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:[EMAIL PROTECTED]
Homepage        www.bison-group.com



> -----Urspr�ngliche Nachricht-----
> Von: Stadelmann Adi 
> Gesendet: Donnerstag, 6. Dezember 2001 09:58
> An: [EMAIL PROTECTED]
> 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Adrian Stadelmann
Software Development

---------------------------------------------------
BISON Schweiz AG
Eichweid 5
CH-6203 Sempach-Station

Phone direct    +41 41 469 65 03
E-Mail  mailto:[EMAIL PROTECTED]
Homepage        www.bison-group.com



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to