Project

Profile

Help

saxon nullpointer exception xquery xml copy

Added by Anonymous about 18 years ago

Legacy ID: #3742299 Legacy Poster: thomaskre (thomaskre)

hi, i try to write a xquery function that copy the first $k nodes of a xml document. if the node to copy is not an element-node, copy the node. if the node is an element-node and the element contains childs, the function should copy the first $k nodes under this element. i used xml-spy to debug. and it works. but if i try to "compile" my function with saxon i get a nullpointer exception. and i don`t know why. maybe someone could help me! and how can i turn on debuging for saxon, so that i can see where exactly in my source-code of the function the null-pointer exception is thrown? thanks! -source---------------------------------------- declare variable $t:= doc("Buchbestand.xml"); declare function local:nodeCopy( $a as node(), $k as xs:integer) as node()* { let $w := $a/node() for $b at $i in $w return if($i <= $k) then ( if($b/child::) then ( element {fn:node-name($b)} {$b/@, local:nodeCopy( $b,$k)} ) else ($b) ) else() }; local:nodeCopy($t/BUCHBESTAND/BUCH[1],3) ----------------------------------------------- -error message---------------------------------- java.lang.NullPointerException at net.sf.saxon.expr.ValueComparison.compare(ValueComparison.java:519) at net.sf.saxon.expr.ValueComparison.evaluateItem(ValueComparison.java:5 55) at net.sf.saxon.expr.ComputedExpression.iterate(ComputedExpression.java: 564) at net.sf.saxon.expr.FilterIterator.matches(FilterIterator.java:82) at net.sf.saxon.expr.FilterIterator.getNextMatchingItem(FilterIterator.j ava:64) at net.sf.saxon.expr.FilterIterator.next(FilterIterator.java:44) at net.sf.saxon.expr.MappingIterator.next(MappingIterator.java:52) at net.sf.saxon.expr.ComputedExpression.process(ComputedExpression.java: 603) at net.sf.saxon.query.XQueryExpression.run(XQueryExpression.java:312) at net.sf.saxon.Query.doQuery(Query.java:449) at net.sf.saxon.Query.main(Query.java:81) Fatal error during transformation: null --------------------------------------------------


Replies (2)

RE: saxon nullpointer exception xquery xml co - Added by Anonymous about 18 years ago

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

An NPE occurring in the middle of Saxon code means you've hit a Saxon bug. Are you sure you're running the latest version (8.7.1)?

RE: saxon nullpointer exception xquery xml co - Added by Anonymous about 18 years ago

Legacy ID: #3742347 Legacy Poster: thomaskre (thomaskre)

i just downloaded the version: saxonb8-7-1j.zip ... hope it is the proper .zip file. and i use the saxon8.jar out of this .zip . i startet the program with: set CLASSPATH=.;..\saxon8.jar; java net.sf.saxon.Query test4.xquery > result02.xml pause

    (1-2/2)

    Please register to reply