Article

XML Namespaces Explained

Page: 1 2 3

Attributes and Namespace

For any specific element, an attribute may only exist once. This makes attributes slightly different to elements.

Attributes may be placed in a specific namespace (<.... myns:myattib="foo" ...>) or they may be left unqualified.

The normal "rule" for attributes is to place them within a namespace only if the attribute in question is defined by a particular namespace (such as xlink or rdf attributes).

Attributes that have no namespace prefix are not defined by a namespace. Note that this is not the same as being in the default namespace.

Placing attributes in namespaces only becomes important if you require your document to conform to a DTD or Schema that defines the attribute as being qualified.

What do I Put at the End of a Namespace URI?

Nothing!

Ok, so this isn't really helpful. The problem here is that humans see a URL, so they want to point their Web browser at it to see what they get. This is a purely human thing, and is a consequence of the decision to standardise URIs for namespaces.

To quote Claude L. Bullard (from the XML-Dev email list):

The flaw is the conflation of name, location and identity, but that flaw is the basic feature by which the WWW runs, so we are stuck there. All the handwaving about URN/URI/URL doesn't avoid the simple fact that if one puts http:// anywhere in browser display space, the system colors it blue and puts up a finger. The monkey expects a resource and when it doesn't get one, this shocks the monkey. Monkeys don't read specs to find out why they shouldn't be shocked. They turn red and put up a finger.

What many people do to avoid this "shock" factor is post a document that describes the namespace to the errant viewer. A new idea that builds on this approach, and is now emerging from XML-dev, is RDDL (the Resource Directory Description Language).

Further Reading

Main XML portals

Portals that have information on XML

If you liked this article, share the love:
Print-Friendly Version Suggest an Article

Sponsored Links

Rate This Article

  • 1
    Poor
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
    Great

Post A Comment

You need to be a member of the SitePoint Forums to comment on this post. Sign Up

Already a member? Post using your SitePoint Forums account: