You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Stadelmann Adi <Ad...@bison-group.com> on 2001/12/10 15:21:15 UTC
parsing of big xml. my way of solution
hi,
has anybody a solution for parsing big xml sources?
my solution was a event-driven dom parsing. while
parsing, i can access the already builded dom-tree and
remove no more needed elements. this solves memory.
with xerces 2.0. i am looking for a proper solution.
who can help me?
see below for detailed analysis.
Adrian Stadelmann
Software Development
---------------------------------------------------
BISON Schweiz AG
Eichweid 5
CH-6203 Sempach-Station
Phone direct +41 41 469 65 03
E-Mail mailto:adrian.stadelmann@bison-group.com
Homepage www.bison-group.com
> -----Ursprüngliche Nachricht-----
> Von: Stadelmann Adi
> Gesendet: Donnerstag, 6. Dezember 2001 09:58
> An: xerces-j-user@xml.apache.org
> Betreff: event of endElement while dom parsing
>
>
> hi
> i try to get events (endElement) while dom parsing for saving
> memory and
> performance.
> org.w3c.dom.events sends only events about an insert of a element, not
> the end of parsing
> could xni be my solution?
> a simple (but dirty) solution was with xerces1:
>
> public interface DOMHandler {
> /**
> * Handles the current parsed Element
> * For save the memory, you should returning true after handled a
> element.
> * This will remove the element in the document-tree
> *
> * @param element the current element
> * @return true if element handled. It will be removed automaticly
> form the DOMStreamParser
> * @exception IEException
> * if an error happen while handle
> */
> public boolean handleElementNode(Element elementNode) throws
> IEException;
> }
>
> and following subclass of DOMParser
>
> public class DOMStreamParser extends DOMParser {
> private DOMHandler _DOMHandler=null;
>
> public DOMStreamParser() {
> try{
> setDeferNodeExpansion(false);
> } catch (Exception e) {
> System.out.println("Error while setting freature off:"+e);
> }
> }
>
> /**
> * Sets a new DOMHandler
> */
> public void setDOMHandler(DOMHandler handler) {
> _DOMHandler=handler;
> }
>
> /**
> * Gets the DOMHandler
> */
> public DOMHandler getDOMHandler() {
> return _DOMHandler;
> }
>
> /**
> * Triggering of endElement and send Event to DOMHandler
> */
> public void endElement(int elementTypeIndex) throws Exception {
> DOMHandler handler=getDOMHandler();
> //First get current Node, because the super.endElement will change
> it
> Element elementNode=getCurrentElementNode();
>
> //call the official endElement
> super.endElement(elementTypeIndex);
>
> //Send notification to DOMHandler
> if (handler!=null && elementNode!=null) {
> boolean
> removeNode=getDOMHandler().handleElementNode(elementNode);
> if (removeNode) ...
> }
> }
> }
>
> cu.
> Adrian Stadelmann
> Software Development
> ---------------------------------------------------
> BISON Schweiz AG
> Eichweid 5
> CH-6203 Sempach-Station
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org