[XML-SIG] xml-schema parsing using minidom.
Martin v. Loewis
martin@v.loewis.de
Mon, 3 Dec 2001 08:48:31 +0100
> But contents is different to version 1.6.
>
> class PullDOM(xml.sax.ContentHandler):
> def __init__(self):
> self.firstEvent = [None, None]
> self.lastEvent = self.firstEvent
> self._ns_contexts = [{}] # contains uri -> prefix dicts
> self._current_context = self._ns_contexts[-1]
It should then read
class PullDOM(xml.sax.ContentHandler):
def __init__(self):
from xml.dom import XML_NAMESPACE
self.firstEvent = [None, None]
self.lastEvent = self.firstEvent
self._ns_contexts = [{XML_NAMESPACE:'xml'}] # contains uri -> prefix dicts
self._current_context = self._ns_contexts[-1]
> 2) My aim of using PyExpat is not only parsing the schema file but
> also to print the variants enum value.
>
> It is not giving any parse error. But the function "getAvailableVariants()"
> is not working as we expect to print enums.
>
> It is not even printing available simpleTypes.
Since you are parsing in a namespace-aware mode, you also need to use
the namespace API. So replace
simpletypes = dom.getElementsByTagName("xsd:simpleType")
with
simpletypes = dom.getElementsByTagNameNS(XSD,"simpleType")
where
XSD="http://www.w3.org/2001/XMLSchema"
HTH,
Martin