Skip navigation links

Oracle® Fusion Middleware Java API Reference for Oracle WebCenter Content Remote Intradoc Client (RIDC)
11g Release 1 (11.1)

E17274-04


oracle.stellent.ridc.common.xml
Class XPathEvaluator

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


public class XPathEvaluator
extends Object

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


Field Summary
protected  Node m_contextNode
           
protected  String m_defaultPrefix
           
protected  Element m_documentRoot
           
protected  NamespaceContext m_namespaceContext
           
protected  XPath m_xpath
           

 

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

 

Method Summary
protected  XPathExpression compileXPathExpression(String xpath)
           
 Node evaluateToNode(String xpath)
          Evaluate the xpath expression; return the result as a Node
 NodeList evaluateToNodeList(String xpath)
          Evaluate the xpath expression; return the result as a NodeList
 String evaluateToString(String xpath)
          Evaluate the xpath expression; return the result as a String.
protected  Object evaluateXPath(String xpath, QName returnType)
           
 Node getContextNode()
           
 Node getElementById(String id)
          Retrieve an element by ID.
 NamespaceContext getNamespaceContext()
           
 Element getRootNode()
           
protected  XPath getXPath()
           
protected  void initNamespaceContext(NamespaceContext namespaceContext)
          Initialize the namespace context.
 void resetContext()
          Reset the context to the root node
 void setContextNode(Node node)
          Set the context of the queries
 void setContextNode(String xpath)
          Set the context of the queries to be the result of the given xpath expression
 void setIdAttribute(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 NamespaceContext m_namespaceContext

m_documentRoot

protected Element m_documentRoot

m_xpath

protected XPath m_xpath

m_contextNode

protected Node m_contextNode

m_defaultPrefix

protected String m_defaultPrefix

Constructor Detail

XPathEvaluator

public XPathEvaluator(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(Element rootElement,
                      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(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(InputStream xmlStream,
                      NamespaceContext namespaceContext,
                      boolean validating,
                      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(Reader xmlReader)
               throws XPathEvaluatorException
Throws:
XPathEvaluatorException

XPathEvaluator

public XPathEvaluator(Reader xmlReader,
                      NamespaceContext namespaceContext,
                      boolean validating,
                      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(InputSource xmlSource,
                      NamespaceContext namespaceContext,
                      boolean validating,
                      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(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 NamespaceContext getNamespaceContext()
Returns:
the configured namespace context

setIdAttribute

public void setIdAttribute(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 Node getElementById(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(Node node)
Set the context of the queries
Parameters:
node - the context node

setContextNode

public void setContextNode(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 Node getContextNode()
Returns:
the current context node

getRootNode

public Element getRootNode()
Returns:
get root node

resetContext

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

evaluateToString

public String evaluateToString(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 Node evaluateToNode(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 NodeList evaluateToNodeList(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 Object evaluateXPath(String xpath,
                               QName returnType)

compileXPathExpression

protected XPathExpression compileXPathExpression(String xpath)
                                          throws XPathEvaluatorException
Throws:
XPathEvaluatorException

getXPath

protected XPath getXPath()

Skip navigation links

Oracle® Fusion Middleware Java API Reference for Oracle WebCenter Content Remote Intradoc Client (RIDC)
11g Release 1 (11.1)

E17274-04


Copyright © 2008, 2013, Oracle and/or its affiliates. All rights reserved.