You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-users@xml.apache.org by La...@pap.state.ga.us on 2004/06/07 19:51:44 UTC

XPATH query roubles - attribute values

Hello.

I'm attempting to use XPath to return attribute values from the document
store. I'm using 1.1b4.




the first query return the value of the type attribute within the
xq:result.

C:\xindice-1.1b4\bin>xindice xpath -c
xmldb:xindice://localhost:8080/db/ecoavs0.2 -q "/exec:Exhibit
[@exec:ownerRef='_678919600101martian' and @type='PARDON']/@type"
trying to register database
<xq:result type="PARDON" xmlns:xq="http://xml.apache.org/xindice/Query"
xq:col="/db/ecoavs0.2" xq:key="f2aadbe374dd3722-35c41b-fcf19
833d6--8000" />

the next query attempts to get the value of exec:id with the following
error message
C:\xindice-1.1b4\bin>xindice xpath -c
xmldb:xindice://localhost:8080/db/ecoavs0.2 -q "/exec:Exhibit
[@exec:ownerRef='_678919600101mar
tian' and  @type='PARDON']/@exec:id"
trying to register database
[Fatal Error] :2:203: The prefix "exec" for attribute "exec:id" associated
with an element type "xq:result" is not bound.
org.xml.sax.SAXParseException: The prefix "exec" for attribute "exec:id"
associated with an element type "xq:result" is not bound.
        at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
        at
org.apache.xindice.client.xmldb.xmlrpc.CollectionImpl.query(CollectionImpl.java:518)
        at
org.apache.xindice.client.xmldb.XindiceCollection.query(XindiceCollection.java:259)
        at
org.apache.xindice.client.xmldb.services.QueryService.query(QueryService.java:90)
        at
org.apache.xindice.tools.command.XPathQuery.execute(XPathQuery.java:75)
        at org.apache.xindice.tools.XMLTools.execute(XMLTools.java:293)
        at org.apache.xindice.tools.XMLTools.process(XMLTools.java:171)
        at org.apache.xindice.tools.XMLTools.main(XMLTools.java:82)
ERROR : Query error: The prefix "exec" for attribute "exec:id" associated
with an element type "xq:result" is not bound.


If I modify the same query by removingthe namespace from the ID attribute
name the query does not return a xq:result - which I assume indicates that
the query did select any output.
C:\xindice-1.1b4\bin>xindice xpath -c
xmldb:xindice://localhost:8080/db/ecoavs0.2 -q "/exec:Exhibit
[@exec:ownerRef='_678919600101mar
tian' and  @type='PARDON']/@id"
trying to register database
C:\xindice-1.1b4\bin>

I do not understand the cause of the "...is not bound." error above. Can
anyone enlighten me?

Thanks


Re: XPATH query roubles - attribute values

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Lavon_Lofton@pap.state.ga.us wrote:

>Vadim,
>
>Thank you for your quick reply. I reviewed the references and modified the
>query to include the -s for both name spaces.
>The result is essentially the same. With the -s the additional error
>"mismatched namespace prefixes and uris" is also generated.
>  
>

I've seen this error before, can't remember where...


>I can understand the original error in that the query is generating a
>xq:Query element and inserting into it the search attribute. I expect that
>the namespace declaration is not being added to the xq:Query element
>resulting in the error. Is there a way to log or trace the construction of
>the xq:Query element during the query?
>  
>

See xml-xindice\java\src\org\apache\xindice\core\query\QueryUtil.java


>Also, XPath queries return different results based upon the query string:
>the document, document element, xq:Query, or null.
>

Yes.


>My uneducated
>expectation would be that all querys would return a xq:Query wrapping the
>results, if any.
>  
>

That's not currently the case, API is different. See
    http://xml.apache.org/xindice/guide-xpath.html

Support for non-element results was added later, by adding xq:query 
wrapper around results. Document and element results behave same as 
before, without wrapper, for backward compatibility.

Vadim


Re: XPATH query roubles - attribute values

Posted by La...@pap.state.ga.us.
Vadim,

Thank you for your quick reply. I reviewed the references and modified the
query to include the -s for both name spaces.
The result is essentially the same. With the -s the additional error
"mismatched namespace prefixes and uris" is also generated.

I can understand the original error in that the query is generating a
xq:Query element and inserting into it the search attribute. I expect that
the namespace declaration is not being added to the xq:Query element
resulting in the error. Is there a way to log or trace the construction of
the xq:Query element during the query?

Also, XPath queries return different results based upon the query string:
the document, document element, xq:Query, or null. My uneducated
expectation would be that all querys would return a xq:Query wrapping the
results, if any.

Thanks again

Lavon Loftin


C:\xindice-1.1b4\bin>xindice xpath -c
xmldb:xindice://localhost:8080/db/ecoavs0.2
                                   -s
"xq=http://xml.apache.org/xindice/Query";"exec=http://mynamespace"
                                   -q "/exec:Exhibit[@exec:ownerRef='
_678919600101martian' and  @type='PARDON']/@exec:id"
trying to register database
ERROR : mismatched namespace prefixes and uris
[Fatal Error] :2:203: The prefix "exec" for attribute "exec:id" associated
with an element type "xq:result" is not bound.
org.xml.sax.SAXParseException: The prefix "exec" for attribute "exec:id"
associated with an element type "xq:result" is not bound.
        at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
        at
org.apache.xindice.client.xmldb.xmlrpc.CollectionImpl.query(CollectionImpl.java:518)
        at
org.apache.xindice.client.xmldb.XindiceCollection.query(XindiceCollection.java:259)
        at
org.apache.xindice.client.xmldb.services.QueryService.query(QueryService.java:90)
        at
org.apache.xindice.tools.command.XPathQuery.execute(XPathQuery.java:75)
        at org.apache.xindice.tools.XMLTools.execute(XMLTools.java:293)
        at org.apache.xindice.tools.XMLTools.process(XMLTools.java:171)
        at org.apache.xindice.tools.XMLTools.main(XMLTools.java:82)
ERROR : Query error: The prefix "exec" for attribute "exec:id" associated
with an element type "xq:result" is not bound.


Re: XPATH query roubles - attribute values

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Lavon_Lofton@pap.state.ga.us wrote:

>C:\xindice-1.1b4\bin>xindice xpath -c
>xmldb:xindice://localhost:8080/db/ecoavs0.2 -q "/exec:Exhibit
>[@exec:ownerRef='_678919600101mar
>tian' and  @type='PARDON']/@exec:id"
>trying to register database
>[Fatal Error] :2:203: The prefix "exec" for attribute "exec:id" associated
>with an element type "xq:result" is not bound.
>org.xml.sax.SAXParseException: The prefix "exec" for attribute "exec:id"
>associated with an element type "xq:result" is not bound.
>  
>

Read
    http://www.w3.org/TR/REC-xml-names/
    http://xml.apache.org/xindice/guide-tools.html#Xpath+Query+Actions


Vadim