[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Saxon and XT both exhibit unexpected document() behavi
Please bear with me while I describe the situation in which I find
myself. After hours of debugging a largish stylesheet with 6 imported
fragments and trying to reproduce the problem, I have finally narrowed it
down to the shortest reproducable example I could think of with only a
single imported fragment.
I delivered a stylesheet to a customer where the document function utilized a URI relative to the stylesheet, and we witnessed what I believe is the incorrect file being accessed when we changed the relative URI from being in the local directory to being in a remote directory. Below, I have set up data files relative to the stylesheet to be accessed by the stylesheet so I am using a string argument for a relative URI and no second argument, thus the document() function should be relative to the Base URI of the stylesheet fragment that calls document(). In the transcript below you will find: (1) - a directory listing showing only four files in two directories: dir1/data.xml dir1/ss1.xsl dir2/data.xml dir2/ss2.xsl (2) - the exposition of each data.xml: they identify themselves (3) - stylesheet dir1/ss1.xsl is run from dir1 and imports dir2/ss2.xsl (4) - ss2's call to document('data.xml') correctly finds dir2/data.xml (5) - ss2's call to document('../data.xml') incorrectly finds dir1/data.xml instead of reporting that data.xml is not in the parent directory Can anyone justify from the XSLT specification why both XT and Instant Saxon 6.5.3 find the dir1/data.xml file when the relative URI is "../data.xml" and the stylesheet fragment is dir2/ss2.xsl? I believe both should be reporting the error that the parent directory of dir2 does not contain the file "data.xml", but if they both are doing the same behaviour then it must be something I'm missing from the spec. BTW, I did get the expected error when the same document() calls were made in ss1.xsl and no imported fragments. It only happens when being called from an imported fragment, and I use imported fragments for large stylesheets. Thanks for any help anyone can provide! ...................... Ken T:\test\dir1>dir \test /s Volume in drive T is Crane Data Volume Serial Number is 0445-7502 Directory of T:\test 2003-12-03 21:11 <DIR> . 2003-12-03 21:11 <DIR> .. 2003-12-03 21:13 <DIR> dir1 2003-12-03 21:13 <DIR> dir2 0 File(s) 0 bytes Directory of T:\test\dir1 2003-12-03 21:13 <DIR> . 2003-12-03 21:13 <DIR> .. 2003-12-03 21:12 24 data.xml 2003-12-03 21:10 296 ss1.xsl 2 File(s) 320 bytes Directory of T:\test\dir2 2003-12-03 21:13 <DIR> . 2003-12-03 21:13 <DIR> .. 2003-12-03 21:12 24 data.xml 2003-12-03 21:08 340 ss2.xsl 2 File(s) 364 bytes Total Files Listed: 4 File(s) 684 bytes 8 Dir(s) 12,797,771,776 bytes free T:\test\dir1>type data.xml <dir>dir1\data.xml</dir> T:\test\dir1>type ..\dir2\data.xml <dir>dir2\data.xml</dir> T:\test\dir1>type ss1.xsl <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:import href="..\dir2\ss2.xsl"/> <xsl:output method="text"/> <xsl:template match="/"> <xsl:call-template name="remote"/> </xsl:template> </xsl:stylesheet> T:\test\dir1>type ..\dir2\ss2.xsl <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template name="remote"> "data.xml" from ss2: <xsl:value-of select="document('data.xml')"/> "../data.xml" from ss2: <xsl:value-of select="document('../data.xml')"/> </xsl:template> </xsl:stylesheet> T:\test\dir1>xt ss1.xsl ss1.xsl "data.xml" from ss2: dir2\data.xml "../data.xml" from ss2: dir1\data.xml T:\test\dir1>saxon ss1.xsl ss1.xsl "data.xml" from ss2: dir2\data.xml "../data.xml" from ss2: dir1\data.xml T:\test\dir1> -- Next public European delivery: 3-day XSLT/2-day XSL-FO 2004-01-?? Instructor-led on-site corporate, government & user group training for XSLT and XSL-FO world-wide: please contact us for the details 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 (F:-0995) ISBN 0-13-065196-6 Definitive XSLT and XPath ISBN 0-13-140374-5 Definitive XSL-FO ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath ISBN 1-894049-11-X Practical Formatting Using XSL-FO Member of the XML Guild of Practitioners: http://XMLGuild.info Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|