sergi / xslty

Command-line XSLT 2.0 processor
Mozilla Public License 2.0
13 stars 5 forks source link

xsl import fails #1

Open mikaa123 opened 10 years ago

mikaa123 commented 10 years ago

Hey there! First, let me thank you for this great tool. It's extremely valuable to what I am doing.

I am having an issue regarding xsl:import tags.

<xsl:import href="myFile.xsl"/>

Throws the following error:

SEVERE: Error at /xsl:stylesheet/xsl:import[1] in XTSE0165: Cannot initialize URI with empty parameters. SaxonCE.XSLT20Processor 11:57:01.451 SEVERE: XPathException in renderXML: Failed to compile stylesheet. 1 error detected.

Not sure if this problem is directly linked to xslty.

Anyway, thank you and have a great day!

ghost commented 10 years ago

I am not an xslty user, but I came across this report looking into the same issue for another context.

When a string containing XML is passed to Saxon-CE, the resulting XML document has a null document.baseURI property, meaning that any nodes in an XSL stylesheet inheriting from that value, probably including that xsl:import node, will have the same. Since your import statement probably has a relative URI (and no explicit @xml:base value), that URI cannot be resolved.

There are a few ways that this can be worked around from what I can tell:

1) [for xslty.js] Send Saxon-CE an XML document (XSL styelsheet) using the call

   var xslt = Saxon.requestXML(system.args[2]);

instead, where the XSL stylesheet path was passed in in that arg. This will allow the parsed XML document to have a valid baseURI.

2) [for end-user usage] Use an absolute path for the xsl:import statement, or set an @xml:base attribute value for the xsl:stylesheet node. For example,

   <xsl:stylesheet version="2.0" xml:base="file:///path.to.stylesheet.xsl">

I haven't tested any of this, but I am fairly certain either should be a fix.