com.fujitsu.xml.omquery
Class DomQueryMgr

java.lang.Object
  extended by com.fujitsu.xml.omquery.OmQueryMgrBase
      extended by com.fujitsu.xml.omquery.DomQueryMgr

public class DomQueryMgr
extends OmQueryMgrBase

A class which provides XPath API facility on top of DOM by interfacing with James Clark's XT.


For example:
   InputSource input = new InputSource(createURL("sample.xml"));
   XMLProcessorImpl xmlproc = new JAXP_ProcessorImpl();
   Document doc = xmlproc.load(input);

   DomQueryMgr query_mgr = new DomQueryMgr(doc);

   NamespacePrefixMap nspm = query_mgr.getEmptyNamespacePrefixMap();
   nspm = nspm.bind("fuj", "http://www.fujitsu.co.jp/");

   XPathContext ctx = query_mgr.createXPathContext(doc, nspm);

   Enumeration iter = query_mgr.getNodesByXPath("(A/B/C)[2]", ctx);
 

Author:
Takuki Kamiya

Nested Class Summary
 
Nested classes/interfaces inherited from class com.fujitsu.xml.omquery.OmQueryMgrBase
OmQueryMgrBase.MyExprContext, OmQueryMgrBase.MyLoadContext, OmQueryMgrBase.MyVariableMgr
 
Field Summary
(package private)  com.jclark.xsl.dom.RootNode rootNode
           
 
Fields inherited from class com.fujitsu.xml.omquery.OmQueryMgrBase
nametbl
 
Constructor Summary
DomQueryMgr(org.w3c.dom.Document doc)
          Constructs a Query Manager for DOM.
 
Method Summary
 XPathContext createXPathContext()
          Creates a XPath evaluation context with default values.
 XPathContext createXPathContext(org.w3c.dom.Node dom_node, com.jclark.xsl.om.NamespacePrefixMap nspm)
          Creates a XPath evaluation context with specified context node and namespace bindings.
 XPathContext createXPathContext(org.w3c.dom.Node dom_node, com.jclark.xsl.om.NamespacePrefixMap nspm, int position, int size)
          Creates a XPath evaluation context with specified values.
 boolean getBooleanByXPath(org.w3c.dom.Node base_node, java.lang.String selector)
          Evaluates XPath expression on top DOM to yield a boolean.
 boolean getBooleanByXPath(org.w3c.dom.Node base_node, java.lang.String selector, com.jclark.xsl.om.NamespacePrefixMap nspm)
           
 boolean getBooleanByXPath(java.lang.String selector, XPathContext context)
          Evaluates XPath expression on top DOM to yield a boolean.
 com.jclark.xsl.om.NamespacePrefixMap getEmptyNamespacePrefixMap()
          Get an empty NamespacePrefixMap.
 java.util.Enumeration getNodesByXPath(org.w3c.dom.Node base_node, java.lang.String selector)
          Performs XPath query on top DOM.
 java.util.Enumeration getNodesByXPath(org.w3c.dom.Node base_node, java.lang.String selector, com.jclark.xsl.om.NamespacePrefixMap nspm)
           
 java.util.Enumeration getNodesByXPath(java.lang.String selector, XPathContext context)
          Performs XPath query on top DOM.
 double getNumberByXPath(org.w3c.dom.Node base_node, java.lang.String selector)
          Evaluates XPath expression on top DOM to yield a number.
 double getNumberByXPath(org.w3c.dom.Node base_node, java.lang.String selector, com.jclark.xsl.om.NamespacePrefixMap nspm)
           
 double getNumberByXPath(java.lang.String selector, XPathContext context)
          Evaluates XPath expression on top DOM to yield a number.
 java.lang.String getStringByXPath(org.w3c.dom.Node base_node, java.lang.String selector)
          Evaluates XPath expression on top DOM to yield a string.
 java.lang.String getStringByXPath(org.w3c.dom.Node base_node, java.lang.String selector, com.jclark.xsl.om.NamespacePrefixMap nspm)
           
 java.lang.String getStringByXPath(java.lang.String selector, XPathContext context)
          Evaluates XPath expression on top DOM to yield a string.
(package private)  com.jclark.xsl.om.Node getXtOmNode(org.w3c.dom.Node dom_node)
           
 
Methods inherited from class com.fujitsu.xml.omquery.OmQueryMgrBase
getBooleanWithXPath, getBooleanWithXPath, getBooleanWithXPath, getNameTable, getNodesWithXPath, getNodesWithXPath, getNodesWithXPath, getNumberWithXPath, getNumberWithXPath, getNumberWithXPath, getStringWithXPath, getStringWithXPath, getStringWithXPath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rootNode

final com.jclark.xsl.dom.RootNode rootNode
Constructor Detail

DomQueryMgr

public DomQueryMgr(org.w3c.dom.Document doc)
Constructs a Query Manager for DOM. Query Manager for DOM insulates applications from knowing miscellaneous house keeping procedures required to use XT's internal modules which provides the actual capability of XPath querying.

Parameters:
doc - an instance of org.w3c.dom.Document. In subsequent query request, an org.w3c.dom.Node owned by this document must be specified as the base node.
Method Detail

createXPathContext

public XPathContext createXPathContext()
Creates a XPath evaluation context with default values. Context node, the set of namespace bindings, context position and context size are defaulted to null, null, 1 and 1, respectively. Note that a XPath evaluation context is early-binded to a particular DomQueryMgr instance.


createXPathContext

public XPathContext createXPathContext(org.w3c.dom.Node dom_node,
                                       com.jclark.xsl.om.NamespacePrefixMap nspm)
Creates a XPath evaluation context with specified context node and namespace bindings. Context position and context size are defaulted to 1 and 1, respectively. Note that a XPath evaluation context is early-binded to a particular DomQueryMgr instance.

Parameters:
dom_node - context node of type org.w3c.dom.Node
nspm - Namespace bindings

createXPathContext

public XPathContext createXPathContext(org.w3c.dom.Node dom_node,
                                       com.jclark.xsl.om.NamespacePrefixMap nspm,
                                       int position,
                                       int size)
Creates a XPath evaluation context with specified values. Note that a XPath evaluation context is early-binded to a particular DomQueryMgr instance.

Parameters:
dom_node - context node of type org.w3c.dom.Node
nspm - Namespace bindings
position - context position
position - context size

getNodesByXPath

public java.util.Enumeration getNodesByXPath(org.w3c.dom.Node base_node,
                                             java.lang.String selector)
                                      throws com.jclark.xsl.om.XSLException
Performs XPath query on top DOM. Returns java.util.Enumeration with which to iterate through objects of type org.w3c.dom.Node that matched the specified selector.

Parameters:
base_node - the node where query processing starts from.
selector - XPath query string
Returns:
Enumeration of objects of type org.w3c.dom.Node for iterating through the query result
Throws:
com.jclark.xsl.om.XSLException

getNodesByXPath

public java.util.Enumeration getNodesByXPath(org.w3c.dom.Node base_node,
                                             java.lang.String selector,
                                             com.jclark.xsl.om.NamespacePrefixMap nspm)
                                      throws com.jclark.xsl.om.XSLException
Throws:
com.jclark.xsl.om.XSLException

getNodesByXPath

public java.util.Enumeration getNodesByXPath(java.lang.String selector,
                                             XPathContext context)
                                      throws com.jclark.xsl.om.XSLException
Performs XPath query on top DOM. Returns java.util.Enumeration with which to iterate through objects of type org.w3c.dom.Node that matched the specified selector.

Parameters:
selector - XPath query string
context - XPath evaluation context against which the expression is to be evaluated
Returns:
Enumeration of objects of type org.w3c.dom.Node for iterating through the query result
Throws:
com.jclark.xsl.om.XSLException

getNumberByXPath

public double getNumberByXPath(org.w3c.dom.Node base_node,
                               java.lang.String selector)
                        throws com.jclark.xsl.om.XSLException
Evaluates XPath expression on top DOM to yield a number.

Parameters:
base_node - the node where expression evaluation starts from.
selector - XPath expression to be evaluated into a number
Returns:
a number of type double
Throws:
com.jclark.xsl.om.XSLException

getNumberByXPath

public double getNumberByXPath(org.w3c.dom.Node base_node,
                               java.lang.String selector,
                               com.jclark.xsl.om.NamespacePrefixMap nspm)
                        throws com.jclark.xsl.om.XSLException
Throws:
com.jclark.xsl.om.XSLException

getNumberByXPath

public double getNumberByXPath(java.lang.String selector,
                               XPathContext context)
                        throws com.jclark.xsl.om.XSLException
Evaluates XPath expression on top DOM to yield a number.

Parameters:
selector - XPath expression to be evaluated into a number
context - XPath evaluation context against which the expression is to be evaluated
Returns:
a number of type double
Throws:
com.jclark.xsl.om.XSLException

getBooleanByXPath

public boolean getBooleanByXPath(org.w3c.dom.Node base_node,
                                 java.lang.String selector)
                          throws com.jclark.xsl.om.XSLException
Evaluates XPath expression on top DOM to yield a boolean.

Parameters:
base_node - the node where expression evaluation starts from.
selector - XPath expression to be evaluated into a boolean
Returns:
a value of type boolean
Throws:
com.jclark.xsl.om.XSLException

getBooleanByXPath

public boolean getBooleanByXPath(org.w3c.dom.Node base_node,
                                 java.lang.String selector,
                                 com.jclark.xsl.om.NamespacePrefixMap nspm)
                          throws com.jclark.xsl.om.XSLException
Throws:
com.jclark.xsl.om.XSLException

getBooleanByXPath

public boolean getBooleanByXPath(java.lang.String selector,
                                 XPathContext context)
                          throws com.jclark.xsl.om.XSLException
Evaluates XPath expression on top DOM to yield a boolean.

Parameters:
selector - XPath expression to be evaluated into a boolean
context - XPath evaluation context against which the expression is to be evaluated
Returns:
a value of type boolean
Throws:
com.jclark.xsl.om.XSLException

getStringByXPath

public java.lang.String getStringByXPath(org.w3c.dom.Node base_node,
                                         java.lang.String selector)
                                  throws com.jclark.xsl.om.XSLException
Evaluates XPath expression on top DOM to yield a string.

Parameters:
base_node - the node where expression evaluation starts from.
selector - XPath expression to be evaluated into a string
Returns:
a value of type String
Throws:
com.jclark.xsl.om.XSLException

getStringByXPath

public java.lang.String getStringByXPath(org.w3c.dom.Node base_node,
                                         java.lang.String selector,
                                         com.jclark.xsl.om.NamespacePrefixMap nspm)
                                  throws com.jclark.xsl.om.XSLException
Throws:
com.jclark.xsl.om.XSLException

getStringByXPath

public java.lang.String getStringByXPath(java.lang.String selector,
                                         XPathContext context)
                                  throws com.jclark.xsl.om.XSLException
Evaluates XPath expression on top DOM to yield a string.

Parameters:
selector - XPath expression to be evaluated into a string
context - XPath evaluation context against which the expression is to be evaluated
Returns:
a value of type String
Throws:
com.jclark.xsl.om.XSLException

getEmptyNamespacePrefixMap

public com.jclark.xsl.om.NamespacePrefixMap getEmptyNamespacePrefixMap()
Get an empty NamespacePrefixMap. See also com.jclark.xsl.om.NamespacePrefixMap.


getXtOmNode

com.jclark.xsl.om.Node getXtOmNode(org.w3c.dom.Node dom_node)