ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rodney Waldhoff" <rw...@hotmail.com>
Subject Re: Reserved XML tags?
Date Thu, 01 Jan 1970 00:00:00 GMT
>Is it actually possible to define a DTD, without namespaces, that allows 
>the same element name to have two different contexts?

That depends what you mean by "context".  If is certainly possible within a 
DTD to define an element that can be used within the content model of two 
(or more) other elements.  It is not possible in a DTD to define an element 
that has a different content model (i.e., allows different child elements) 
depending upon its own parent.

You could accomplish something similiar to what you want by simply defining 
the content model to be the "union" of the content models for each 
"context", but this just degenerates into <!ELEMENT foo ANY>, which 
precludes meaningful validatoin.

If an element really has the same meaning (and therefore the same content 
model) where ever it is used, then reusing that element name in different 
contexts (where I'm taking "context" to mean parent element) is a good 
thing.  If it doesn't have the same meaning, it deserves a different name.

>How could namespaces help us here?

Forget about identifying XML elements by "name".  They are identified by 
namespace uri/name.  Hence if you declare two namespaces and use the same 
element name in both namespaces:

<example xmlns:ns1="http://example.com/one" 
xmlns:ns2="http://example.com/two">
<ns1:foo/>
<ns2:foo/>
</example>

then you're really talking about two different elements.  It doesn't really 
solve this problem, it just changes the syntax by which naming collisions 
are avoided.

In theory you could have a different namespace for each Ant task, and hence 
use the same element name with an entirely different, yet strictly 
validatable, content model, but that doesn't really buy us anything since 
you'd be declaring namespaces and prefixes everywhere.


A real Ant namespace would be useful, IMHO, even if only for bookkeeping 
purposes.  It would really help when you want to overlay another XML 
document with an Ant document--providing documentation, additional 
processing instructions, etc.
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com


Mime
View raw message