Project

Profile

Help

xsl:include and UNC path error

Added by Anonymous about 17 years ago

Legacy ID: #4619860 Legacy Poster: Andrew Fang (afang4)

This problem occurred in 9.0. I have three xsl stylesheets A, B, and C. A includes B and B includes C. B is on a network drive and C is at the same directory as B. E.g. (root element removed for clarity) A.xsl <xsl:template match="/"> <root> <xsl:apply-templates/> </root> </xsl:template> <xsl:include href="file:////MyMachine/test%20include/B.xsl"/> B.xsl <xsl:template match="doc"> <document></document> </xsl:template> <xsl:include href="C.xsl"/> C.xsl <xsl:template match="ch"> <chapter></chapter> </xsl:template> When try to transform against A.xsl, I got the following error: Warning: at xsl:stylesheet on line 4 of file:////MyMachine/test%20include/A.xsl: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor Error at xsl:include on line 11 of file:////MyMachine/test%20include/B.xsl: XTSE0165: java.io.FileNotFoundException: \MyMachine\test include\C.xsl (The system cannot find the path specified) However, if I change xsl:include in A from four slahses to two slahses, i.e., <xsl:include href="file://MyMachine/test%20include/B.xsl"/> It all works fine. However, I believe file:////... is a valid URI. Am I missing something? The same syntax works for 6.5.x.


Replies (4)

Please register to reply

RE: xsl:include and UNC path error - Added by Anonymous about 17 years ago

Legacy ID: #4619969 Legacy Poster: Michael Kay (mhkay)

It seems that when given the absolute URI file:////machine/folder/b.xsl, and the relative URI c.xsl, the Java class java.net.URI produces the answer file:/machine/folder/c.xsl, which maps to a file on the local machine rather than the remote machine. On the whole the java.net.URI class sticks very closely to the standards - sometimes too closely for comfort. I've spent some time (yet again) reading the fine print of rfc 3986, and to be honest, I think you can read it in more than one way. It hinges on whether an authority component of "" satisfies the condition defined(authority) in section 5.3. Frankly, I think this is debatable. Whoever wrote java.net.URI obviously decided that it didn't. However, it does seem unsatisfactory: if java.net.URI thinks that it's a valid URI, then it should do something intelligent when resolving it against a relative URI. The XSLT specs are pretty strong on using RFC 3986, and the java.net.URI implementation is probably the best one available. Pragmatically, though, I departed from it for handling the "jar:" URI scheme (which doesn't fit into RFC 3986 at all) by using the code in java.net.URL instead. So I think in future I'll take URIs beginning with "file:////" down the same path as "jar:" URIs, using the java.net.URL class to resolve them. If you want to do this yourself in the meantime, the logic is all in the URIResolver so you can change it by writing your own.

RE: xsl:include and UNC path error - Added by Anonymous about 17 years ago

Legacy ID: #4619974 Legacy Poster: Michael Kay (mhkay)

(Incidentally, the change in Saxon to use java.net.URI for URI resolution was made years ago, this certainly isn't a new problem in 9.0).

RE: xsl:include and UNC path error - Added by Anonymous about 17 years ago

Legacy ID: #4620042 Legacy Poster: Michael Kay (mhkay)

I have added some notes on UNC filename support to the Wiki at http://saxon.wiki.sourceforge.net/UNC+filenames Michael Kay

RE: xsl:include and UNC path error - Added by Anonymous about 17 years ago

Legacy ID: #4621098 Legacy Poster: Andrew Fang (afang4)

Michael, Thanks for looking into this issue. Really appreciated. The problem may exist in 7.x and 8.x (I did not test). However, for your reference, I just tried again on 6.5.3 and the problem did not occur there. Andrew

    (1-4/4)

    Please register to reply