Project

Profile

Help

XSLT: commandline versus TransformerFactory

Added by Anonymous about 17 years ago

Legacy ID: #4385639 Legacy Poster: holtkamp (holtkamper)

When performing a XSLT 2.0 transformation using net.sf.saxon.Transformer, an exception is thrown. When performing the same transformation from commandline it succeeds properly. The strange part however is that the error does exists in both situations, but is ignored in the commandline transformation. The exception that is thrown: XPTY0004: A sequence of more than one item is not allowed as the first argument of lower-case() ("Name1", "Name2") net.sf.saxon.trans.DynamicError: A sequence of more than one item is not allowed as the first argument of lower-case() ("Name1", "Name2") at net.sf.saxon.expr.Expression.typeError(Expression.java:791) at net.sf.saxon.expr.CardinalityChecker.evaluateItem(CardinalityChecker.java:284) at net.sf.saxon.functions.ForceCase.evaluateItem(ForceCase.java:23) at net.sf.saxon.functions.KeyFn.iterate(KeyFn.java:224) at net.sf.saxon.expr.Expression.effectiveBooleanValue(Expression.java:299) at net.sf.saxon.expr.BooleanExpression.effectiveBooleanValue(BooleanExpression.java:171) at net.sf.saxon.expr.BooleanExpression.effectiveBooleanValue(BooleanExpression.java:171) at net.sf.saxon.expr.BooleanExpression.effectiveBooleanValue(BooleanExpression.java:174) at net.sf.saxon.instruct.Choose.processLeavingTail(Choose.java:334) at net.sf.saxon.instruct.Block.processLeavingTail(Block.java:365) at net.sf.saxon.instruct.Template.applyLeavingTail(Template.java:98) at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:317) at net.sf.saxon.instruct.ApplyTemplates.defaultAction(ApplyTemplates.java:349) at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:310) at net.sf.saxon.instruct.ApplyTemplates.defaultAction(ApplyTemplates.java:349) at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:310) at net.sf.saxon.instruct.ApplyTemplates.defaultAction(ApplyTemplates.java:349) at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:310) at net.sf.saxon.instruct.ApplyTemplates.defaultAction(ApplyTemplates.java:349) at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:310) at net.sf.saxon.instruct.ApplyTemplates.apply(ApplyTemplates.java:187) at net.sf.saxon.instruct.ApplyTemplates.processLeavingTail(ApplyTemplates.java:151) at net.sf.saxon.instruct.Block.processLeavingTail(Block.java:365) at net.sf.saxon.instruct.Instruction.process(Instruction.java:91) at net.sf.saxon.instruct.ElementCreator.processLeavingTail(ElementCreator.java:240) at net.sf.saxon.instruct.Block.processLeavingTail(Block.java:365) at net.sf.saxon.instruct.Template.applyLeavingTail(Template.java:98) at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:317) at net.sf.saxon.Controller.transformDocument(Controller.java:1705) at net.sf.saxon.Controller.transform(Controller.java:1513) The XML instance that has to be transformed: <root> <type> <source>Source</source> <value>Name1</value> <value>Name2</value> </type> </root The actual transformation: <xsl:template match="//ns:type"> <!--Succeeds in commandline mode, but fails using net.sf.saxon.TransformerFactoryImpl.transform() --> <xsl:choose> <xsl:when test="doc-available('./fileDoesNotExist.xml') and key('KEY' , lower-case(./ns:value), doc('./fileDoesNotExist.xml' ))"/> <xsl:otherwise> <dd xmlns="http://www.w3.org/1999/xhtml" class="assert">Not found</dd> </xsl:otherwise> </xsl:choose> <!--Fails in commandline as well --> <xsl:choose> <xsl:when test="lower-case(./ns:value)"/> <xsl:otherwise> <dd xmlns="http://www.w3.org/1999/xhtml" class="assert">Not found</dd> </xsl:otherwise> </xsl:choose> </xsl:template> I did found some topics about the errormessage XPTY0004, the difference between XSLT 1.0 and 2.0 and the point that I should use ./ns:value[0] to refer to the first element. However, providing various items should not result in a fatal error. My idea is that in command-line mode, since doc-available('./fileDoesNotExist.xml') fails, the rest of the expression is not evaluated and therefore the transformation continues. We use these transformations for validation purposes, therefore a stylesheet compilation error caused by two <value> elements should not result in a fatal error but in a warning. The transformation itself should not halt. Is this possible to achieve using the transformerFactory as well?


Replies (2)

RE: XSLT: commandline versus TransformerFacto - Added by Anonymous about 17 years ago

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

Could you confirm which Saxon version you are using, and that it is the same in both cases? There have been problems in the past with doc-available() masking more errors than it should mask, but I thought these were fixed.

RE: XSLT: commandline versus TransformerFacto - Added by Anonymous about 17 years ago

Legacy ID: #4393996 Legacy Poster: holtkamp (holtkamper)

Aah, should have included that information the first time, currently using: -Saxon 8.9J from Saxonica -Java version 1.5.0_11

    (1-2/2)

    Please register to reply