com.northconcepts.datapipeline.xml
Class XmlReader

java.lang.Object
  extended by com.northconcepts.datapipeline.core.DataEndpoint
      extended by com.northconcepts.datapipeline.core.DataReader
          extended by com.northconcepts.datapipeline.xml.XmlReader

public class XmlReader
extends DataReader

Obtains records from an XML stream. See the Read an XML file example.

XmlReader's addField(String, String), addField(String, String, boolean), and addRecordBreak(String) methods use a subset of the XPath 1.0 location paths notation to identify field values and demarcate records.

Axis Specifiers

Axis Abbreviated Syntax Supported Examples
ancestor      
ancestor-or-self      
attribute @ yes @lang or attribute::lang
child   yes title or child::title
descendant   yes  
descendant-or-self // yes //book or /descendant-or-self::book/
following      
following-sibling      
namespace      
parent ..    
preceding      
preceding-sibling      
self . yes  

Node Tests


Predicates


Functions and Operators


Nested Class Summary
 
Nested classes/interfaces inherited from class com.northconcepts.datapipeline.core.DataEndpoint
DataEndpoint.State
 
Field Summary
protected  Record currentRecord
           
protected  List<XmlField> fields
           
protected  File file
           
protected  XmlNodeReader reader
           
protected  List<XmlRecordBreak> recordBreaks
           
 
Fields inherited from class com.northconcepts.datapipeline.core.DataEndpoint
BUFFER_SIZE, log
 
Constructor Summary
XmlReader(File file)
           
XmlReader(Reader reader)
           
XmlReader(XmlNodeReader reader)
           
XmlReader(javax.xml.stream.XMLStreamReader streamReader)
           
 
Method Summary
 DataException addExceptionProperties(DataException exception)
          Adds this endpoint's current state to a DataException.
 XmlReader addField(String name, String locationPathAsString)
           
 XmlReader addField(String name, String locationPathAsString, boolean cascadeValues)
           
 XmlReader addField(XmlField field)
           
 XmlReader addRecordBreak(String locationPathAsString)
           
 void close()
          Indicates that this endpoint has finished reading or writing.
protected  void createRecord()
           
protected  void getFieldValues(XmlNode node)
           
protected  boolean isRecordBreak(XmlNode node)
           
 void open()
          Makes this endpoint ready for reading or writing.
protected  Record readImpl()
          Overridden by subclasses to read the next record from this DataReader.
 
Methods inherited from class com.northconcepts.datapipeline.core.DataReader
available, getBufferSize, getNestedReader, getRootReader, peek, pop, push, read, skip
 
Methods inherited from class com.northconcepts.datapipeline.core.DataEndpoint
assertNotOpened, assertOpened, decrementRecordCount, exception, exception, exception, finalize, getDescription, getRecordCount, getRecordCountAsBigInteger, getRecordCountAsString, getState, incrementRecordCount, isClosed, isOpen, isRecordCountBigInteger, resetRecordCount, setDescription, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

recordBreaks

protected final List<XmlRecordBreak> recordBreaks

fields

protected final List<XmlField> fields

reader

protected final XmlNodeReader reader

file

protected final File file

currentRecord

protected Record currentRecord
Constructor Detail

XmlReader

public XmlReader(File file)

XmlReader

public XmlReader(Reader reader)

XmlReader

public XmlReader(javax.xml.stream.XMLStreamReader streamReader)

XmlReader

public XmlReader(XmlNodeReader reader)
Method Detail

addRecordBreak

public XmlReader addRecordBreak(String locationPathAsString)

addField

public XmlReader addField(XmlField field)

addField

public XmlReader addField(String name,
                          String locationPathAsString,
                          boolean cascadeValues)

addField

public XmlReader addField(String name,
                          String locationPathAsString)

createRecord

protected void createRecord()

readImpl

protected Record readImpl()
                   throws Throwable
Description copied from class: DataReader
Overridden by subclasses to read the next record from this DataReader.

If no record is available, null will be returned.

Specified by:
readImpl in class DataReader
Throws:
Throwable

getFieldValues

protected void getFieldValues(XmlNode node)

isRecordBreak

protected boolean isRecordBreak(XmlNode node)

open

public void open()
          throws DataException
Description copied from class: DataEndpoint
Makes this endpoint ready for reading or writing.

Overrides:
open in class DataEndpoint
Throws:
DataException

close

public void close()
           throws DataException
Description copied from class: DataEndpoint
Indicates that this endpoint has finished reading or writing.

Overrides:
close in class DataEndpoint
Throws:
DataException

addExceptionProperties

public DataException addExceptionProperties(DataException exception)
Description copied from class: DataEndpoint
Adds this endpoint's current state to a DataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.

Overrides:
addExceptionProperties in class DataReader


Copyright (c) 2007-2012 North Concepts Inc. All Rights Reserved.