문제

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.

도움이 되었습니까?

해결책

No, sadly, it's not possible.

(Padding because SO doesn't like short answers)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top