Note that there are some explanatory texts on larger screens.

plurals
  1. POparsing .xsd in python
    text
    copied!<p>I need to parse a file .xsd in Python as i would parse an XML.<br/> I am using libxml2.<br/> I have to parse an xsd that look as follow: <br></p> <pre><code>&lt;xs:complexType name="ClassType"&gt; &lt;xs:sequence&gt; &lt;xs:element name="IeplcHeader"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name="device-number" type="xs:integer" fixed="1"/&gt; &lt;/xs:sequence&gt; &lt;xs:attribute name="version" type="xs:integer" use="required" fixed="0"/&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; </code></pre> <p>when i access with</p> <pre><code>doc.xpathEval('//xs:complexType/xs:sequence/xs:element[@name="IeplcHeader"]'): </code></pre> <p>tells me that cannot find the path.</p> <p>while if i remove all the xs: as follow </p> <pre><code>&lt;complexType name="ClassType"&gt; &lt;sequence&gt; &lt;element name="IeplcHeader"&gt; &lt;complexType&gt; &lt;sequence&gt; &lt;element name="device-number" type="xs:integer" fixed="1"/&gt; &lt;/sequence&gt; &lt;attribute name="version" type="xs:integer" use="required" fixed="0"/&gt; &lt;/complexType&gt; &lt;/element&gt; </code></pre> <p>in this way it works </p> <pre><code>doc.xpathEval('//complexType/sequence/element[@name="IeplcHeader"]'): </code></pre> <p>Does anyone knows how can i get read of this problem fixing a prefix? righ now i am preparsing the file removing the xs: but it's an orrible solution and i really hope to be able to find a better solution.</p> <p>(I did not try with py-dom-xpath yet and i do not know if may work even with the xs:)</p> <p>thanks, ste</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload