Best Practices
-
Change prefixes as rarely as possible
Although Namespaces in XML makes it clear that prefixes are just placeholders, using prefixes consistently can both enhance the readability of your documents and make it easier for processors without namespace support to deal with your documents - including XML 1.0 validating parsers.
-
Choose URIs carefully
Relative URIs were one problematic choice among the URI possibilities, but there are others. Many XML gurus argue that developers should use URNs rather than URLs for namespace identifiers, since they have fewer connotations. Always make sure your organization controls the URIs you use as namespace identifiers.
-
Identify the default namespace even if you aren't using namespaces
Even die-hard namespace haters would probably do well to provide namespace identifiers in their root elements. Documents have a way of moving beyond their original maintainers, and having a namespace makes document management easier.
-
Make no assumptions about URI resolution
Don't build processors which expect to resolve namespace URIs. You may not always find something there, if you can even retrieve the resource.
-
Include all namespace declarations directly in the document
Never rely on a DTD or a Schema to supply a defaulted attribute. This processing is not always available.
Previous Page <
TOC
> Next Page