[XOM-interest] Using attributes from element before parsing content (via NodeFactory)

Peter Stibrany pstibrany at gmail.com
Sat Jan 17 10:50:34 EST 2009


Hello,

I am using node factory to get information from XML Document while it
is still being parsed. I need to process attributes from element
before entire element content is read. E.g. if I have

<root>
  <element attr1='value' attr2='value'>
    ... some really big content here ...
  </element>
</root>

I want to process 'element' as soon as start tag was fully read (incl.
attributes), but before any content of 'element' is read.

What I currently do is that I set flag 'processAttributes' in
startMakingElement for 'element' (and store element too), and I check
this flag in subsequent calls to startMakingElement and
finishMakingElement (just in case my 'element' had no content). This
works because I know that my 'element' has only other elements as
children nodes. If I didn't know this, I would need to also do same
check in makeText, makeComment and other methods.

Is there better way than this?

Thank you,
-Peter Stibrany


More information about the XOM-interest mailing list