|
||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Interface Summary | |
---|---|
ComponentNode | A common interface to elements and attributes in the C24 Integreation Objects data model. |
DataNode | A virtual node in the C24 Integreation Objects data model which holds some accessible data from the original model. |
Node | A virtual node in the C24 Integreation Objects data model, other than an attribute or namespace node. |
Class Summary | |
---|---|
AttributeNode | This class represents an attribute of an object in the C24 Integreation Objects data model. |
CommentNode | A comment node in the C24 Integreation Objects data model |
ComplexElementNode | An element in the C24 Integreation Objects data model whose type is a complex type. |
DocumentNode | A document node in the C24 Integreation Objects data model. |
ElementNode | Implements the Saxon NodeInfo interface as a wrapper around the C24 Integreation Objects representation. |
LeafNode | Abstract superclass for a text node, comment node, or processing instruction node. |
ProcessingInstructionNode | A processing instruction node in the C24 Integreation Objects data model. |
SaxonXPath | Concrete implementation of IOXPath interface using Saxon. |
SaxonXQuery | Concrete implementation of IOXPath interface using Saxon. |
SimpleElementNode | An element node described in the schema as having a simple type. |
TextNode | A text node in the C24 Integreation Objects data model. |
XPath integration with Saxonica.
There are several ways of invoking the Saxon XPath API:Using the IOXPathFactory to get an IOXPath object:
biz.c24.io.api.data.ComplexDataObject cdo = ... ; // load object to be interrogated biz.c24.io.api.data.IOXPath xpath = biz.c24.io.api.data.IOXPathFactory.getInstance("/mynode/@myattribute"); // using a simple XPath expression // biz.c24.io.api.data.IOXPath xpath = biz.c24.io.api.data.IOXPathFactory.getInstance(new biz.c24.io.api.data.XPathStatement("/mynode/@ns1:myattribute", false, true)); // using an XPath statement to allow namespace declarations implicit in 'cdo' - assuming cdo contains a mapping for prefix 'ns1' // biz.c24.io.api.data.IOXPath xpath = biz.c24.io.api.data.IOXPathFactory.getInstance(new biz.c24.io.api.data.XPathStatement("/mynode/@ext:myattribute", false, // using an XPath statement to specify explicit namespace declarations new biz.c24.io.api.data.NamespaceMapping[]{ new biz.c24.io.api.data.NamespaceMapping("http://www.mynamespace.com/main-namespace", ""), new biz.c24.io.api.data.NamespaceMapping("http://www.mynamespace.com/imported-namespace", "ext")})); Object result = xpath.getObject(cdo); // result will be ComplexDataObject, String, Boolean, Number, Date, or other simple value. // String result = xpath.getString(cdo); // Boolean result = xpath.getBoolean(cdo); // Number result = xpath.getNumber(cdo); // List result = xpath.getList(cdo); // result will be a java.util.List of biz.c24.io.api.data.IOContext objects
Using the SaxonXPath wrapper directly:
biz.c24.io.api.data.ComplexDataObject cdo = ... ; // load object to be interrogated biz.c24.io.api.data.saxon.SaxonXPath xpath = new biz.c24.io.api.data.saxon.SaxonXPath("/mynode/@myattribute"); // using a simple XPath expression // biz.c24.io.api.data.saxon.SaxonXPath xpath = new biz.c24.io.api.data.saxon.SaxonXPath(new biz.c24.io.api.data.XPathStatement("/mynode/@ns1:myattribute", false, true)); // using an XPath statement to allow namespace declarations implicit in 'cdo' - assuming cdo contains a mapping for prefix 'ns1' // biz.c24.io.api.data.saxon.SaxonXPath xpath = new biz.c24.io.api.data.saxon.SaxonXPath(new biz.c24.io.api.data.XPathStatement("/mynode/@ext:myattribute", false, // using an XPath statement to specify explicit namespace declarations new biz.c24.io.api.data.NamespaceMapping[]{ new biz.c24.io.api.data.NamespaceMapping("http://www.mynamespace.com/main-namespace", ""), new biz.c24.io.api.data.NamespaceMapping("http://www.mynamespace.com/imported-namespace", "ext")})); Object result = xpath.getObject(cdo); // result will be ComplexDataObject, String, Boolean, Number, Date, or other simple value. // String result = xpath.getString(cdo); // Boolean result = xpath.getBoolean(cdo); // Number result = xpath.getNumber(cdo); // List result = xpath.getList(cdo); // result will be a java.util.List of biz.c24.io.api.data.IOContext objects
Using the SaxonXPath wrapper to handle namespace declarations and return the underlying Saxon XPathExpression:
biz.c24.io.api.data.ComplexDataObject cdo = ... ; // load object to be interrogated net.sf.saxon.Configuration config = new net.sf.saxon.Configuration(); net.sf.saxon.sxpath.XPathExpression xpath = biz.c24.io.api.data.saxon.SaxonXPath.createExpression(new biz.c24.io.api.data.XPathStatement("/mynode/@ns1:myattribute", false, true), config); // assuming 'cdo' contains a mapping for prefix 'ns1' Object result = xpath.evaluateSingle(new biz.c24.io.api.data.saxon.DocumentNode(config, cdo, true, true)); // result will be net.sf.saxon.om.NodeInfo (or a subclass such as biz.c24.io.api.data.saxon.DataNode), or a simple value. // List result = xpath.evaluate(new biz.c24.io.api.data.saxon.DocumentNode(config, cdo, true, true)); // result will be a java.util.List of the above
Using the Saxon XPathExpression directly:
biz.c24.io.api.data.ComplexDataObject cdo = ... ; // load object to be interrogated net.sf.saxon.Configuration config = new net.sf.saxon.Configuration(); net.sf.saxon.sxpath.XPathEvaluator eval = new net.sf.saxon.sxpath.XPathEvaluator(config); eval.getStaticContext().declareNamespace("ext", "http://www.mynamespace.com/imported-namespace"); eval.getStaticContext().declareNamespace("int", "http://www.mynamespace.com/main-namespace"); // eval.getStaticContext().setDefaultElementNamespace("http://www.mynamespace.com/main-namespace"); set default (no prefix) namespace instead of 'int' net.sf.saxon.sxpath.XPathExpression xpath = eval.createExpression("/int:mynode/@ext:myattribute"); Object result = xpath.evaluateSingle(new biz.c24.io.api.data.saxon.DocumentNode(config, cdo, true, true)); // result will be net.sf.saxon.om.NodeInfo (or subclass such as biz.c24.io.api.data.saxon.DataNode), or a simple value. // List result = xpath.evaluate(new biz.c24.io.api.data.saxon.DocumentNode(config, cdo, true, true)); // result will be a java.util.List of the above
Using other native Saxon accessors:
Please see Saxonica for more information & examples.
|
||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |