[xml] seeking help with namespaces and SAX


I need to be able to tell if an element or attribute is in a specific
namespace using the SAX parser.  Is there any good sample code for a
state machine that would do this?

I was essentially thinking that I would keep an array of lists of valid
namespace prefixes (one entry in the array for each parent node).  I
would walk up the array looking for the current element/attributes'
prefix.  On startElement the index into the array would be incremented,
and an array constructed of new prefixes for my namespace.  The reverse
would happen on endElement.  

Hmm... this doesn't cover the redefine of a parent node's valid prefix
to another namespace... uggg... I guess I could keep an allow list and a
deny list for each node.  Anyways, every way I can think of seems gross
and makes way too many allocations.  

Someone must have dealt with this before, whats the best solution?


P.S. - I don't know the namespace spec well, maybe I am overengineering
for stuff that isn't even allowed...

 Think about it man!  Rock singers are only rockin you half the time... 
 the other time they're... they're breathing... in!  But not anymore 

                        -- Tenacious D

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]