#1636 XDoc.write does not save namespaces

jessevdam Mon 5 Sep 2011

I put some namespaces into my xml document, which I generated dynamically using the xml pod. It stores the prefixes, but it does not save the xml namespace definitions.

rdfNs = XNs.make("rdf", `http://www.w3.org/1999/02/22-rdf-syntax-ns#`)
root := XElem("RDF",rdfNs)

doc := XDoc.make(root)
out := `test.rdf`.toFile.out
doc.write(out)  

This is the result I get

<?xml version='1.0' encoding='UTF-8'?>
<rdf:RDF/>

and this what I would expect

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">

brian Tue 6 Sep 2011

Currently the XNs doesn't implicitly create the attributes - that is modeled separately with an actual XAttr instance. Although might be nice to potentially have a convenience method that does both. See XAttr.makeNs constructor.

Login or Signup to reply.