[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Problem resolving base URI in document fuction
>>NOTE: I posted this previously to the respective Apache lists, trying here to see if anyone has expertise with this section of the specification or has run into a similar problem.<< Hello, I'm using Cocoon 1.7.4, Tomcat 3.2 beta, Xerces 1.0.3, and Xalan 1.1. I have a project that uses XML documents of a specific grammar to pass filenames to a stylesheet which then loads them with the "document()" function relative to the source document. I'm having a problem where Xalan's implementation of document() either isn't working properly, or I'm not understanding the XSLT specification fully. For example lets say I have a file: <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="view/mydoc.xsl"?> <mydoc filename="mydoc"/> and it is located in /mydoc.xml (path on tomcat context) for which the REAL directory is: D:\somedir\webapps\docroot\mydoc.xml and I have a file: <?xml version="1.0"?> <myresources> <myresource id="test">Testing, 1, 2, 3</myresource> </myresources> and it is located in /resources/mydoc_en.xml (path on tomcat context) for which the REAL directory is: D:\somedir\webapps\docroot\resources\mydoc_en.xml and I have a stylesheet: <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:variable name="myotherdoc" select="document(concat('resources/', /mydoc/@filename, '_en.xml'), /mydoc)/myresources"/> </xsl:stylesheet> and it is located in /view/mydoc.xsl (path on tomcat context) for which the REAL directory is: D:\somedir\webapps\docroot\view\mydoc.xsl As per the XSL specification, the document() function can take one, or two parameters. If it only takes one this can be an existing nodeset to be treated as a document with its own root or a string that specifies a filename of an XML document to load. The spec also says if the second parameter is ommitted the base URI that will be used to resolve the filename (if relative) is determined from the document that contains the call to the document() function. This is not the case, in that I want to load the "resource" file for a document in a directory relative to my original mydoc.xml file. Luckily, the spec also states that if you pass a nodeset as the second parameter to document(), the document from which this nodeset was retrieved (the first node in document order) will be used to resolve the base URI. If you look at the xsl:stylesheet, I do this by passing a second parameter to document with nodes from the original source document being transformed. The problem is, I can tell it DOES use the second parameter to form the base URI, but the base URI comes out relative to the web URI and not the URI on the filesystem. In the example above, Xalan tries to load the following document: D:\somedir\resources\mydoc_en.xml Which of course doesn't exist. It looks as though the base URI was determined as being different, but went up too many levels. Any help with this problem would be great. Its pretty critical to provide fully extensibly data-to-style based web solutions with XSL. Thanks, Jayme 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
|