XML attribute names and elements in default namespace?

akannulshook

New Member
How should the following in XML namespace specification be interpreted?\[quote\] A default namespace declaration applies to all unprefixed element names within its scope. Default namespace declarations do not apply directly to attribute names; the interpretation of unprefixed attributes is determined by the element on which they appear.\[/quote\]My intuitive understanding is that unprefixed attributes should be interpreted as belonging to the namespace of the element they belong to. However, the following example seems to prove this false:Schema:\[code\]<xs:schema xmlns:myns="http://test.com/xsd/foo" elementFormDefault="qualified" targetNamespace="http://test.com/xsd/foo" version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:attribute name="Id" type="xs:string" /> <xs:element name="Foo"> <xs:complexType> <xs:attribute ref="myns:Id" /> </xs:complexType> </xs:element></xs:schema>\[/code\]Example that passes validation:\[code\]<a:Foo xmlns:a="http://test.com/xsd/foo" a:Id="123" />\[/code\]Example that fails validation:\[code\]<Foo xmlns="http://test.com/xsd/foo" Id="123" />\[/code\]What gives?
 
Back
Top