You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Celinio Fernandes <cf...@pagesjaunes.fr> on 2005/08/10 19:58:27 UTC
Using XQuery with XMLbeans
Hi again,
I am new to XQuery and I am trying to select a value in my XML file
which looks a bit like this:
<?xml version="1.0" encoding="UTF-8"?>
<MPG-PVC xmlns:xsi=" <http://www.w3.org/2001/XMLSchema-instance>
http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="mpgpvc.xsd">
<DATE_ENVOI>07/08/2005 09:07:01</DATE_ENVOI>
<NB_EPJ>92</NB_EPJ>
<EPJ>
<IOS>
<IO>
<LO_ID_EPJ>751</LO_ID_EPJ>
<LO_ID_INSCRIPTION>5454</LO_ID_INSCRIPTION>
<LO_DA_CREATION>10/05/2005 10:07:14</LO_DA_CREATION>
</IO>
<IOS>
<EPJ>
</MPG-PVC>
How do you get the value of LO_ID_EPJ ?
I tried this: (inputXMLFile is my XML file of course)
MPGPVCDocument mpgpvcdoc = MPGPVCDocument.Factory.parse(inputXMLFile);
String nsText = "declare namespace
xq='http://www.w3.org/2001/XMLSchema';";
String pathText = "$this/xq:MPG-PVC/xq:EPJ/xq:IOS/xq:IO/xq:LO_ID_EPJ";
String queryText = nsText + pathText;
XmlCursor itemCursor = mpgpvcdoc.newCursor().execQuery(queryText);
System.out.println(itemCursor.xmlText());
Result is :
<xml-fragment/>
instead of 751
Something wrong with my use of the XML elements ?
Thanks in advance for your help.
XPath/XQuery on SchemaType
Posted by Roshan Punnoose <pu...@bah.com>.
Is it possible to run xpath/xquery on the schemaType? I know that it is
possible to load the .xsd as an XmlObject and then run the execQuery
function. But can you run a query against the SchemaType?
Roshan Punnoose
Phone: 301-497-6039