Skip to content
Prev 309265 / 398506 Next

XML namespace control

Hi Ben

  Can you tell us the slightly bigger picture, please?
Do you want to create a single similar node entirely in isolation
or do you want to create it as part of an XML tree/document?
Who will be reading the resulting XML.

You can use a parent node

  top = newXMLNode("storms", namespaceDefinitions = c(weather = "http://my.weather.com/events"))

Then

    newXMLNode("storm", "ripsnorter", namespace = "weather",
                attrs = c(type = "hurrican", name = "Sandy"),
               parent = top )


That gives you

   <weather:storm type="hurrican" name="Sandy">ripsnorter</weather:storm>

So now what are you going to do with that node?

The namespace prefix is local to a document, chosen by the author of that XML document.
The namespace URI is the global key that authors and consumers must agree upon.
While your database may use "udf", you may chose a different prefix or even the default
prefix to correspond to that same URI.  So each document must explicitly declare the
prefix = URI mapping for it to be understood.

    D.
On 10/29/12 5:54 AM, Ben Tupper wrote: