You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Stadelmann Adi <Ad...@bison-group.com> on 2001/12/18 15:49:50 UTC

missing interface for dom parsing events

hi,
while parsing xml into a dom tree, i need a event
after each endElement. then i can call my functions with
the already parsed dom-tree and decide while parsing for removing from the
document. this is a solution for parsing big xml sources, 
and still can use the dom-tree parser instead of
a ugly sax-parser. 
xni XMLDocumentHandler with "endElement(Element element);"
could be the solution, what you mean?

Adrian Stadelmann
Software Development

ps: below was my old solution....

---------------------------------------------------
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


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



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Re: missing interface for dom parsing events

Posted by Andy Clark <an...@apache.org>.
Stadelmann Adi wrote:
> xni XMLDocumentHandler with "endElement(Element element);"
> could be the solution, what you mean?

We're not going to put anything in the XNI interfaces that
adds a direct dependency to other APIs. Therefore, we would
not add SAX or DOM dependencies to XNI.

-- 
Andy Clark * andyc@apache.org
----------------------------------------------------
Sign Up for NetZero Platinum Today
Only $9.95 per month!
http://my.netzero.net/s/signup?r=platinum&refcd=PT97

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org