selectNodes with a NSResolver

Bernhard Gruber <[email protected]> Fri, 26 Jul 2002 11:28:46 +0200
Newsgroups gmane.comp.windows.devel.java.general
Message-ID <[email protected]>
--=====================_316736442==_.ALT
Content-Type: text/plain; charset="us-ascii"; format=flowed

hi

I was using the method : "selectNodes(java.lang.String pattern)"
for XMLDocs without Namespace Declarations, and it was working very fine,
but now I have a Namespace, and it does not work any more -->
guess I'll have to use

selectNodes(java.lang.String pattern, NSResolver nsr)

but how do I get the NSResolver ????

the task is to get all "xs:element" Nodes from this XML Schema :



<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
                    targetNamespace="http://anyurl.net"
                    xmlns="http://anyurl.net"
                    elementFormDefault="qualified">
<xs:element name="ComponentDB">
         <xs:complexType>
             <xs:all>
                 <xs:element name="Id" type="xs:integer" minOccurs="1"
maxOccurs="1"/>
                 <xs:element name="Name" type="xs:string" minOccurs="0"
maxOccurs="1"/>
                 <xs:element name="NeedsKW" type="xs:string" minOccurs="0"
maxOccurs="1"/>
                 <xs:element name="ONDObjectList" minOccurs="1"
maxOccurs="1">
                         <xs:complexType>
                                 <xs:sequence>
                                         <xs:element name="ONDObject"
type="xs:string" minOccurs="1" maxOccurs="unbounded"/>
                                 </xs:sequence>
                         </xs:complexType>
                     </xs:element>
                 <xs:element name="KeywordList" minOccurs="1"
maxOccurs="1">
                         <xs:complexType>
                                 <xs:sequence>
                                         <xs:element name="Keyword"
type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
                                 </xs:sequence>
                         </xs:complexType>
                     </xs:element>
             </xs:all>
     </xs:complexType>
</xs:element>


You can read messages from the JAVA archive, unsubscribe from JAVA,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.

--=====================_316736442==_.ALT
Content-Type: text/html; charset="us-ascii"

<html>
hi<br><br>
I was using the method :
&quot;<font face="Courier New, Courier" color="#0000FF"><b><u>selectNodes</u></b></font><font face="Courier New, Courier">(java.lang.String
pattern)</font>&quot; <br>
for XMLDocs without Namespace Declarations, and it was working very fine,
but now I have a Namespace, and it does not work any more --&gt;<br>
guess I'll have to use <br><br>
<font face="Courier New, Courier" color="#0000FF"><b><u>selectNodes</u></b></font><font face="Courier New, Courier">(java.lang.String
pattern,
</font><font face="Courier New, Courier" color="#0000FF"><u>NSResolver</u></font><font face="Courier New, Courier">
nsr) <br><br>
</font>but how do I get the NSResolver ????<br><br>
the task is to get all &quot;xs:element&quot; Nodes from this XML Schema
:<br><br>
<br><br>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>
&lt;xs:schema
xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;<x-tab>&nbsp;&nbsp;</x-tab><br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;&nbsp;
targetNamespace=&quot;<a href="http://anyurl.net/" eudora="autourl">http://anyurl.net</a>&quot;<x-tab>&nbsp;&nbsp;</x-tab><br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;&nbsp;
xmlns=&quot;<a href="http://anyurl.net/" eudora="autourl">http://anyurl.net</a>&quot;&nbsp;&nbsp;
<x-tab>&nbsp;</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;&nbsp;
<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;&nbsp;
elementFormDefault=&quot;qualified&quot;&gt;<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;&nbsp;
<br>
&lt;xs:element name=&quot;ComponentDB&quot;&gt; <br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&lt;xs:complexType&gt;
<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;&nbsp;&nbsp;
&lt;xs:all&gt;<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;&nbsp;&nbsp;
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&lt;xs:element name=&quot;Id&quot;
type=&quot;xs:integer&quot; minOccurs=&quot;1&quot;
maxOccurs=&quot;1&quot;/&gt;<x-tab>&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;
<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;&nbsp;&nbsp;
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&lt;xs:element
name=&quot;Name&quot; type=&quot;xs:string&quot; minOccurs=&quot;0&quot;
maxOccurs=&quot;1&quot;/&gt;<x-tab>&nbsp;&nbsp;</x-tab>&nbsp; <br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;&nbsp;&nbsp;
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&lt;xs:element
name=&quot;NeedsKW&quot; type=&quot;xs:string&quot;
minOccurs=&quot;0&quot;
maxOccurs=&quot;1&quot;/&gt;<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;
<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;&nbsp;&nbsp;
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&lt;xs:element
name=&quot;ONDObjectList&quot; minOccurs=&quot;1&quot;
maxOccurs=&quot;1&quot;&gt;<x-tab>&nbsp;&nbsp;&nbsp;</x-tab>&nbsp; <br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;&nbsp;&nbsp;
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&lt;xs:complexType&gt;<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;&nbsp;&nbsp;
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&lt;xs:sequence&gt;<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;&nbsp;&nbsp;
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&lt;xs:element name=&quot;ONDObject&quot; type=&quot;xs:string&quot; minOccurs=&quot;1&quot; maxOccurs=&quot;unbounded&quot;/&gt;<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp; <br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;&nbsp;&nbsp; <x-tab>&nbsp;&nbsp;&nbsp;&nbsp;</x-tab> <x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&lt;/xs:sequence&gt;<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;&nbsp;&nbsp; <x-tab>&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&lt;/xs:complexType&gt;<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;&nbsp;&nbsp; &lt;/xs:element&gt;<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;&nbsp;&nbsp; <x-tab>&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;&nbsp;&nbsp; <x-tab>&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&lt;xs:element name=&quot;KeywordList&quot; minOccurs=&quot;1&quot; maxOccurs=&quot;1&quot;&gt;<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp; <br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;&nbsp;&nbsp; <x-tab>&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&lt;xs:complexType&gt;<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;&nbsp;&nbsp; <x-tab>&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&lt;xs:sequence&gt;<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;&nbsp;&nbsp; <x-tab>&nbsp;&nbsp;&nbsp;&nbsp;</x-tab> <x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&lt;xs:element name=&quot;Keyword&quot; type=&quot;xs:string&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;unbounded&quot;/&gt;<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp; <br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;&nbsp;&nbsp; <x-tab>&nbsp;&nbsp;&nbsp;&nbsp;</x-tab> <x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&lt;/xs:sequence&gt;<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;&nbsp;&nbsp; <x-tab>&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&lt;/xs:complexType&gt;<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;&nbsp;&nbsp; &lt;/xs:element&gt;<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;&nbsp;&nbsp; <x-tab>&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>&nbsp;&nbsp;&nbsp; &lt;/xs:all&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;/xs:complexType&gt;<br>
&lt;/xs:element&gt;<br>
<br>
</html>
You can read messages from the JAVA archive, unsubscribe from JAVA,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.

--=====================_316736442==_.ALT--