[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: SAX Filters for Namespace Processing
- From: "Simon St.Laurent" <simonstl@simonstl.com>
- To: xml-dev@lists.xml.org
- Date: Wed, 01 Aug 2001 13:05:06 -0400
On 01 Aug 2001 09:50:13 -0700, Jeff Rafter wrote:
> Assuming you have encountered the above example, what was it that you
> couldn't do because of the unqualified nature?
For starters, I can't easily write processing in SAX that sends all
content of a given (namespace-identified) vocabulary to appropriate
processing. I have to start maintaining context explicitly in my code.
(That happens within the filters of course, but at least it's isolated
from other processing.)
> Obviously there is a touchy
> issue with unqualified elements being designed within a schema that
> represents a namespace, while they are not, themselves, within that
> namespace. This can make it difficult to process them, I suppose, but what
> is the exact difficulty?
The SAX-routing example is one part, but it has other ramifications.
Moving pieces of documents from place to place becomes pretty tricky
when there are unqualified elements. Context can disappear, and they
unqualified parts may also pick up a namespace declaration from
elsewhere in the destination tree if the processing isn't careful.
(Aaron's talk did recommend the use of xmlns="" on explicitly
unqualified content to ensure it stayed that way, if I remember
correctly.)
> >From a purely naive point of view (mine) I see XML as completely heirarchal;
> where context is king. Processing elements rarely occurs outside of knowing
> context (be it only the context of a specific document), so it would seem
> that needing the context in the case of unqualified elements is perfectly
> natural.
If you have the context - you're working in DOM, XPath, or some
variation - it's something you can deal with. If you're in a streaming
environment, or move content between contexts, it gets ugly rapidly.
> My second question revolves around the default namespace issue (which is
> where this all got really contentios last time). I am wondering if you make
> any special choices, or plan to regarding default namespaces:
>
> <root xmlns="http://simonstl.com/default">
> <p:person xmlns:p="http://simonstl.com/person">
> <givenName>Chip</givenName>
> <familyName>Skillet</familyName>
> <address>
> <city>Ithaca</city>
> </address>
> </p:person>
> </root>
>
> or
>
> <root xmlns="http://simonstl.com/default">
> <p:person xmlns:p="http://simonstl.com/person">
> <givenName>Chip</givenName>
> <familyName>Skillet</familyName>
> <address xmlns="">
> <city>Ithaca</city>
> </address>
> </p:person>
> </root>
>
> I am not looking to say what would be right or wrong-- I am just wondering
> how or if your filter handles these?
The filter checks the namespace URI, not the prefix. So if something is
in the default namespace and has a URI, the filter leaves it alone. If
something is unqualified, then processing starts, determined by rules
that work from the context. (The context is maintained as a stack to
ensure to that hierarchy and not mere sequence sets the appropriate
context.)
Simon St.Laurent