Domanda

Is it possible to reset/remove the default namespace from a few elements in an XML document only?

<root xmlns="default.namespace" xmlns:no="">
<!-- defining a prefix no: with empty value does not work either -->
  <:config> <!-- the <config> element should be namespaceless -->
    <option /> <!-- option should have "default.namespace" -->
  </:config>

  <no:config>
    <option />
  </no:config>
</root>

And, I doubt this is possible, but can you define a default namespace to use for all child elements, but not for the element itself defining it?

<"":root xmlns="default.namespace"> <!-- root should not have a namespace -->
<child /> <!-- child nodes should have "default namespace" -->
<child />
</"":root>

The reason I'm asking this, is that elements from the default namespace are a lot more common than those without a namespace and I'd like to avoid repeatedly setting the default namespace on child nodes or prefixing every element from the namespace with its namespace prefix.

È stato utile?

Soluzione

No, sadly, it's not possible.

(Padding because SO doesn't like short answers)

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top