Project

Profile

Help

xslt saxon8 and variables

Added by Anonymous over 19 years ago

Legacy ID: #2793163 Legacy Poster: Lawrence Michel, CH (arkean_forge)

Hello, I have currently ended coding an entire stylesheet containing several global variables referencing to external document nodes. When processing them using the Altova XMLSPY 2004 local xslt processor, everything works well. But when processing it with saxon, it fails : The xsl stylesheet: <?xml version="1.0" encoding="UTF-16"?> <!-- edited with XMLSPY v2004 rel. 3 U (http://www.xmlspy.com) by Arkean (Arkansys) --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-16" indent="yes"/> <xsl:variable name="TemplateDefinition_node" select="document('../../Templates/XML/TemplateDefinitionAll.xml')"/> <xsl:template match="/"> <xsl:apply-templates select="$TemplateDefinition_node/Classes"/> </xsl:template> <xsl:template match="$TemplateDefinition_node/Classes"> <!--...Content...--> </xsl:template> </xsl:stylesheet> And here the command line used to process it: java -jar saxon8 -o blabla.txt theXMLFile.xml theXSLFile.xsl Errors given : XPath syntax error at char 0 in {$TemplateDefinition_Node}: Unexpected token in pattern, found "$" Thanks for your help Regards


Replies (6)

Please register to reply

RE: xslt saxon8 and variables - Added by Anonymous over 19 years ago

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

Are you sure the code being compiled is the code you have shown? Because (a) the error message refers to TemplateDefinition_Node, while your code specimen always uses a lower case _node, and (b) there are no curly braces around anything in your source. I'm surprised XML Spy accepts the code shown, however: its processor is an XSLT 1.0 processor, and XSLT 1.0 disallows the use of variables in match patterns. This restriction is removed in XSLT 2.0, but only to the extent that variables can be used inside a predicate in a match pattern. Writing match="$TemplateDefinition_node/Classes" is an error in both 1.0 and 2.0. Michael Kay http://www.saxonica.com/

RE: xslt saxon8 and variables - Added by Anonymous over 19 years ago

Legacy ID: #2793235 Legacy Poster: Lawrence Michel, CH (arkean_forge)

Hello again, thanks for your prompt reply. Since the code runs on another computer (which is not the same I'm actually accessing this forum), I just copied manually the error message. I just forgot to upper case the "N" while typing. XMLSpy runs it without any problem, and gives me the output I definitely wanted. I guess the 2004 xsl processor is xslt 1.0 compliant. May I be wrong? The xsl sample is only a minimal and simplified part of the whole xsl I wrote. I may send you a copy of both files (xsl and xml), if it might help you find the problem. regards

RE: xslt saxon8 and variables - Added by Anonymous over 19 years ago

Legacy ID: #2793486 Legacy Poster: Lawrence Michel, CH (arkean_forge)

By the way : Java 2 Runtime Environment, standard edition (Build 1.4.1_02-b06) only! ;-)

RE: xslt saxon8 and variables - Added by Anonymous over 19 years ago

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

As I said before, the match pattern in your example is conformant with neither XSLT 1.0 nor 2.0, so on the evidence so far, you should be sending a bug report to XMLSpy for accepting this syntax. Michael Kay

RE: xslt saxon8 and variables -&gt; ok - Added by Anonymous over 19 years ago

Legacy ID: #2793798 Legacy Poster: Lawrence Michel, CH (arkean_forge)

Thank you for your reply. I converted these xsl:templates into xsl:for-each, without changing the XPATH, and everything works very fine. I'm also quite impressed by the speed of your processor... I used until now the xslt processor of XMLSPY on a 59Mb XML data, with a few other 5Mb external XML document called within the stylesheet, and it took enough time for me to have a bath and enjoy a big amount of coffee breaks during working hours...(Memory swaping). Now, it takes less than a minute :-( Regards

RE: xslt saxon8 and variables -&gt; ok - Added by Anonymous over 19 years ago

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

Good news (On both fronts) thanks for sharing it. I suspect XML Spy is optimized for debugging rather than execution speed - I did a lot of work in Saxon to reduce the run-time memory requirement to the minimum. In 8.1 however there are hooks added so that debugging is also possible, these are exploited in the debugger that comes with Stylus Studio 6.

    (1-6/6)

    Please register to reply