Skip navigation links

Oracle® Fusion Middleware Site Studio for External Applications Java API Reference
11g Release 1 (11.1.1)

E17273-02


oracle.stellent.wcm.common.xml
Class XPathEvaluator

java.lang.Object
  extended by oracle.stellent.wcm.common.xml.XPathEvaluator


public class XPathEvaluator
extends java.lang.Object

Parses an XML file from a given inputstream. Wraps calls into the XPath API.


Field Summary
protected  org.w3c.dom.Node m_contextNode
           
protected  java.lang.String m_defaultPrefix
           
protected  org.w3c.dom.Element m_documentRoot
           
protected  javax.xml.namespace.NamespaceContext m_namespaceContext
           
protected  javax.xml.xpath.XPath m_xpath
           

 

Constructor Summary
XPathEvaluator(org.w3c.dom.Element rootElement)
          Initialize an Evaluator object based on the current element as the root
XPathEvaluator(org.w3c.dom.Element rootElement, javax.xml.namespace.NamespaceContext namespaceContext)
          Initialize an Evaluator object based on the current element as the root
XPathEvaluator(org.xml.sax.InputSource xmlSource, javax.xml.namespace.NamespaceContext namespaceContext, boolean validating, java.lang.String defaultPrefix)
          Builds a new XPath evaluator from an InputSource.
XPathEvaluator(java.io.InputStream xmlStream)
          Builds an XPathEvaluator with no namespace evaluator and non-validating, using "wcm" as the default namespace prefix.
XPathEvaluator(java.io.InputStream xmlStream, javax.xml.namespace.NamespaceContext namespaceContext, boolean validating, java.lang.String defaultPrefix)
          Builds a new XPath evaluator from InputStream.
XPathEvaluator(java.io.Reader xmlReader)
           
XPathEvaluator(java.io.Reader xmlReader, javax.xml.namespace.NamespaceContext namespaceContext, boolean validating, java.lang.String defaultPrefix)
          Builds a new XPath evaluator from a Reader.

 

Method Summary
protected  javax.xml.xpath.XPathExpression compileXPathExpression(java.lang.String xpath)
           
 org.w3c.dom.Node evaluateToNode(java.lang.String xpath)
          Evaluate the xpath expression; return the result as a Node
 org.w3c.dom.NodeList evaluateToNodeList(java.lang.String xpath)
          Evaluate the xpath expression; return the result as a NodeList
 java.lang.String evaluateToString(java.lang.String xpath)
          Evaluate the xpath expression; return the result as a String.
protected  java.lang.Object evaluateXPath(java.lang.String xpath, javax.xml.namespace.QName returnType)
           
 org.w3c.dom.Node getContextNode()
           
 org.w3c.dom.Node getElementById(java.lang.String id)
          Retrieve an element by ID.
 javax.xml.namespace.NamespaceContext getNamespaceContext()
           
 org.w3c.dom.Element getRootNode()
           
protected  javax.xml.xpath.XPath getXPath()
           
protected  void initNamespaceContext(javax.xml.namespace.NamespaceContext namespaceContext)
          Initialize the namespace context.
 void resetContext()
          Reset the context to the root node
 void setContextNode(org.w3c.dom.Node node)
          Set the context of the queries
 void setContextNode(java.lang.String xpath)
          Set the context of the queries to be the result of the given xpath expression
 void setIdAttribute(java.lang.String attribute, boolean enable)
          Set the ID attribute feature against this DOM tree

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

m_namespaceContext

protected javax.xml.namespace.NamespaceContext m_namespaceContext

m_documentRoot

protected org.w3c.dom.Element m_documentRoot

m_xpath

protected javax.xml.xpath.XPath m_xpath

m_contextNode

protected org.w3c.dom.Node m_contextNode

m_defaultPrefix

protected java.lang.String m_defaultPrefix

Constructor Detail

XPathEvaluator

public XPathEvaluator(org.w3c.dom.Element rootElement)
Initialize an Evaluator object based on the current element as the root
Parameters:
rootElement - the root of all xpath queries

XPathEvaluator

public XPathEvaluator(org.w3c.dom.Element rootElement,
                      javax.xml.namespace.NamespaceContext namespaceContext)
Initialize an Evaluator object based on the current element as the root
Parameters:
rootElement - the root of all xpath queries
namespaceContext - the namespace context to use

XPathEvaluator

public XPathEvaluator(java.io.InputStream xmlStream)
               throws XPathEvaluatorException
Builds an XPathEvaluator with no namespace evaluator and non-validating, using "wcm" as the default namespace prefix.
Parameters:
xmlStream - the stream to the xml file contents
Throws:
XPathEvaluatorException

XPathEvaluator

public XPathEvaluator(java.io.InputStream xmlStream,
                      javax.xml.namespace.NamespaceContext namespaceContext,
                      boolean validating,
                      java.lang.String defaultPrefix)
               throws XPathEvaluatorException
Builds a new XPath evaluator from InputStream.
Parameters:
xmlStream - the stream to the xml file contents
namespaceContext - (optional) the namespace resolver
validating - true to set the parser to validating
defaultPrefix - the prefix to use for querying in the default namespace
Throws:
XPathEvaluatorException

XPathEvaluator

public XPathEvaluator(java.io.Reader xmlReader)
               throws XPathEvaluatorException
Throws:
XPathEvaluatorException

XPathEvaluator

public XPathEvaluator(java.io.Reader xmlReader,
                      javax.xml.namespace.NamespaceContext namespaceContext,
                      boolean validating,
                      java.lang.String defaultPrefix)
               throws XPathEvaluatorException
Builds a new XPath evaluator from a Reader.
Parameters:
xmlReader - the reader to the xml file contents
namespaceContext - (optional) the namespace resolver
validating - true to set the parser to validating
defaultPrefix - the prefix to use for querying in the default namespace
Throws:
XPathEvaluatorException

XPathEvaluator

public XPathEvaluator(org.xml.sax.InputSource xmlSource,
                      javax.xml.namespace.NamespaceContext namespaceContext,
                      boolean validating,
                      java.lang.String defaultPrefix)
               throws XPathEvaluatorException
Builds a new XPath evaluator from an InputSource.
Parameters:
xmlSource - the inputSource to the xml file contents
namespaceContext - (optional) the namespace resolver
validating - true to set the parser to validating
defaultPrefix - the prefix to use for querying in the default namespace
Throws:
XPathEvaluatorException

Method Detail

initNamespaceContext

protected void initNamespaceContext(javax.xml.namespace.NamespaceContext namespaceContext)
Initialize the namespace context. Should be called by all constructors.
Parameters:
namespaceContext - the namespace context or null to use the default

getNamespaceContext

public javax.xml.namespace.NamespaceContext getNamespaceContext()
Returns:
the configured namespace context

setIdAttribute

public void setIdAttribute(java.lang.String attribute,
                           boolean enable)
Set the ID attribute feature against this DOM tree
Parameters:
attribute - the attribute to declare as the DOM ID attribute
enable - true to enable this attribute, false to disable the ID functionality

getElementById

public org.w3c.dom.Node getElementById(java.lang.String id)
Retrieve an element by ID. Only valid after calling setIdAttribute(String, boolean) to enable the ID attribute functionality.
Parameters:
id - the ID to query
Returns:
the node with the corresponding ID or null if not found

setContextNode

public void setContextNode(org.w3c.dom.Node node)
Set the context of the queries
Parameters:
node - the context node

setContextNode

public void setContextNode(java.lang.String xpath)
Set the context of the queries to be the result of the given xpath expression
Parameters:
xpath - the xpath to the root for the queries

getContextNode

public org.w3c.dom.Node getContextNode()
Returns:
the current context node

getRootNode

public org.w3c.dom.Element getRootNode()
Returns:
get root node

resetContext

public void resetContext()
Reset the context to the root node

evaluateToString

public java.lang.String evaluateToString(java.lang.String xpath)
Evaluate the xpath expression; return the result as a String. This typically will be the text value of the node (i.e. attribute value, non-xml child content).
Parameters:
xpath - the xpath expression from the current context root
Returns:
a string expression of the result

evaluateToNode

public org.w3c.dom.Node evaluateToNode(java.lang.String xpath)
Evaluate the xpath expression; return the result as a Node
Parameters:
xpath - the xpath expression from the current context root
Returns:
a string expression of the result

evaluateToNodeList

public org.w3c.dom.NodeList evaluateToNodeList(java.lang.String xpath)
Evaluate the xpath expression; return the result as a NodeList
Parameters:
xpath - the xpath expression from the current context root
Returns:
a string expression of the result

evaluateXPath

protected java.lang.Object evaluateXPath(java.lang.String xpath,
                                         javax.xml.namespace.QName returnType)

compileXPathExpression

protected javax.xml.xpath.XPathExpression compileXPathExpression(java.lang.String xpath)
                                                          throws XPathEvaluatorException
Throws:
XPathEvaluatorException

getXPath

protected javax.xml.xpath.XPath getXPath()

Skip navigation links

Oracle® Fusion Middleware Site Studio for External Applications Java API Reference
11g Release 1 (11.1.1)

E17273-02


Copyright © 2010, 2011, Oracle and/or its affiliates. All rights reserved.