[XML-SIG] replace ENTITY_NODE ?
Jürgen Schmidt
scjuonline@web.de
Wed, 2 Oct 2002 10:57:06 +0200
>Starting with PyXML 0.8, there is a new DOM builder that doesn't go
>through SAX accessible using minidom's DOM 3 Load support (spec still
>in draft). You can use it like this:
>
> dom = xml.dom.minidom.getDOMImplementation()
> builder = dom.createDOMBuilder(dom.MODE_SYNCHRONOUS, None)
> # use setFeature() & friends as needed
> doc = builder.parseURI(...)
>
>Note that the ENTITY nodes are created, but they are not filled in,
>and entities are not parsed. This will be improved in the future.
>
>Now, I'm not at all sure how to deal with ENTITY nodes when namespaces
>are being processed, since there is no meaningful namespace context in
>the raw entities at that point. ;-(
This code:
def show(node):
print node
for n in node.childNodes:
show(n)
dom = minidom.getDOMImplementation()
builder = dom.createDOMBuilder(dom.MODE_SYNCHRONOUS,None)
doc = builder.parseURI("file:///.../doc.xml")
show(doc)
on:
#####################################
# doc.xml
#####################################
<?xml version="1.0" encoding="latin-1"?>
<!DOCTYPE doc SYSTEM "doc.dtd"
[
<!ENTITY foo SYSTEM "foo.xml">
<!ENTITY bar SYSTEM "bar.xml">
]>
<doc>
&foo;
&bar;
</doc>
#####################################
gives:
<xml.dom.minidom.Document instance at 0x82aab9c>
<xml.dom.minidom.DocumentType instance at 0x82a21f4>
<DOM Element: doc at 137014212>
<DOM Text node "
">
How do I access the ENTITY Nodes?
How could I save this DOM document as XML again?
thx Juergen