[jdom-interest] Namespace declarations

Peter V. Gadjokov pvg at c-c-s.com
Wed Sep 13 17:31:32 PDT 2000


Could you describe what the two kinds of namespace declaration look like? It
sounds like (or I'm misunderstanding) there is some other way to declare a
namespace beyond: 

<somelement xmlns:foo="someURI" /> ?

Thanks,

-pvg


-----Original Message-----
From: Elliotte Rusty Harold [mailto:elharo at metalab.unc.edu]
Sent: Wednesday, September 13, 2000 1:34 PM
To: jdom-interest at jdom.org
Subject: [jdom-interest] Namespace declarations


I've been thinking about how to handle namespace declarations that 
don't map to any actual element or attribute in the document. These 
would customarily be prefixes used in attribute values or 
theoretically in element content.  I've only been able to develop two 
solutions to this problem, nether of which I like. Before I start 
writing code, I wanted to toss this out for further discussion.

Solution 1:

   Each element keeps track of namespace declarations (i.e. xmlns 
attributes) as well the namespace it actually uses. The builders 
would have to produce these form the input documents (not too hard) 
and we'd need to add an API for attaching new ones to elements. The 
XMLOutputter would need to change as well. We could still (and I'd 
argue should still) not require people to add namespace declarations 
to elements just to declare prefixes actually used on elements and 
attributes. Instead the XMLOutputter could deduce these. It would, 
however, check to make sure that it wasn't duplicating an existing 
xmlns declaration.

Thorniest issue with this approach: How do we handle conflicts 
between xmlns attributes and the prefixes actually used? More error 
checking and exception throwing is needed to prevent the possibility 
of using the same prefix or default namespace to refer to more than 
one URI within a single start tag. In fact we actually need this now, 
because it's possible for attributes and elements to define the same 
prefix in multiple ways within a start tag.

Solution 2:

   We allow attribute values to have a namespace URI attached to them. 
This would be optional. Most people wouldn't need to use this. The 
builders would still need to change to look for things that appeared 
to be prefixes in attribute values.  There's still a possibility of 
conflict between different prefixed names with the same prefix in a 
single start tag. Also I'm not sure it's at all intuitive.  Question: 
would there ever be more than one namespace prefix in a single 
attribute value?


I'd still like to come up with a solution that's cleaner than either 
of these. If anyone has any ideas I'd love to hear them.
-- 

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
|                  The XML Bible (IDG Books, 1999)                   |
|              http://metalab.unc.edu/xml/books/bible/               |
|   http://www.amazon.com/exec/obidos/ISBN=0764532367/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://metalab.unc.edu/javafaq/ |
|  Read Cafe con Leche for XML News: http://metalab.unc.edu/xml/     |
+----------------------------------+---------------------------------+
_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com



More information about the jdom-interest mailing list