public class XmlReader extends DataReader
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
Modifier and Type | Class and Description |
---|---|
static class |
XmlReader.DuplicateFieldPolicy |
DataEndpoint.State
Modifier and Type | Field and Description |
---|---|
protected Record |
currentRecord |
protected List<XmlField> |
fields |
protected File |
file |
protected boolean |
hasCascadingFields |
protected XmlNodeReader |
reader |
protected List<XmlRecordBreak> |
recordBreaks |
fieldLineage, recordLineage
lastRecord, PRODUCT, PRODUCT_VERSION, VENDOR, XML_INPUT_FACTORY_KEY
BUFFER_SIZE, captureElapsedTime, DEFAULT_READ_BUFFER_SIZE
id, log, name, TIMESTAMP_FORMAT
Constructor and Description |
---|
XmlReader(File file) |
XmlReader(Reader reader) |
XmlReader(XmlNodeReader reader) |
XmlReader(XMLStreamReader streamReader) |
Modifier and Type | Method and Description |
---|---|
DataException |
addExceptionProperties(DataException exception)
Adds this endpoint's current state to a
DataException . |
XmlReader |
addField(String name,
String locationPathAsString)
Identifies a new field using XPath in the XML stream.
|
XmlReader |
addField(String name,
String locationPathAsString,
boolean cascadeValues)
Identifies a new field using XPath in the XML stream.
|
XmlReader |
addField(String name,
String locationPathAsString,
String cascadeResetLocationPath)
Identifies a new field using XPath in the XML stream.
|
XmlReader |
addField(XmlField field) |
protected void |
addFieldValue(Field recordField,
Object value) |
protected Record |
addLineage(Record record) |
XmlReader |
addRecordBreak(String locationPathAsString) |
void |
close()
Indicates that this endpoint has finished reading or writing.
|
protected void |
createRecord() |
protected void |
expandAndPushRecords(Record record) |
protected void |
expandListFieldsAsFields(Record record) |
XmlReader.DuplicateFieldPolicy |
getDuplicateFieldPolicy() |
protected void |
getFieldValues(long sequence) |
protected XmlNodeReader |
getXmlNodeReader() |
boolean |
isAddTextToParent()
Return true if each child node's text should be concatenated to its parent during parsing (defaults to false).
|
boolean |
isAutoCloseReader() |
boolean |
isDebug() |
boolean |
isIgnoreNamespaces()
Indicates if namespaces on elements and attributes are ignored when matching expressions (default to true).
|
boolean |
isLineageSupported() |
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 . |
protected void |
saveAncestorAttributeFieldValues(XmlNode node) |
protected void |
saveAncestorNodeFieldValues(XmlNode node) |
protected void |
saveFieldValues(XmlNode node) |
XmlReader |
setAddTextToParent(boolean addTextToParent)
Indicates if each child node's text should be concatenated to its parent during parsing (defaults to false).
|
XmlReader |
setAutoCloseReader(boolean autoCloseReader) |
XmlReader |
setDebug(boolean debug) |
XmlReader |
setDescription(String description) |
XmlReader |
setDuplicateFieldPolicy(XmlReader.DuplicateFieldPolicy duplicateFieldPolicy) |
XmlReader |
setIgnoreNamespaces(boolean ignoreNamespaces)
Indicates if namespaces on elements and attributes are ignored when matching expressions (default to true).
|
protected void |
setRecordField(XmlNode node,
XmlField xmlField,
LocationPath path) |
XmlReader |
setSaveLineage(boolean saveLineage) |
available, getBufferSize, getNestedEndpoint, getNestedReader, getRootEndpoint, getRootReader, isExhausted, isSaveLineage, peek, pop, push, read, skip
decrementRecordCount, enableJmx, getLastRecord, getRecordCount, getRecordCountAsBigInteger, getRecordCountAsString, incrementRecordCount, isRecordCountBigInteger, resetRecordCount, toString
addElapsedtime, assertClosed, assertNotOpened, assertOpened, finalize, getClosedOn, getDescription, getElapsedTime, getElapsedTimeAsString, getOpenedOn, getOpenElapsedTime, getOpenElapsedTimeAsString, getSelfTime, getSelfTimeAsString, getState, isCaptureElapsedTime, isClosed, isOpen, setCaptureElapsedTime
protected final List<XmlRecordBreak> recordBreaks
protected final XmlNodeReader reader
protected final File file
protected Record currentRecord
protected boolean hasCascadingFields
public XmlReader(File file)
public XmlReader(Reader reader)
public XmlReader(XMLStreamReader streamReader)
public XmlReader(XmlNodeReader reader)
public boolean isDebug()
public XmlReader setDebug(boolean debug)
protected XmlNodeReader getXmlNodeReader()
public boolean isAddTextToParent()
public XmlReader setAddTextToParent(boolean addTextToParent)
true
will
result in higher memory consumption.public XmlReader addField(String name, String locationPathAsString, boolean cascadeValues)
name
- the field name to createlocationPathAsString
- the XPath to match to populate this fieldcascadeValues
- indicates if this reader should return the last value seen for this field when no matches are available.public XmlReader addField(String name, String locationPathAsString, String cascadeResetLocationPath)
cascadeResetLocationPath
is not null and not empty, it will indicate when this
field should be cleared, otherwise this field will return the last value seen when no new matches are available.name
- the field name to createlocationPathAsString
- the XPath to match to populate this fieldcascadeResetLocationPath
- the XPath to identify when cascading values (i.e. the last value seen for this field) should be cleared.public XmlReader addField(String name, String locationPathAsString)
name
- the field name to createlocationPathAsString
- the XPath to match to populate this fieldpublic XmlReader.DuplicateFieldPolicy getDuplicateFieldPolicy()
public XmlReader setDuplicateFieldPolicy(XmlReader.DuplicateFieldPolicy duplicateFieldPolicy)
public boolean isIgnoreNamespaces()
public XmlReader setIgnoreNamespaces(boolean ignoreNamespaces)
protected void createRecord()
public XmlReader setSaveLineage(boolean saveLineage)
setSaveLineage
in class DataReader
public XmlReader setDescription(String description)
setDescription
in class Endpoint
protected Record readImpl() throws Throwable
DataReader
DataReader
. The default
implementation of DataReader.read()
now insures that this method will not be called again after it returns
a null
.
If no record is available, null
will be returned.
readImpl
in class DataReader
Throwable
protected void expandAndPushRecords(Record record)
protected void expandListFieldsAsFields(Record record)
protected void setRecordField(XmlNode node, XmlField xmlField, LocationPath path)
protected void saveFieldValues(XmlNode node)
protected void saveAncestorAttributeFieldValues(XmlNode node)
protected void saveAncestorNodeFieldValues(XmlNode node)
protected void getFieldValues(long sequence)
protected boolean isRecordBreak(XmlNode node)
public void open() throws DataException
DataEndpoint
open
in class DataEndpoint
DataException
public void close() throws DataException
DataEndpoint
close
in class DataEndpoint
DataException
public boolean isLineageSupported()
isLineageSupported
in class DataReader
protected Record addLineage(Record record)
addLineage
in class DataReader
public DataException addExceptionProperties(DataException exception)
Endpoint
DataException
. Since this method is called whenever an
exception is thrown, subclasses should override it to add their specific information.addExceptionProperties
in class DataReader
public boolean isAutoCloseReader()
public XmlReader setAutoCloseReader(boolean autoCloseReader)
Copyright (c) 2006-2024 North Concepts Inc. All Rights Reserved.