Project

Profile

Help

switching from Xalan to Saxon

Added by sunil dangayach over 11 years ago

Getting error while saxon parser parsing saxon:evaluate function.It is giving error while we are passing null string or invalid xpath values.

This exception I am getting:

XPST0003: Static error in XPath expression supplied to saxon:evaluate: Unexpected token
  "" in path expression
net.sf.saxon.trans.XPathException: Static error in XPath expression supplied to saxon:evaluate: Unexpected token "" in path expression
    at com.saxonica.functions.extfn.Evaluate$EvaluateCall.prepareExpression(Evaluate.java:223)
    at com.saxonica.functions.extfn.Evaluate$EvaluateCall.call(Evaluate.java:263)
    at net.sf.saxon.functions.IntegratedFunctionCall.call(IntegratedFunctionCall.java:298)
    at CE__Slash__29499086.process(file:/D:/WORKS/WORKS_ON_XSLT2.0/Test.xsl:48)
    at com.saxonica.bytecode.CompiledExpression.process(CompiledExpression.java:60)
    at net.sf.saxon.expr.instruct.Template.applyLeavingTail(Template.java:214)
    at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1034)
    at net.sf.saxon.Controller.transformDocument(Controller.java:1957)
    at net.sf.saxon.Controller.transform(Controller.java:1803)
    at com.iflex.fcat.gui.content.TestXMLXSLTContentGenerator.simpleTransform(TestXMLXSLTContentGenerator.java:177)
    at com.iflex.fcat.gui.content.TestXMLXSLTContentGenerator.main(TestXMLXSLTContentGenerator.java:190)

Replies (11)

Please register to reply

RE: switching from Xalan to Saxon - Added by O'Neil Delpratt over 11 years ago

Hi Sunil, I am not able to reproduce this error. Please may you let us know which version of Saxon you are running?

Looking at the stack trace the error might be related to our bytecode generation feature, but it would be useful if you can send us the stylesheet which causes the error either as reply to this post or by email if content is confidential.

RE: switching from Xalan to Saxon - Added by O'Neil Delpratt over 11 years ago

HI Sunil,

I managed to reproduce the error. I don't think this is a bug as I would expect to see the XPathException thrown for an invalid or null string passed as the parameter for saxon:evaluate.

RE: switching from Xalan to Saxon - Added by sunil dangayach over 11 years ago

Thanks for your useful comment.Can you please elaborate us how can i catch that particular exception in xslt or how can i avoid that particular exception in my xslt code.

RE: switching from Xalan to Saxon - Added by sunil dangayach over 11 years ago

sunil dangayach wrote:

Thanks for your useful comment.yes you are right it is giving exception while we are passing null string or invalid xpath So Can you please elaborate us how can i catch that particular exception in xslt or how can i avoid that particular exception in my xslt code.

RE: switching from Xalan to Saxon - Added by O'Neil Delpratt over 11 years ago

Cannot give you a definite answer here without seeing your stylesheet(s), but what is clear is the value supplied to the saxon:evaluate is not valid and a expression cannot be constructed. I would start by looking there.

Just to point out you can catching the exception in a xsl:try (XSLT 3.0 feature), but this is probably not your intentions?

RE: switching from Xalan to Saxon - Added by sunil dangayach over 11 years ago

This is sample code snippet.

	

			
				
					
						
						
						
						hidden
						
					

				
					
					
				
			
			
				
					
						
						
						
						hidden
						
					
			
		

RE: switching from Xalan to Saxon - Added by sunil dangayach over 11 years ago

Whenever i am getting some null string it is giving me that exception.

RE: switching from Xalan to Saxon - Added by sunil dangayach over 11 years ago

Whenever i am getting some null string it is giving me that exception while it was working fine when i was using xalan parson instead of saxon.

RE: switching from Xalan to Saxon - Added by sunil dangayach over 11 years ago

Any type of help would be appreciated.

RE: switching from Xalan to Saxon - Added by O'Neil Delpratt over 11 years ago

Hi Sunil,

I am not sure on the details of the equivelent stylesheet in Xalan. Please see: http://www.saxonica.com/documentation/extensions/functions/evaluate.xml It mentions that the supplied string must contain an XPath expression. If the variable is empty then the xpath constructed after the call of the @concat@ function is '/faml/request/', which I believe should raise an XPath error.

RE: switching from Xalan to Saxon - Added by Michael Kay over 11 years ago

Sunil, you should be able to catch the error using the new xsl:try instruction in XSLT 3.0. I'm not sure it is supported in the Saxon edition you are using though. If you switch to this, you could also switch from saxon:evaluate to the new xsl:evaluate instruction in XSLT 3.0 (it will still fail if the XPath expression is invalid, of course).

    (1-11/11)

    Please register to reply