Name

document() Function — Allows you to process multiple source documents in a single stylesheet. This extremely powerful and flexible function is the subject of Chapter 7, so we’ll only include a brief overview of the function here.

Synopsis

node-set document(
               object
               node-set?
               )

Inputs

The document() function most commonly takes a string as its argument; that string is treated as a URI, and the XSLT processor attempts to open that URI and parse it. If the string is empty (the function call is document('')), the document() function parses the stylesheet itself. See Section 7.3 in Chapter 7 for all the details on the parameters to the document() function.

Output

A node-set containing the nodes identified by the input argument. Again, Chapter 7 has all the details, so we won’t rehash them here.

Defined in

XSLT section 12.1, Multiple Source Documents.

Example

The following example uses the document() function with an empty string to implement a lookup table. Here is our XML document:

<?xml version="1.0"?>
<report>
  <title>Miles Flown in 2001</title>
  <month sequence="01">
    <miles-flown>12379</miles-flown>
    <miles-earned>35215</miles-earned>
  </month>
  <month sequence="02">
    <miles-flown>32857</miles-flown>
    <miles-earned>92731</miles-earned>
  </month>
  <month sequence="03">
    <miles-flown>19920</miles-flown>
    <miles-earned>76725</miles-earned>
  </month>
  <month sequence="04">
    <miles-flown>18903</miles-flown>
    <miles-earned>31781</miles-earned>
  </month>
</report>

We can use the document() function to convert ...

Get XSLT now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.