[XML-SIG] binding an unbound namespace prefix

Walter Dörwald walter at livinglogic.de
Tue Dec 23 04:18:43 EST 2003


Keith Beattie wrote:

> Hi all,
> 
> I'm trying to parse a string which is a segment of xml (in order to 
> canonicalize it) which doesn't have all it's namespaces bound in the 
> segment I'm trying to parse.  How do I pass the namespaces into 
> minidom.parseString(), or 
> Domlette.NonvalidatingReader.parseString(),such that they'll be happy 
> with the 'unbound prefix'?  I hoped to see an nsdict kw arg or some 
> such, but no luck.  Is building the dom myself the only way to do this?

You could try XIST (http://www.livinglogic.de/Python/xist/), which
supports passing a prefix mapping to the parser:

from ll.xist import xsc, parsers
from ll.xist.ns import html, svg, fo

e = parsers.parseString(
    "<h:html><s:svg><block/></s:svg></h:html>",
    prefixes=xsc.Prefixes(fo, s=svg, h=html)
)

Unfortunately this doesn't return a standard DOM, but of course
you could convert it into one.

Bye,
    Walter Dörwald




More information about the XML-SIG mailing list