Step 5: Adding Other Documents

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.

To add the watermark and copyright text to 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:

See Also

Step 4: Adding Conditional Statements | Tutorial: Getting Started with XSLT | Exploring XSLT Capabilities | XSLT Developer Guide

 Last updated on Saturday, April 10, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.