Re: document()-function, using 2 arguments

Subject: Re: document()-function, using 2 arguments
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 04 Apr 2000 19:22:27 -0400
At 00/04/04 14:33 +0200, michael gruber wrote:
Has anybody some examples on how to use the second argument in the
document function?
Don't know whether it's useful or not but I don't want missing
anything...
I've read the spec, but I didn't understand it :-(

I was obliged to use the second argument in my book production environment.


I have a "share" construct in my XML that allows me to define content in another XML file and access it algorithmically through an unparsed NDATA entity. I am not using the other XML file syntactically through XML parsed entity referencing ... each package of content is named in the shared file and I am pointing to a package through an NDATA entity for the file and pulling in content from that remote entity according to the share construct. With my book spread out over a number of subdirectories, I have relative paths between subdirectories in my SYSTEM identifiers for my NDATA entities.

Recall that every node in the source and stylesheet node trees has a "Base URI" being the URI of the entity in which the node is found when read by the XML processor inside the XSLT processor.

Recall also that if you do not supply a second argument to the document() function then the a relative first argument value is resolved relative to the stylesheet node's base URI (hence, relative to the subdirectory in which the stylesheet is found). If you do supply a second argument to the document() function, a relative first argument is resolved relative to the base URI of the node in the supplied second argument.

In my situation I was using relative SYSTEM identifiers in my unparsed entity declaration and I was omitting the second argument ... thus, when the XSLT processor resolved my relative addresses, it was going relative to my stylesheet directory which is one level higher in my directory structure than my XML storage directory ... hence, my shared file of XML was never being found!

My fix was to change the call from "document($file)" to be "document($file,.)" which supplied my current XML source file node instead of the default current XSLT stylesheet file node ... and my relative addresses were then being resolved relative to my data directory and not relative to my stylesheet directory ... everything started to work and I *finally* understood that second argument for myself.

I hope this has helped.

................. Ken

--
G. Ken Holman                    mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.             http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0   +1(613)489-0999   (Fax:-0995)
Web site: XSL/XML/DSSSL/SGML services, training, libraries, products.
Practical Transformation Using XSLT and XPath      ISBN 1-894049-04-7
Next instructor-led training:    2000-05-02,2000-05-11/12,2000-05-15,
-                                    2000-06-12,2000-06-13,2001-01-27


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread