[XML-SIG] xml-schema parsing using minidom.

Mariappan, MaharajanX m_mariappanX@trillium.com
Sun, 2 Dec 2001 23:14:18 -0800


Hi Martin,

1) Thanks for your timely valid response. I've a quick question on applying 
the patch you have provided. I'm using win200. So tried to change two lines
in ...Lib/xml/dom/pulldom.py 

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]

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.


TIA,
Maharajan


-----Original Message-----
From: Martin v. Loewis [mailto:martin@v.loewis.de]
Sent: Monday, December 03, 2001 12:20 PM
To: m_mariappanX@trillium.com
Cc: m_mariappanX@trillium.com; xml-sig@python.org
Subject: Re: [XML-SIG] xml-schema parsing using minidom.


> I've attached the full xml and xsd file.

Thanks, it turns out this is a bug in pulldom. Please apply the patch
below.

> Can you provide feedback on my second approach using pyExpat module

You said "but no valid response." Can you please qualify?

One problem here is that FromUri expects an URI. You are passing
"c:\\Project\\build.xsd", which, if it was an URI, would use the "c"
scheme, which is not defined. However, as a work-around, FromUri will
open that resource if it is a local file.

If I change the file name so that it works on my Unix system, the
PyExpat.Reader will parse the document just fine; I can see no
problems.

Regards,
Martin

Index: pulldom.py
===================================================================
RCS file: /cvsroot/pyxml/xml/xml/dom/pulldom.py,v
retrieving revision 1.17
diff -u -r1.17 pulldom.py
--- pulldom.py	2001/11/21 09:57:35	1.17
+++ pulldom.py	2001/12/03 06:39:18
@@ -21,6 +21,7 @@
     document = None
 
     def __init__(self, documentFactory=None):
+        from xml.dom import XML_NAMESPACE
         self.documentFactory = documentFactory
         self.firstEvent = [None, None]
         self.lastEvent = self.firstEvent
@@ -31,7 +32,7 @@
         except AttributeError:
             # use class' pop instead
             pass
-        self._ns_contexts = [{}] # contains uri -> prefix dicts
+        self._ns_contexts = [{XML_NAMESPACE:'xml'}] # contains uri ->
prefix dicts
         self._current_context = self._ns_contexts[-1]
         self.pending_events = []