Project

Profile

Help

Running Xquery from the command line

Added by Anonymous almost 16 years ago

Legacy ID: #6204910 Legacy Poster: pvallone (pvallone)

Please excuse me if this is a newbie question. I am trying to run a simple xquery from the command line, as per http://www.saxonica.com/documentation/using-xquery/commandline.html Command: java -cp C:/sandbox/saxonb9-1-0-5j net.sf.saxon.query -q:missingXrefs-base-uri().xq I get the java.lang.NoClassDefFoundError: net/sf/saxon/query. I looked at the source code, and I can't seem to find the entry point for xquery. My saxon files are loaded in the class path. What am I missing? Thanks Phil


Replies (4)

Please register to reply

RE: Running Xquery from the command line - Added by Anonymous almost 16 years ago

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

First, you need the Jar files to be on the classpath, not the directory containing them. So I would expect to see -cp C:/sandbox/saxonb9-1-0-5j/saxon9.jar And its net.sf.saxon.Query not net.sf.saxon.query - Java class names are case-sensitive. Michael Kay http://www.saxonica.com/

RE: Running Xquery from the command line - Added by Anonymous almost 16 years ago

Legacy ID: #6205640 Legacy Poster: pvallone (pvallone)

Thanks. One more question. Running this xquery expression in .net works, but I get an error in the java version: xquery version "1.0"; (:find missing xrefs:) declare namespace f = "http://somewhere.com/"; declare namespace saxon = "http://saxon.sf.net/"; declare function f:name-and-position($n as element()) as xs:string { concat(name($n), '[', 1+count($n/preceding-sibling::[node-name(.) = node-name($n)]), ']') }; for $h in //xref/@href let $xpath := $h/string-join(ancestor-or-self:: /f:name-and-position(.), '/') let $base := $h/base-uri() let $line := $h/saxon:line-number(.) return if (//@id[.=$h]) then <ok/> else <not-found id="{$h}" file="{$base}" line="{$line}">/{$xpath} </not-found> Error: Error on line 8 of missingXrefs-base-uri().xq: XPDY0002: Finding root of tree: the context item is undefined Query processing failed: Run-time errors were reported Line 8 is: for $h in //xref/@href Thanks, Phil

RE: Running Xquery from the command line - Added by Anonymous almost 16 years ago

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

That message implies you didn't supply a source XML filename on the command line.

RE: Running Xquery from the command line - Added by Anonymous almost 16 years ago

Legacy ID: #6205793 Legacy Poster: pvallone (pvallone)

Well a source file would be helpful! Ahhh, I am trying to do too much at once. Thanks for the help.

    (1-4/4)

    Please register to reply