Partager via


Step 5: Adding Other Documents

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

Not all documents are sales figures. You can incorporate new XML into your output from external documents through the document() function. This function can take as an argument the relative or absolute Uniform Resource Locater (URL) of the document you want to retrieve as a string or a node in which the text value of that node resolves to a URL. With document(), you load the entire contents of the document, and can even manipulate them as if the document was itself an XML document using XML Path Language (XPath) and XSLT expressions.

You will create a document called Ancillary.xml that will contain a watermark and a copyright notice for the report.

To create Ancillary.xml

  1. Paste the following text into your HTML editor.

    <document>
      <watermark></watermark>
      <copyright></copyright>
    </document>
    
  2. Save the file as Ancillary.xml.

  1. Open Ancillary.xml.

  2. Paste Lucerne Publishing between the <watermark> and </watermark> tags.

  3. Paste the following copyright information between the <copyright> and </copyright> tags.

    The file should look like this:

    <document>
    <watermark>Lucerne Publishing</watermark>
    <copyright>Copyright 2000, Lucerne Publishing. All Rights Reserved.</copyright>
    </document>
    
  4. Save Ancillary.xml, and then open Transform.xsl.

  5. To load the ancillary document into the variable named ancillary in Transform.xsl, paste the following after the <body> element.

          <xsl:variable name="ancillary" 
               select="document('ancillary.xml')"/>
    
  6. To add the watermark, paste the following directly below the lines that you just added.

          <div style="position:absolute;font-size:96;font-family:Times New Roman;color:#F0F0F0;z-index:-1">
    <xsl:value-of select="$ancillary//watermark"/>
          </div>
    
  7. To add the copyright notice, paste the following directly above the </BODY> tag.

            <div style="font-size:9">
            <xsl:value-of select="$ancillary//copyright"/>
        </div>
    
  8. Save Transform.xsl.

    Your final result should look like this:

    Aa925516.ea333fac-1124-41e3-80a9-974f2fbb828b(en-us,MSDN.10).gif

See Also

Tasks

Step 4: Adding Conditional Statements
Tutorial: Getting Started with XSLT

Concepts

Exploring XSLT Capabilities
XSLT Developer Guide