[xquery-talk] Use Saxon Proccessor to Process XQuery (without external variables)

Alice Wei ajwei at indiana.edu
Mon Dec 31 12:56:29 PST 2007


  Thanks for helping me out with solving this problem. The follow up 
question I have is, should I create a different command to parse the 
result when there is no external variable stated in my XQuery?

For example:

declare boundary-space preserve;

  let $course := doc("resume_2.xml")//course_name/name
<name>{string-join($course, ', ')}</name>

This one obviously has no external variables to be declared. When I use 
the terminal prompt to call up the command, the error brings up as the 
one below:

java -classpath ./saxon8.jar net.sf.Query question_1_1.xquery > query_1.xml
Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/Query

Am I not supposed to run the XQuery command this way? The error does 
not generate as the one above when there is an "external variable" in 
the declare statement at the beginning?

Thanks to those who can help.


Alice Wei
MIS 2008
School of Library and Information Science
Indiana University Bloomington
ajwei at indiana.edu

Quoting Michael Kay <mike at saxonica.com>:

> The default entry point in saxon8.jar (and indeed saxon9.jar) is the XSLT
> processor, so if you use the -jar option then you need to supply parameters
> for XSLT processing. For XQuery processing, use
> java net.sf.saxon.Query sample.xquery text=SLIS
> This is documented at
> http://www.saxonica.com/documentation/using-xquery/commandline.html
> Michael Kay
> http://www.saxonica.com/
>> -----Original Message-----
>> From: talk-bounces at x-query.com
>> [mailto:talk-bounces at x-query.com] On Behalf Of Alice Wei
>> Sent: 28 December 2007 16:38
>> To: talk at x-query.com
>> Subject: [xquery-talk] Use Saxon Proccessor to Process XQuery
>> Hi,
>>   I wonder if there are any of you on this list use Saxon
>> (Java) to process XQuery files. I currently process my XQuery
>> files with a XML editor to parse the XQuery. Since I have
>> external variables in my files, I wonder if it is possible to
>> generated it using the command prompt.
>> For my XQuery file, it calls the external file instead of a
>> database, as shown in the following:
>> declare boundary-space preserve;
>> declare variable $text external;
>> <project>
>> {
>> for $project in doc("resume_2.xml")//projection, $content in
>> $project/descrip, $title in $project/project_title, $url in
>> $project/link_2/extras_1/@url
>>     where contains($content, $text)
>> return
>> <projection>
>> <project_title>{data($title)}</project_title>
>> <descrip>{data($content)}</descrip>
>> <link_2>
>> <extras_1 url="{data($url)}"/>
>> </link_2>
>> </projection>
>> }
>> </project>
>> The query works, without a terminal prompt, that is. What I
>> want to do is to call it with a command prompt so I can
>> change my variable from case to case. According to Dr. Kay's
>> article in Learn XQuery in 10 minutes, the prompt is as follows:
>>   java net.sf.saxon.Query sample.xquery firstName=Lisa
>> I tried implementing it on my server, which my saxon8.jar
>> file is on the same path as my to be parsed files, but the
>> prompt result is as
>> follows:
>> java saxon8.jar question_8.xquery text=SLIS Exception in
>> thread "main" java.lang.NoClassDefFoundError: saxon8/jar
>> I then added -jar to make the prompt look like:
>> java -jar saxon8.jar question_8.xquery text=SLIS Stylesheet
>> file text=SLIS does not exist
>> Is there something I did wrong?
>> Thanks for your help.
>> Alice Wei
>> MIS 2008
>> School of Library and Information Science Indiana University
>> Bloomington ajwei at indiana.edu
>> 812-856-2659
>> _______________________________________________
>> talk at x-query.com
>> http://x-query.com/mailman/listinfo/talk

More information about the talk mailing list