ca.umontreal.iro.rali
Class Extract

java.lang.Object
  extended by ca.umontreal.iro.rali.Extract

public class Extract
extends java.lang.Object

Extract nodes from an XML document corresponding to an XPath expression using a Pull Parser

Author:
Guy Lapalme, Université de Montréal, 2009

Constructor Summary
Extract()
           
 
Method Summary
protected static long execute()
          Create a new XML document for each node matching the XPath expression given by the -xp parameter in order to save on memory each node is generated one by one as the input file is read
protected static org.w3c.dom.Node readFullNode(javax.xml.stream.XMLStreamReader xmlsr, org.w3c.dom.Document doc)
          read a Node (created with the doc) from pull parser reader read a complete element (including embedded elements if necessary)
protected static long setInputOutput()
          Set up and initialize the pull parser and output stream writer
protected static void skip(javax.xml.stream.XMLStreamReader xmlsr, int level)
          Skip the rest of an element, taking into account the possibility of embedded elements
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Extract

public Extract()
Method Detail

setInputOutput

protected static long setInputOutput()
Set up and initialize the pull parser and output stream writer

Returns:
the number of bytes in the input file

execute

protected static long execute()
Create a new XML document for each node matching the XPath expression given by the -xp parameter in order to save on memory each node is generated one by one as the input file is read


readFullNode

protected static org.w3c.dom.Node readFullNode(javax.xml.stream.XMLStreamReader xmlsr,
                                               org.w3c.dom.Document doc)
                                        throws javax.xml.stream.XMLStreamException
read a Node (created with the doc) from pull parser reader read a complete element (including embedded elements if necessary)

Parameters:
xmlsr - the pull-parser
doc - the document to create new nodes
Returns:
the Document node created by the pull-parser
Throws:
javax.xml.stream.XMLStreamException

skip

protected static void skip(javax.xml.stream.XMLStreamReader xmlsr,
                           int level)
                    throws javax.xml.stream.XMLStreamException
Skip the rest of an element, taking into account the possibility of embedded elements

Parameters:
xmlsr - pull-parser
level - indicates how many starting elements have been encountered without closing
Throws:
javax.xml.stream.XMLStreamException