W3C home > Mailing lists > Public > www-dom@w3.org > October to December 1998

Re: DOM Level 1 and namespaces

From: David Brownell <db@Eng.Sun.COM>
Date: Thu, 17 Dec 1998 20:55:07 -0500 (EST)
Message-ID: <3679B4B6.5633EE39@eng.sun.com>
To: "Andrew M. Kuchling" <akuchlin@cnri.reston.va.us>
CC: www-dom@w3.org
"Andrew M. Kuchling" wrote:
> 
>	  Namespaces don't
> really seem like something for Level 2 or higher, but are fundamental
> enough that they should be added to Level 1.

In spirit I agree that namespace support should come earlier than
a Level 2 spec will probably arrive, but then the XML Namespaces
"Proposed Recommendation" only finished its comment period today.


> Has anyone thought about what namespace support would look like?

Sun's XML package (http://java.sun.com/jdc/earlyAccess/xml) has
some such support.  I won't say it's everything that you might ever
want, but it's proven useful enough to implement a number of rather
namespace-aware XML based services.

There is an interface that lets you get at the basic annotations
for each Node.  Both Element and Attribute implementations support
this interface.  (I'm not keen on the interface name; suggestions?)

	interface NamespaceScoped extends Node {

		// Node.getNodeName() might return "prefix:foo"

		// returns the unscoped name:  "foo"
		String getLocalName ();

		// returns any namespace URI (e.g. for "prefix")
		String getNamespace ();
	}

There's an extended "Document" with a new element factory method
that take the namespace URI; for example, if the element is in the
XSL namespace you might want to have your elements implement some
methods that make it easy to apply stylesheet templates, etc.

There's an extended "Element" with accessors for Attributes that
take the namespace URI.  The extended "Node" method to access the
value of an "inherited" attribute likewise provide a way to access
them taking the namespace URI ... regardless, of course, of the
particular prefix that was used.


That's about all I remember off the top of my head.  There are
no primitives to answer questions like "what namespaces are
in scope at this node?" or manage prefixes.  If you want to filter
out nodes in a namespace-aware way (e.g. with TreeWalker) you have
to write the few lines of code yourself.  But if you're given a
document that uses namespaces, you can work with them.

That package is "early Access" meaning subject to change, etc.
Feel free to grab a copy (JDC registration required; it's free)
and send along any feedback.

- Dave
Received on Friday, 18 December 1998 04:06:33 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:46 GMT