Query looks good. But when I see the "doc("score.xml")" call with a
relative path in it, I'm thinking that is something that can cause
problems. Also, please note that the free version of Saxon that XMLBeans
uses doesn't support typed XQuery so you need to try XMLSpy without the
Schema for a meaningful comparison.
 
Radu


________________________________

        From: Gustavo Aquino [mailto:[EMAIL PROTECTED] 
        Sent: Wednesday, April 16, 2008 2:17 PM
        To: [email protected]
        Subject: XQuery
        
        
        Hi,
         
        I'm trying to use XQuery in XMLBeans.
         
        Well using samples in XMLBeans package, all work fine, but when
i write my XQuery it is not work.
         
        I wrote my XQuery and validate in XML Spy and all work fines,
but when i put my xquery in XMLBeans this not return nothing.
         
         
        
------------------------------------------------------------------------
----------------------------------------------------------------------
XQUERY -----
        declare

        namespace n1='http://xxxxx.com.br/score/probability';
        for $x in doc("score.xml")/n1:scores/score
          let $s := $x/name 
          where $s = 'Score1' 
        return $x
        
------------------------------------------------------------------------
----------------------------------------------------------------------
XML -----
        <?xml version="1.0" encoding="UTF-8"?>
        

        <n1:scores
xsi:schemaLocation="http://xxxxx.com.br/score/probability
score_probability.xsd" xmlns:n1="http://xxxxx.com.br/score/probability";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
        <score>
        <class>0</class>
        <rating>String</rating>
        <probability>String</probability>
        <initial_score>0</initial_score>
        <end_score>0</end_score>
        <name>Score1</name>
        </score>
        <score>
        <class>0</class>
        <rating>String</rating>
        <probability>String</probability>
        <initial_score>0</initial_score>
        <end_score>0</end_score>
        <name>Score2</name>
        </score>
        <score>
        <class>0</class>
        <rating>String</rating>
        <probability>String</probability>
        <initial_score>0</initial_score>
        <end_score>0</end_score>
        <name>Score3</name>
        </score>
        </n1:scores>
        
------------------------------------------------------------------------
----------------------------------------------------------------------
RETURN  XML Spry-----
         <score xmlns:n1=http://xxxxx.com.br/score/probability
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";><class>0</class><r
ating>String</rating><probability>String</probability><initial_score>0</
initial_score><end_score>0</end_score><name>Score1</name></score>
         
        
------------------------------------------------------------------------
----------------------------------------------------------------------
CODE -----
         
          

        String newQuery=

        "declare namespace n1='http://xxxxx.com.br/score/probability';
"+
        "for $x in $this/n1:scores/score "+
        "let $s := $x/name "+
        "where $s = 'Score1' "+
        "return $x"; 

        

        XmlCursor scoreCursor = 

        scoreDoc.newCursor();
        scoreCursor.toNextToken();
        XmlCursor resultCursor = scoreCursor.execQuery(newQuery);
        System.out.println("The query results : ");
        System.out.println(resultCursor.getObject().toString() + "\n");
        
------------------------------------------------------------------------
----------------------------------------------------------------------
RETURN  PROGRAM-----
          

        The query results : 

        

        <xml-fragment/>

         

         

        Thanks for any help.

        Gustavo

         


Notice:  This email message, together with any attachments, may contain 
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated 
entities,  that may be confidential,  proprietary,  copyrighted  and/or legally 
privileged, and is intended solely for the use of the individual or entity 
named in this message. If you are not the intended recipient, and have received 
this message in error, please immediately return this by email and then delete 
it.

Reply via email to