org.apache.metamodel.xml
Class XmlSaxTableDef
java.lang.Object
org.apache.metamodel.xml.XmlSaxTableDef
- All Implemented Interfaces:
- Serializable
public final class XmlSaxTableDef
- extends Object
- implements Serializable
Defines a table layout for XmlSaxDataContext. This class is used as
an instruction set of xpath expressions for the datacontext to create
Tables.
These types of expressions are allowed in the XmlSaxTableDef:
- Element selectors: "/path/to/element"
- Attribute selectors: "/path/to/element@attribute"
- Element index selectors: "index(/path/to)" (can be used to make
cross-references to parent tags)
If, for example, this is your XML document:
<root>
<organization type="company">
<name>Company A</name>
<employees>
<employee>
<name>John Doe</name>
<gender>M</gender>
</employee>
<employee>
<name>Jane Doe</name>
<gender>F</gender>
</employee>
</employees>
</organization>
<organization type="government">
<name>Company B</name>
<employees>
<employee>
<name>Susan</name>
<gender>F</gender>
</employee>
</employees>
</organization>
</root>
Then if you wanted to extract information about organizations, these xpaths
could work:
- Organization row scope: "/root/organization"
- Organization name: "/root/organization/name"
- Organization type: "/root/organization@type"
Or if you wanted to extract information about employees:
- Employee row scope: "/root/organization/employees/employee"
- Employee name: "/root/organization/employees/employee/name"
- Employee gender: "/root/organization/employees/employee/gender"
- Employee organization index: "index(/root/organization)"
- See Also:
- Serialized Form
|
Constructor Summary |
XmlSaxTableDef(String rowXpath,
String[] valueXpaths)
Constructs a XmlSaxTableDef based on an xpath expression for the
row scope and an array of xpath expressions for the individual values
(columns) within a row. |
XmlSaxTableDef
public XmlSaxTableDef(String rowXpath,
String[] valueXpaths)
- Constructs a
XmlSaxTableDef based on an xpath expression for the
row scope and an array of xpath expressions for the individual values
(columns) within a row.
- Parameters:
rowXpath - an xpath expression for the scope of a record, eg.
/companies/company/employeevalueXpaths - an array of xpath expressions for the individual values
(columns) of a row. eg: [/companies/company/employee/name,
/companies/company/employee/gender, index(/companies/company)]
getRowXpath
public String getRowXpath()
getValueXpaths
public String[] getValueXpaths()
hashCode
public int hashCode()
- Overrides:
hashCode in class Object
equals
public boolean equals(Object obj)
- Overrides:
equals in class Object
toString
public String toString()
- Overrides:
toString in class Object
Copyright © 2007–2015 The Apache Software Foundation. All rights reserved.