Skip to Content.
Sympa Menu

xom-interest - [XOM-interest] NodeFactory and additional namespace declarations

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
  • To: xom-interest AT lists.ibiblio.org
  • Subject: [XOM-interest] NodeFactory and additional namespace declarations
  • Date: Mon, 10 Nov 2003 20:26:24 -0500

I've had an open action item for a while to consider whether additional namespace declarations should be reported to the NodeFactory so they can be filtered. Doing this would be really messy because XOM doesn't have any namespace class. What I came up with looked something like this:

public void makeNamespaceDeclaration(Element parent, String uri, String
prefix)

This method would have to add the relevant namespace declaration to the passed Element. I also considered reworking the makeAttribute method to behave similarly.

However, today I think I finally convinced myself this was a bad idea for several reasons:

1. It's ugly as hell, and doesn't follow the Factory design pattern, or the general pattern of NodeFactory.

2. If you do need to muck with the additional namespace declarations, you can do it in endElement.

3. This is the kicker: I don't think depending on additional namespace declarations makes sense within XOM. They're tracked, and you can use them, but that's mostly for serialization. The right way to determine which namespace is in scope is by asking an element. Namespaces themselves don't really have any existence independent of the elements. Thus you shouldn't be filtering with respect to additional namespaces. (Filtering by element namespaces is perfectly OK, and supported now.) Furthermore, in practice additional namespaces often appear at the particular points they do simply to avoid having to be redeclared on several child elements in the same namespace. Their location has little if any meaning to the document itself. If you really want to adjust the additional namespaces, you can do it in endElement() anyway. They're just won't be a special callback for it.

Anyway, that's my thinking on this. It's a little blurred but I think I'm happy with it. However, if anyone wants to disagree or has a streaming use case that really needs to see additional namespace declaration in their own method, now is the time to speak up.


--

Elliotte Rusty Harold
elharo AT metalab.unc.edu
Effective XML (Addison-Wesley, 2003)
http://www.cafeconleche.org/books/effectivexml
http://www.amazon.com/exec/obidos/ISBN%3D0321150406/ref%3Dnosim/cafeaulaitA



  • [XOM-interest] NodeFactory and additional namespace declarations, Elliotte Rusty Harold, 11/10/2003

Archive powered by MHonArc 2.6.24.

Top of Page