Home > Articles > Web Services > XML

  • Print
  • + Share This
This chapter is from the book

1.4 Attributes and namespaces

prefix:localname='value'
prefix:localname="value"

Attribute names are QNames. The namespace of an attribute with a given prefix is the namespace specified by the in-scope namespace declaration for that prefix. It is an error if no such namespace declaration is in scope. Unprefixed attributes are not in any namespace even if a default namespace declaration is in scope.

Examples

Qualified attributes

<Person xmlns='urn:example-org:People' 
    xmlns:b='urn:example-org:People:base' 
    xmlns:u='urn:example-org:units' >
 <name>Martin</name>
 <age b:base='10' u:units='years'
>33</age>
</Person>

An attribute with a local name of base in the namespace urn:example-org:People:base and an attribute with a local name of units in the namespace urn:example-org:units

Unqualified attributes

<Person xmlns='urn:example-org:People' >
 <name>Martin</name>
 <age base='10' units='years' >33</age>
</Person>

Attributes that are in no namespace, even though a default namespace declaration is in scope

  • + Share This
  • 🔖 Save To Your Account