Interview Questions

If an element or attribute is in the scope of an XML namespace declaration, is its name in that namespace?

XML Interview Questions and Answers


(Continued from previous question...)

80. If an element or attribute is in the scope of an XML namespace declaration, is its name in that namespace?

Not necessarily.
When an element or attribute is in the scope of an XML namespace declaration, the element or attribute's name is checked to see if it has a prefix that matches the prefix in the declaration. Whether the name is actually in the XML namespace depends on whether the prefix matches. For example, in the following, the element type names A, B, and D and the attribute names C and E are in the scope of the declaration of the http://www.google.org/ namespace. While the names A, B, and C are in that namespace, the names D and E are not.

<google:A xmlns:google="http://www.google.org/">
<google:B google:C="google" />
<bar:D bar:E="bar" />
</google:A>

(Continued on next question...)

Other Interview Questions