|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.jasperreports.engine.data.JRAbstractTextDataSource net.sf.jasperreports.engine.data.AbstractXmlDataSource
public abstract class AbstractXmlDataSource
Abstract XML data source implementation that allows to access the data from a xml document using XPath expressions.
The data source is constructed around a node set (record set) selected by an XPath expression from the xml document.
Each field can provide an additional XPath expresion that will be used to select its value. This expression must be specified using the "fieldDescription" element of the field. The expression is evaluated in the context of the current node thus the expression should be relative to the current node.
To support subreports, sub data sources can be created. There are two different methods for creating sub data sources. The first one allows to create a sub data source rooted at the current node. The current node can be seen as a new document around which the sub data source is created. The second method allows to create a sub data source that is rooted at the same document that is used by the data source but uses a different XPath select expression.
Example:
<A> <B id="0"> <C> <C> </B> <B id="1"> <C> <C> </B> <D id="3"> <E> <E> </D> </A>
Data source creation
Generally the full power of XPath expression is available. As an example, "/A/B[@id > 0"] will select all the nodes of type /A/B having the id greater than 0. You'll find a short XPath tutorial here.
Note on performance. Due to the fact that all the XPath expression are interpreted the data source performance is not great. For the cases where more speed is required, consider implementing a custom data source that directly accesses the Document through the DOM API.
Constructor Summary | |
---|---|
AbstractXmlDataSource()
|
Method Summary | |
---|---|
AbstractXmlDataSource |
dataSource()
Creates a sub data source using as root document the document used by "this" data source. |
abstract AbstractXmlDataSource |
dataSource(java.lang.String selectExpr)
Creates a sub data source using as root document the document used by "this" data source. |
abstract org.w3c.dom.Node |
getCurrentNode()
|
java.lang.Object |
getFieldValue(JRField jrField)
Gets the field value for the current position. |
abstract java.lang.Object |
getSelectObject(org.w3c.dom.Node currentNode,
java.lang.String expression)
|
java.lang.String |
getText(org.w3c.dom.Node node)
Return the text that a node contains. |
AbstractXmlDataSource |
subDataSource()
Creates a sub data source using the current node (record) as the root of the document. |
abstract AbstractXmlDataSource |
subDataSource(java.lang.String selectExpr)
Creates a sub data source using the current node (record) as the root of the document. |
abstract org.w3c.dom.Document |
subDocument()
Creates a document using the current node as root. |
Methods inherited from class net.sf.jasperreports.engine.data.JRAbstractTextDataSource |
---|
convertNumber, convertStringValue, getConvertBean, getDatePattern, getFormattedDate, getFormattedNumber, getLocale, getNumberPattern, getTimeZone, setDatePattern, setLocale, setLocale, setNumberPattern, setTextAttributes, setTimeZone, setTimeZone |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.sf.jasperreports.engine.JRRewindableDataSource |
---|
moveFirst |
Methods inherited from interface net.sf.jasperreports.engine.JRDataSource |
---|
next |
Constructor Detail |
---|
public AbstractXmlDataSource()
Method Detail |
---|
public abstract org.w3c.dom.Node getCurrentNode()
public abstract java.lang.Object getSelectObject(org.w3c.dom.Node currentNode, java.lang.String expression) throws JRException
JRException
public java.lang.Object getFieldValue(JRField jrField) throws JRException
JRDataSource
getFieldValue
in interface JRDataSource
JRException
public abstract AbstractXmlDataSource subDataSource(java.lang.String selectExpr) throws JRException
selectExpr
- the XPath select expression
JRException
- if the sub data source couldn't be createdJRXmlDataSource.JRXmlDataSource(Document, String)
public AbstractXmlDataSource subDataSource() throws JRException
JRException
- if the data source cannot be createdJRXmlDataSource.subDataSource(String)
,
JRXmlDataSource.JRXmlDataSource(Document)
public abstract org.w3c.dom.Document subDocument() throws JRException
JRException
public abstract AbstractXmlDataSource dataSource(java.lang.String selectExpr) throws JRException
selectExpr
- the XPath select expression
JRException
- if the sub data source couldn't be createdJRXmlDataSource.JRXmlDataSource(Document, String)
public AbstractXmlDataSource dataSource() throws JRException
JRException
- if the data source cannot be createdJRXmlDataSource.dataSource(String)
,
JRXmlDataSource.JRXmlDataSource(Document)
public java.lang.String getText(org.w3c.dom.Node node)
node
- a DOM node
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |