Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


SAX parse and ISAXContentHandlerImpl Members

From: RCGray@-----------.---------.---
To: NULL
Date: 9/2/2005 9:07:00 AM
I have an application which takes an XML document and uses a SAX reader to 
parse the document.  The xml document could have several "empty elements" 
like <Value /> or <Value></Value>.

I am currently using the startElement, characters, and endElement methods to 
help me determine what to do with the data.  My question is, how can I 
differentiate between an empty element and an starting element in a 
"structure".

<something>
    <somethingelse>data</somethingelse>
    <anemptyelement />
</something>

I am building a vector list of those data elements through the parser and 
these methods.  When endElement is called I push the data to the vector if 
the data is not an empty string.  In the example above <something> does not 
have any "data" and the string is empty so I bypass pushing the data to the 
vector.  The same problem occurs with <anemptyelement /> although I want to 
know in the main application that <anemptyelement> was simply blank this time.

Is there a method that would easily distinguish between an empty element and 
the other element?

Should I just keep track of the "levels" that I am in?  Devise a hack where 
<something> would be level 0 and <somethingelse> and <anemptyelement> would 
be in level 1.  I could add this concept of levels to startElement.  I am 
hoping for something more elegant.

Thanks for your time...


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent