The effects of the document() function vary, depending on the type and number of arguments supplied.
-
If only one argument is provided and that argument is a string, document() treats the string as a URL and retrieves the document as a set of nodes. See Example 1 below for a code illustration.
-
If only one argument is provided and that argument is a node set, then each node in that node set is treated as a URL and the function returns the union of all of the documents referenced. See Example 2 below for a code illustration.
-
If there are two arguments, the first argument can be either a string or a node set while the second argument must be a node set. The second argument, when supplied, serves to indicate the base URL to which the contents of the first argument are relative. See Example 3 below for a code illustration.
-
If an empty string is passed to the document() function, the result is the source XML of the XSLT document itself, unless the second argument is given (and is not null). In the latter case, the URL of the document is the base URL of the node contained in the second element.
When an XML document is downloaded from within an ASP page using the document() function with an absolute URL as its argument, the ServerHTTPRequest property must be set to true on the DOM object holding the XSLT style sheet before any transformation is initiated, as shown in the following JScript code fragment:
xsltDom.setProperty("ServerHTTPRequest", true);
The reason for this is that MSXML uses URLMON.dll as the default to support file download. However, ASP does not support URLMON. Therefore, you need to set this property to choose WinHTTP.dll as the alternative to downloads.