Java Doc for XPathEvaluator.java in  » XML » saxonb » net » sf » saxon » xpath » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » XML » saxonb » net.sf.saxon.xpath 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   net.sf.saxon.xpath.XPathEvaluator

XPathEvaluator
public class XPathEvaluator implements XPath(Code)

XPathEvaluator provides a simple API for standalone XPath processing (that is, executing XPath expressions in the absence of an XSLT stylesheet). It is an implementation of the JAXP 1.3 XPath interface, with additional methods provided (a) for backwards compatibility (b) to give extra control over the XPath evaluation, and (c) to support XPath 2.0.


author:
   Michael H. Kay



Constructor Summary
public  XPathEvaluator()
     Default constructor.
public  XPathEvaluator(Configuration config)
     Construct an XPathEvaluator with a specified configuration.
Parameters:
  config - the configuration to be used.
public  XPathEvaluator(Source source)
     Construct an XPathEvaluator to process a particular source document.

Method Summary
public  XPathExpressioncompile(String expr)
    
public  XPathExpressionImplcreateExpression(String expression)
     Prepare an XPath expression for subsequent evaluation.
Parameters:
  expression - The XPath expression to be evaluated, supplied as a string.
public  Listevaluate(String expression)
     Prepare and execute an XPath expression, supplied as a string, and returning the results as a List.
Parameters:
  expression - The XPath expression to be evaluated, supplied as a string.
public  Objectevaluate(String expr, Object node, QName qName)
     Single-shot method to compile and execute an XPath 2.0 expression.
Parameters:
  expr - The XPath 2.0 expression to be compiled and executed
Parameters:
  node - The context node for evaluation of the expression
Parameters:
  qName - The type of result required.
public  Stringevaluate(String expr, Object node)
     Single-shot method to compile an execute an XPath 2.0 expression, returning the result as a string.
public  Objectevaluate(String expr, InputSource inputSource, QName qName)
     Single-shot method to parse and build a source document, and compile an execute an XPath 2.0 expression, against that document
Parameters:
  expr - The XPath 2.0 expression to be compiled and executed
Parameters:
  inputSource - The source document: this will be parsed and built into a tree,and the XPath expression will be executed with the root node of the tree as thecontext node
Parameters:
  qName - The type of result required.
public  Stringevaluate(String expr, InputSource inputSource)
    
public  ObjectevaluateSingle(String expression)
     Prepare and execute an XPath expression, supplied as a string, and returning the first item in the result.
public  NamespaceContextgetNamespaceContext()
    
public  StandaloneContextgetStaticContext()
    
public  XPathFunctionResolvergetXPathFunctionResolver()
    
public  XPathVariableResolvergetXPathVariableResolver()
    
public  voidimportSchema(Source source)
     Import a schema.
public  booleanisBackwardsCompatible()
    
public static  voidmain(String[] args)
     A simple command-line interface for the XPathEvaluator (not documented).
public  voidreset()
    
public  voidsetBackwardsCompatible(boolean compatible)
    
public  voidsetContextNode(NodeInfo node)
     Set the context node.
public  voidsetNamespaceContext(NamespaceContext namespaceContext)
     Set the namespace context to be used.
public  NodeInfosetSource(Source source)
     Supply the document against which XPath expressions are to be executed.
public  voidsetStaticContext(StandaloneContext context)
     Set the static context for compiling XPath expressions.
public  voidsetStripSpace(boolean strip)
     Indicate whether all whitespace text nodes in the source document are to be removed.
public  voidsetXPathFunctionResolver(XPathFunctionResolver xPathFunctionResolver)
    
public  voidsetXPathVariableResolver(XPathVariableResolver xPathVariableResolver)
    


Constructor Detail
XPathEvaluator
public XPathEvaluator()(Code)
Default constructor. Creates an XPathEvaluator with a default configuration and name pool. The default Configuration is not schema-aware.



XPathEvaluator
public XPathEvaluator(Configuration config)(Code)
Construct an XPathEvaluator with a specified configuration.
Parameters:
  config - the configuration to be used. If schema-aware XPath expressions are to be used,this must be a SchemaAwareConfiguration.



XPathEvaluator
public XPathEvaluator(Source source) throws net.sf.saxon.trans.XPathException(Code)
Construct an XPathEvaluator to process a particular source document. This is equivalent to using the default constructor and immediately calling setSource().
Parameters:
  source - The source document (or a specific node within it).




Method Detail
compile
public XPathExpression compile(String expr) throws XPathExpressionException(Code)
Compile an XPath 2.0 expression
Parameters:
  expr - the XPath 2.0 expression to be compiled, as a string the compiled form of the expression
throws:
  XPathExpressionException - if there are any static errors in the expression.Note that references to undeclared variables are not treated as static errors, becausevariables are not pre-declared using this API.



createExpression
public XPathExpressionImpl createExpression(String expression) throws net.sf.saxon.trans.XPathException(Code)
Prepare an XPath expression for subsequent evaluation.
Parameters:
  expression - The XPath expression to be evaluated, supplied as a string. an XPathExpression object representing the prepared expression
throws:
  net.sf.saxon.trans.XPathException - if the syntax of the expression is wrong, or if it references namespaces,variables, or functions that have not been declared.



evaluate
public List evaluate(String expression) throws net.sf.saxon.trans.XPathException(Code)
Prepare and execute an XPath expression, supplied as a string, and returning the results as a List.
Parameters:
  expression - The XPath expression to be evaluated, supplied as a string. The results of the expression, as a List. The List represents the sequenceof items returned by the expression. Each item in the list will either be an objectrepresenting a node, or a Java object representing an atomic value.The types of Java object that may be included in the list, and the XML Schema data types that theycorrespond to, are as follows:

  • Boolean (xs:boolean)
  • String (xs:string)
  • BigDecimal (xs:decimal)
  • Long (xs:integer and its derived types)
  • Double (xs:double)
  • Float (xs:float)
  • Date (xs:date, xs:dateTime)



evaluate
public Object evaluate(String expr, Object node, QName qName) throws XPathExpressionException(Code)
Single-shot method to compile and execute an XPath 2.0 expression.
Parameters:
  expr - The XPath 2.0 expression to be compiled and executed
Parameters:
  node - The context node for evaluation of the expression
Parameters:
  qName - The type of result required. For details, seeXPathExpressionImpl.evaluate(Objectjavax.xml.namespace.QName) the result of evaluating the expression, returned as described inXPathExpressionImpl.evaluate(Objectjavax.xml.namespace.QName)
throws:
  XPathExpressionException - if any static or dynamic error occursin evaluating the expression.



evaluate
public String evaluate(String expr, Object node) throws XPathExpressionException(Code)
Single-shot method to compile an execute an XPath 2.0 expression, returning the result as a string.
Parameters:
  expr - The XPath 2.0 expression to be compiled and executed
Parameters:
  node - The context node for evaluation of the expression the result of evaluating the expression, converted to a string as ifby calling the XPath string() function
throws:
  XPathExpressionException - if any static or dynamic error occursin evaluating the expression.



evaluate
public Object evaluate(String expr, InputSource inputSource, QName qName) throws XPathExpressionException(Code)
Single-shot method to parse and build a source document, and compile an execute an XPath 2.0 expression, against that document
Parameters:
  expr - The XPath 2.0 expression to be compiled and executed
Parameters:
  inputSource - The source document: this will be parsed and built into a tree,and the XPath expression will be executed with the root node of the tree as thecontext node
Parameters:
  qName - The type of result required. For details, seeXPathExpressionImpl.evaluate(Objectjavax.xml.namespace.QName) the result of evaluating the expression, returned as described inXPathExpressionImpl.evaluate(Objectjavax.xml.namespace.QName)
throws:
  XPathExpressionException - if any static or dynamic error occursin evaluating the expression.



evaluate
public String evaluate(String expr, InputSource inputSource) throws XPathExpressionException(Code)
Single-shot method to parse and build a source document, and compile an execute an XPath 2.0 expression, against that document, returning the result as a string
Parameters:
  expr - The XPath 2.0 expression to be compiled and executed
Parameters:
  inputSource - The source document: this will be parsed and built into a tree,and the XPath expression will be executed with the root node of the tree as thecontext node the result of evaluating the expression, converted to a string asif by calling the XPath string() function
throws:
  XPathExpressionException - if any static or dynamic error occursin evaluating the expression.



evaluateSingle
public Object evaluateSingle(String expression) throws net.sf.saxon.trans.XPathException(Code)
Prepare and execute an XPath expression, supplied as a string, and returning the first item in the result. This is useful where it is known that the expression will only return a singleton value (for example, a single node, or a boolean).
Parameters:
  expression - The XPath expression to be evaluated, supplied as a string. The first item in the sequence returned by the expression. If the expressionreturns an empty sequence, this method returns null. Otherwise, it returns the firstitem in the result sequence, represented as a Java object using the same mapping as forthe evaluate() method



getNamespaceContext
public NamespaceContext getNamespaceContext()(Code)
Get the namespace context, if one has been set using XPathEvaluator.setNamespaceContext the namespace context if set, or null otherwise



getStaticContext
public StandaloneContext getStaticContext()(Code)
Get the current static context



getXPathFunctionResolver
public XPathFunctionResolver getXPathFunctionResolver()(Code)
Get the resolver for XPath functions the resolver, if one has been set



getXPathVariableResolver
public XPathVariableResolver getXPathVariableResolver()(Code)
Get the resolver for XPath variables the resolver, if one has been set



importSchema
public void importSchema(Source source) throws SchemaException(Code)
Import a schema. This is possible only if the schema-aware version of Saxon is being used, and if the Configuration is a SchemaAwareConfiguration. Having imported a schema, the types defined in that schema become part of the static context.
Parameters:
  source - A Source object identifying the schema document to be loaded
throws:
  net.sf.saxon.type.SchemaException - if the schema contained in this document is invalid
throws:
  UnsupportedOperationException - if the configuration is not schema-aware



isBackwardsCompatible
public boolean isBackwardsCompatible()(Code)
Get the value of XPath 1.0 compatibility mode true if XPath 1.0 compatibility mode is set



main
public static void main(String[] args) throws Exception(Code)
A simple command-line interface for the XPathEvaluator (not documented). First parameter is the filename containing the source document, second parameter is the XPath expression.



reset
public void reset()(Code)



setBackwardsCompatible
public void setBackwardsCompatible(boolean compatible)(Code)
Set XPath 1.0 compatibility mode on or off (by default, it is false)
Parameters:
  compatible - true if XPath 1.0 compatibility mode is to be set to true, falseif it is to be set to false.



setContextNode
public void setContextNode(NodeInfo node)(Code)
Set the context node. This provides the context node for any expressions executed after this method is called, including expressions that were prepared before it was called.
Parameters:
  node - The node to be used as the context node. This mustbe a node within the context document (the document supplied using the setSource() method).
throws:
  NullPointerException - if the argument is null
throws:
  IllegalArgumentException - if the supplied node is not a node in the context document



setNamespaceContext
public void setNamespaceContext(NamespaceContext namespaceContext)(Code)
Set the namespace context to be used. This supplements any namespaces declared directly using declareNamespace on the staticContext object
Parameters:
  namespaceContext - The namespace context



setSource
public NodeInfo setSource(Source source) throws net.sf.saxon.trans.XPathException(Code)
Supply the document against which XPath expressions are to be executed. This method must be called before preparing or executing an XPath expression. Setting a new source document clears all the namespaces that have been declared.
Parameters:
  source - Any javax.xml.transform.Source object representing the document againstwhich XPath expressions will be executed. Note that a Saxon net.sf.saxon.om.DocumentInfo DocumentInfo(indeed any net.sf.saxon.om.NodeInfo NodeInfo)can be used as a Source. To use a third-party DOM Document as a source, create an instance ofjavax.xml.transform.dom.DOMSource DOMSource to wrap it.

The Source object supplied also determines the initial settingof the context item. In most cases the context node will be the root of the supplied document;however, if a NodeInfo or DOMSource is supplied it can be any node in the document.

the NodeInfo of the start node in the resulting document object.



setStaticContext
public void setStaticContext(StandaloneContext context)(Code)
Set the static context for compiling XPath expressions. This provides control over the environment in which the expression is compiled, for example it allows namespace prefixes to be declared, variables to be bound and functions to be defined. For most purposes, the static context can be defined by providing and tailoring an instance of the StandaloneContext class. Until this method is called, a default static context is used, in which no namespaces are defined other than the standard ones (xml, xslt, and saxon), and no variables or functions (other than the core XPath functions) are available.



setStripSpace
public void setStripSpace(boolean strip)(Code)
Indicate whether all whitespace text nodes in the source document are to be removed. This option has no effect unless it is called before the call on setSource(), and unless the Source supplied to setSource() is a SAXSource or StreamSource.
Parameters:
  strip - True if all whitespace text nodes are to be stripped from the source document,false otherwise. The default if the method is not called is false.



setXPathFunctionResolver
public void setXPathFunctionResolver(XPathFunctionResolver xPathFunctionResolver)(Code)
Set the resolver for XPath functions
Parameters:
  xPathFunctionResolver -



setXPathVariableResolver
public void setXPathVariableResolver(XPathVariableResolver xPathVariableResolver)(Code)
Set the resolver for XPath variables
Parameters:
  xPathVariableResolver -



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.