javax.xml.xpath
Interface XPath
public interface XPath
XPath
provides access to the XPath evaluation environment and expressions.
Evaluation of XPath Expressions.
|
---|
context
|
If a request is made to evaluate the expression in the absence of a context item, an empty document node will be used for the context. For the purposes of evaluating XPath expressions, a DocumentFragment is treated like a Document node.
|
variables
|
If the expression contains a variable reference, its value will be found through the XPathVariableResolver
set with
setXPathVariableResolver(XPathVariableResolver resolver)
. An
XPathExpressionException
is raised if the variable resolver is undefined or the resolver returns null
for the variable. The value of a variable must be immutable through the course of any single evaluation.
An XPath object is not thread-safe and not reentrant. In other words, it is the application's responsibility to make sure that one
XPath
object is not used from more than one thread at any given time, and while the evaluate
method is invoked, applications may not recursively call the evaluate
method.
Since:
1.5
Version:
$Revision: 1.2 $, $Date: 2008/01/24 18:12:22 $
Author:
Norman Walsh
, Jeff Suttor
See Also:
XML Path Language (XPath) Version 1.0
|
javax.xml.xpath
Interface XPath
public interface XPath
XPath provides access to the XPath evaluation environment and expressions.
Evaluation of XPath Expressions.
|
---|
context
|
If a request is made to evaluate the expression in the absence
of a context item, an empty document node will be used for the context.
For the purposes of evaluating XPath expressions, a DocumentFragment
is treated like a Document node.
| variables
|
If the expression contains a variable reference, its value will be found through the XPathVariableResolver
set with setXPathVariableResolver(XPathVariableResolver resolver) .
An XPathExpressionException is raised if the variable resolver is undefined or
the resolver returns null for the variable.
The value of a variable must be immutable through the course of any single evaluation.
| functions
|
If the expression contains a function reference, the function will be found through the XPathFunctionResolver
set with setXPathFunctionResolver(XPathFunctionResolver resolver) .
An XPathExpressionException is raised if the function resolver is undefined or
the function resolver returns null for the function.
| QNames
|
QNames in the expression are resolved against the XPath namespace context
set with setNamespaceContext(NamespaceContext nsContext) .
| result
|
This result of evaluating an expression is converted to an instance of the desired return type.
Valid return types are defined in XPathConstants .
Conversion to the return type follows XPath conversion rules.
|
Since:
1.5
Version:
$Revision: 1.2 $, $Date: 2008/01/24 18:12:22 $
Author:
Norman Walsh, Jeff Suttor
See Also:
XML Path Language (XPath) Version 1.0
|
javax.xml.xpath
Interface XPath
public interface XPath
XPath provides access to the XPath evaluation environment and expressions.
Evaluation of XPath Expressions.
|
---|
context
|
If a request is made to evaluate the expression in the absence
of a context item, an empty document node will be used for the context.
For the purposes of evaluating XPath expressions, a DocumentFragment
is treated like a Document node.
| variables
|
If the expression contains a variable reference, its value will be found through the XPathVariableResolver
set with setXPathVariableResolver(XPathVariableResolver resolver) .
An XPathExpressionException is raised if the variable resolver is undefined or
the resolver returns null for the variable.
The value of a variable must be immutable through the course of any single evaluation.
| functions
|
If the expression contains a function reference, the function will be found through the XPathFunctionResolver
set with setXPathFunctionResolver(XPathFunctionResolver resolver) .
An XPathExpressionException is raised if the function resolver is undefined or
the function resolver returns null for the function.
| QNames
|
QNames in the expression are resolved against the XPath namespace context
set with setNamespaceContext(NamespaceContext nsContext) .
| result
|
This result of evaluating an expression is converted to an instance of the desired return type.
Valid return types are defined in XPathConstants .
Conversion to the return type follows XPath conversion rules.
|
An XPath object is not thread-safe and not reentrant.
In other words, it is the application's responsibility to make
sure that one XPath object is not used from
more than one thread at any given time, and while the evaluate
method is invoked, applications may not recursively call
the evaluate method.
Since:
1.5
Version:
$Revision: 1.2 $, $Date: 2008/01/24 18:12:22 $
Author:
Norman Walsh, Jeff Suttor
See Also:
XML Path Language (XPath) Version 1.0
|
XPath.compile(java.lang.String)
compile
XPathExpression compile(java.lang.String expression)
throws XPathExpressionException
Compile an XPath expression for later evaluation.
If expression
contains any XPathFunction
s, they must be available via the XPathFunctionResolver. An XPathExpressionException
will be thrown if the XPathFunction
cannot be resovled with the XPathFunctionResolver.
If expression
contains any variables, the
XPathVariableResolver
in effect
at compile time
will be used to resolve them.
If expression
is null
, a NullPointerException
is thrown.
Parameters:
expression
- The XPath expression.
Returns:
Compiled XPath expression.
Throws:
XPathExpressionException
- If expression
cannot be compiled.
java.lang.NullPointerException
- If expression
is null.
|
compile
XPathExpression compile(java.lang.String expression)
throws XPathExpressionException
Compile an XPath expression for later evaluation.
If expression contains any XPathFunction s,
they must be available via the XPathFunctionResolver .
An XPathExpressionException will be thrown if the XPathFunction
cannot be resovled with the XPathFunctionResolver.
If expression is null, a NullPointerException is thrown.
Parameters:
expression - The XPath expression.
Returns:
Compiled XPath expression.
Throws:
XPathExpressionException - If expression cannot be compiled.
java.lang.NullPointerException - If expression is null.
|
compile
XPathExpression compile(java.lang.String expression)
throws XPathExpressionException
Compile an XPath expression for later evaluation.
If expression contains any XPathFunction s,
they must be available via the XPathFunctionResolver .
An XPathExpressionException will be thrown if the
XPathFunction
cannot be resovled with the XPathFunctionResolver.
If expression contains any variables, the
XPathVariableResolver in effect
at compile time will be used to resolve them.
If expression is null, a NullPointerException is thrown.
Parameters:
expression - The XPath expression.
Returns:
Compiled XPath expression.
Throws:
XPathExpressionException - If expression cannot be compiled.
java.lang.NullPointerException - If expression is null.
|
XPath.evaluate(java.lang.String, java.lang.Object)
evaluate
java.lang.String evaluate(java.lang.String expression,
java.lang.Object item)
throws XPathExpressionException
Evaluate an XPath expression in the specified context and return the result as a String.
This method calls evaluate(String expression, Object item, QName returnType)
with a returnType
of XPathConstants.STRING.
See Evaluation of XPath Expressions
for context item evaluation, variable, function and QName resolution and return type conversion.
If a null
value is provided for item
, an empty document will be used for the context. If expression
is null
, then a NullPointerException
is thrown.
Parameters:
expression
- The XPath expression.
item
- The starting context (a node, (node or node list, for example).
Returns:
The String
that is the result of evaluating the expression and converting the result to a String.
Throws:
XPathExpressionException
- If expression
cannot be evaluated.
java.lang.NullPointerException
- If expression
is null.
|
evaluate
java.lang.String evaluate(java.lang.String expression,
java.lang.Object item)
throws XPathExpressionException
Evaluate an XPath expression in the specified context and return the result as a String.
This method calls evaluate(String expression, Object item, QName returnType) with a returnType of
XPathConstants.STRING .
See Evaluation of XPath Expressions for context item evaluation,
variable, function and QName resolution and return type conversion.
If a null value is provided for
item, an empty document will be used for the
context.
If expression is null, then a NullPointerException is thrown.
Parameters:
expression - The XPath expression.
item - The starting context (node or node list, for example).
Returns:
The String that is the result of evaluating the expression and
converting the result to a String.
Throws:
XPathExpressionException - If expression cannot be evaluated.
java.lang.NullPointerException - If expression is null.
|
evaluate
java.lang.String evaluate(java.lang.String expression,
java.lang.Object item)
throws XPathExpressionException
Evaluate an XPath expression in the specified context and return the result as a String.
This method calls evaluate(String expression, Object item, QName returnType) with a returnType of
XPathConstants.STRING .
See Evaluation of XPath Expressions for context item evaluation,
variable, function and QName resolution and return type conversion.
If a null value is provided for
item, an empty document will be used for the
context.
If expression is null, then a NullPointerException is thrown.
Parameters:
expression - The XPath expression.
item - The starting context (a node, for example).
Returns:
The String that is the result of evaluating the expression and
converting the result to a String.
Throws:
XPathExpressionException - If expression cannot be evaluated.
java.lang.NullPointerException - If expression is null.
|
XPath.evaluate(java.lang.String, java.lang.Object, javax.xml.namespace.QName)
evaluate
java.lang.Object evaluate(java.lang.String expression,
java.lang.Object item,
QName returnType)
throws XPathExpressionException
Evaluate an XPath
expression in the specified context and return the result as the specified type.
See Evaluation of XPath Expressions
for context item evaluation, variable, function and QName
resolution and return type conversion.
If returnType
is not one of the types defined in XPathConstants
( NUMBER
, STRING
, BOOLEAN
, NODE
or NODESET
) then an IllegalArgumentException
is thrown.
If a null
value is provided for item
, an empty document will be used for the context. If expression
or returnType
is null
, then a NullPointerException
is thrown.
Parameters:
expression
- The XPath expression.
item
- The starting context (a node, (node or node list, for example).
returnType
- The desired return type.
Returns:
Result of evaluating an XPath expression as an Object
of returnType.
Throws:
XPathExpressionException
- If expression
cannot be evaluated.
java.lang.IllegalArgumentException
- If returnType
is not one of the types defined in XPathConstants.
java.lang.NullPointerException
- If expression
or returnType
is null.
|
evaluate
java.lang.Object evaluate(java.lang.String expression,
java.lang.Object item,
QName returnType)
throws XPathExpressionException
Evaluate an XPath expression in the specified context and return the result as the specified type.
See Evaluation of XPath Expressions for context item evaluation,
variable, function and QName resolution and return type conversion.
If returnType is not one of the types defined in XPathConstants (
NUMBER ,
STRING ,
BOOLEAN ,
NODE or
NODESET )
then an IllegalArgumentException is thrown.
If a null value is provided for
item, an empty document will be used for the
context.
If expression or returnType is null, then a
NullPointerException is thrown.
Parameters:
expression - The XPath expression.
item - The starting context (node or node list, for example).
returnType - The desired return type.
Returns:
Result of evaluating an XPath expression as an Object of returnType.
Throws:
XPathExpressionException - If expression cannot be evaluated.
java.lang.IllegalArgumentException - If returnType is not one of the types defined in XPathConstants .
java.lang.NullPointerException - If expression or returnType is null.
|
evaluate
java.lang.Object evaluate(java.lang.String expression,
java.lang.Object item,
QName returnType)
throws XPathExpressionException
Evaluate an XPath expression in the specified context and return the result as the specified type.
See Evaluation of XPath Expressions for context item evaluation,
variable, function and QName resolution and return type conversion.
If returnType is not one of the types defined in XPathConstants (
NUMBER ,
STRING ,
BOOLEAN ,
NODE or
NODESET )
then an IllegalArgumentException is thrown.
If a null value is provided for
item, an empty document will be used for the
context.
If expression or returnType is null, then a
NullPointerException is thrown.
Parameters:
expression - The XPath expression.
item - The starting context (a node, for example).
returnType - The desired return type.
Returns:
Result of evaluating an XPath expression as an Object of returnType.
Throws:
XPathExpressionException - If expression cannot be evaluated.
java.lang.IllegalArgumentException - If returnType is not one of the types defined in XPathConstants .
java.lang.NullPointerException - If expression or returnType is null.
|
javax.xml.xpath.XPathException (5 methods)
XPathException(java.lang.String) getCause() printStackTrace() printStackTrace(java.io.PrintStream) printStackTrace(java.io.PrintWriter)
XPathException.XPathException(java.lang.String)
XPathException
public XPathException(java.lang.String message)
Constructs a new XPathException
with the specified detail message.
The cause
is not initialized.
If message
is null
, then a NullPointerException
is thrown.
Parameters:
message
- The detail message.
Throws:
java.lang.NullPointerException
- When message
is null.
|
XPathException
public XPathException(java.lang.String message)
Constructs a new XPathException with the specified detail message.
The cause is not initialized.
If message is null, then a NullPointerException is thrown.
Parameters:
message - The detail message.
|
XPathException
public XPathException(java.lang.String message)
Constructs a new XPathException
with the specified detail message.
The cause is not initialized.
If message is null,
then a NullPointerException is thrown.
Parameters:
message - The detail message.
Throws:
java.lang.NullPointerException - When message is
null.
|
XPathException.getCause()
getCause
public java.lang.Throwable getCause()
Get the cause of this XPathException.
Overrides:
getCause
in class java.lang.Throwable
Returns:
Cause of this XPathException.
|
getCause
public java.lang.Throwable getCause()
Overrides:
getCause in class java.lang.Throwable
|
getCause
public java.lang.Throwable getCause()
Get the cause of this XPathException.
Overrides:
getCause in class java.lang.Throwable
Returns:
Cause of this XPathException.
|
XPathException.printStackTrace()
printStackTrace
public void printStackTrace()
Print stack trace to System.err.
Overrides:
printStackTrace
in class java.lang.Throwable
|
printStackTrace
public void printStackTrace()
Overrides:
printStackTrace in class java.lang.Throwable
|
printStackTrace
public void printStackTrace()
Print stack trace to System.err.
Overrides:
printStackTrace in class java.lang.Throwable
|
XPathException.printStackTrace(java.io.PrintStream)
printStackTrace
public void printStackTrace(java.io.PrintStream s)
Print stack trace to specified PrintStream.
Overrides:
printStackTrace
in class java.lang.Throwable
Parameters:
s
- Print stack trace to this PrintStream.
|
printStackTrace
public void printStackTrace(java.io.PrintStream s)
Overrides:
printStackTrace in class java.lang.Throwable
|
printStackTrace
public void printStackTrace(java.io.PrintStream s)
Print stack trace to specified PrintStream.
Overrides:
printStackTrace in class java.lang.Throwable
Parameters:
s - Print stack trace to this PrintStream.
|
XPathException.printStackTrace(java.io.PrintWriter)
printStackTrace
public void printStackTrace(java.io.PrintWriter s)
Print stack trace to specified PrintWriter.
Overrides:
printStackTrace
in class java.lang.Throwable
Parameters:
s
- Print stack trace to this PrintWriter.
|
printStackTrace
public void printStackTrace(java.io.PrintWriter s)
Overrides:
printStackTrace in class java.lang.Throwable
|
printStackTrace
public void printStackTrace(java.io.PrintWriter s)
Print stack trace to specified PrintWriter.
Overrides:
printStackTrace in class java.lang.Throwable
Parameters:
s - Print stack trace to this PrintWriter.
|
javax.xml.xpath.XPathExpression (2 methods)
CLASS_COMMENT evaluate(java.lang.Object) evaluate(java.lang.Object, javax.xml.namespace.QName)
XPathExpression.CLASS_COMMENT
javax.xml.xpath
Interface XPathExpression
public interface XPathExpression
XPathExpression
provides access to compiled XPath expressions.
Evaluation of XPath Expressions.
|
---|
context
|
If a request is made to evaluate the expression in the absence of a context item, an empty document node will be used for the context. For the purposes of evaluating XPath expressions, a DocumentFragment is treated like a Document node.
|
variables
|
If the expression contains a variable reference, its value will be found through the XPathVariableResolver
. An
XPathExpressionException
is raised if the variable resolver is undefined or the resolver returns null
for the variable. The value of a variable must be immutable through the course of any single evaluation.
Evaluation of XPath Expressions.
|
---|
context
|
If a request is made to evaluate the expression in the absence of a context item, an empty document node will be used for the context. For the purposes of evaluating XPath expressions, a DocumentFragment is treated like a Document node.
|
functions variables
|
If the expression contains a function variable reference, the function its value will be found through the
XPathFunctionResolver
XPathVariableResolver. An XPathExpressionException
is raised if the function resolver is undefined or the function resolver returns null
for the function. variable.
|
QNames
|
functions
|
If the expression contains a function reference, the function will be found through the
XPathFunctionResolver
. An
XPathExpressionException
null
for the function.
|
QNames
|
QNames in the expression are resolved against the XPath namespace context.
|
QNames in the expression are resolved against the XPath namespace context.
|
result
|
This result of evaluating an expression is converted to an instance of the desired return type. Valid return types are defined in XPathConstants. Conversion to the return type follows XPath conversion rules.
|
An XPath expression is not thread-safe and not reentrant. In other words, it is the application's responsibility to make sure that one
XPathExpression
object is not used from more than one thread at any given time, and while the evaluate
method is invoked, applications may not recursively call the evaluate
method.
Since:
1.5
Version:
$Revision: 1.2 $, $Date: 2008/01/24 18:12:22 $
Author:
Norman Walsh
, Jeff Suttor
See Also:
XML Path Language (XPath) Version 1.0, Expressions
|
javax.xml.xpath
Interface XPathExpression
public interface XPathExpression
XPathExpression provides access to compiled XPath expressions.
Evaluation of XPath Expressions.
|
---|
context
|
If a request is made to evaluate the expression in the absence
of a context item, an empty document node will be used for the context.
For the purposes of evaluating XPath expressions, a DocumentFragment
is treated like a Document node.
| variables
|
If the expression contains a variable reference, its value will be found through the XPathVariableResolver .
An XPathExpressionException is raised if the variable resolver is undefined or
the resolver returns null for the variable.
The value of a variable must be immutable through the course of any single evaluation.
| functions
|
If the expression contains a function reference, the function will be found through the XPathFunctionResolver .
An XPathExpressionException is raised if the function resolver is undefined or
the function resolver returns null for the function.
| QNames
|
QNames in the expression are resolved against the XPath namespace context.
| result
|
This result of evaluating an expression is converted to an instance of the desired return type.
Valid return types are defined in XPathConstants .
Conversion to the return type follows XPath conversion rules.
|
Since:
1.5
Version:
$Revision: 1.2 $, $Date: 2008/01/24 18:12:22 $
Author:
Norman Walsh, Jeff Suttor
See Also:
XML Path Language (XPath) Version 1.0, Expressions
|
javax.xml.xpath
Interface XPathExpression
public interface XPathExpression
XPathExpression provides access to compiled XPath expressions.
Evaluation of XPath Expressions.
|
---|
context
|
If a request is made to evaluate the expression in the absence
of a context item, an empty document node will be used for the context.
For the purposes of evaluating XPath expressions, a DocumentFragment
is treated like a Document node.
| variables
|
If the expression contains a variable reference, its value will be found through the XPathVariableResolver .
An XPathExpressionException is raised if the variable resolver is undefined or
the resolver returns null for the variable.
The value of a variable must be immutable through the course of any single evaluation.
| functions
|
If the expression contains a function reference, the function will be found through the XPathFunctionResolver .
An XPathExpressionException is raised if the function resolver is undefined or
the function resolver returns null for the function.
| QNames
|
QNames in the expression are resolved against the XPath namespace context.
| result
|
This result of evaluating an expression is converted to an instance of the desired return type.
Valid return types are defined in XPathConstants .
Conversion to the return type follows XPath conversion rules.
|
An XPath expression is not thread-safe and not reentrant.
In other words, it is the application's responsibility to make
sure that one XPathExpression object is not used from
more than one thread at any given time, and while the evaluate
method is invoked, applications may not recursively call
the evaluate method.
Since:
1.5
Version:
$Revision: 1.2 $, $Date: 2008/01/24 18:12:22 $
Author:
Norman Walsh, Jeff Suttor
See Also:
XML Path Language (XPath) Version 1.0, Expressions
|
XPathExpression.evaluate(java.lang.Object)
evaluate
java.lang.String evaluate(java.lang.Object item)
throws XPathExpressionException
Evaluate the compiled XPath expression in the specified context and return the result as a String.
This method calls evaluate(Object item, QName returnType)
with a returnType
of XPathConstants.STRING.
See Evaluation of XPath Expressions
for context item evaluation, variable, function and QName resolution and return type conversion.
If a null
value is provided for item
, an empty document will be used for the context.
Parameters:
item
- The starting context (a node, (node or node list, for example).
Returns:
The String
that is the result of evaluating the expression and converting the result to a String.
Throws:
XPathExpressionException
- If the expression cannot be evaluated.
|
evaluate
java.lang.String evaluate(java.lang.Object item)
throws XPathExpressionException
Evaluate the compiled XPath expression in the specified context and return the result as a String.
This method calls evaluate(Object item, QName returnType) with a returnType of
XPathConstants.STRING .
See Evaluation of XPath Expressions for context item evaluation,
variable, function and QName resolution and return type conversion.
If a null value is provided for
item, an empty document will be used for the
context.
Parameters:
item - The starting context (node or node list, for example).
Returns:
The String that is the result of evaluating the expression and converting the result to a
String.
Throws:
XPathExpressionException - If the expression cannot be evaluated.
|
evaluate
java.lang.String evaluate(java.lang.Object item)
throws XPathExpressionException
Evaluate the compiled XPath expression in the specified context and return the result as a String.
This method calls evaluate(Object item, QName returnType) with a returnType of
XPathConstants.STRING .
See Evaluation of XPath Expressions for context item evaluation,
variable, function and QName resolution and return type conversion.
If a null value is provided for
item, an empty document will be used for the
context.
Parameters:
item - The starting context (a node, for example).
Returns:
The String that is the result of evaluating the expression and converting the result to a
String.
Throws:
XPathExpressionException - If the expression cannot be evaluated.
|
XPathExpression.evaluate(java.lang.Object, javax.xml.namespace.QName)
evaluate
java.lang.Object evaluate(java.lang.Object item,
QName returnType)
throws XPathExpressionException
Evaluate the compiled XPath expression in the specified context and return the result as the specified type.
See Evaluation of XPath Expressions
for context item evaluation, variable, function and QName resolution and return type conversion.
If returnType
is not one of the types defined in XPathConstants
, then an IllegalArgumentException
is thrown.
If a null
value is provided for item
, an empty document will be used for the context. If returnType
is null
, then a NullPointerException
is thrown.
Parameters:
item
- The starting context (a node, (node or node list, for example).
returnType
- The desired return type.
Returns:
The Object
that is the result of evaluating the expression and converting the result to returnType.
Throws:
XPathExpressionException
- If the expression cannot be evaluated.
java.lang.IllegalArgumentException
- If returnType
is not one of the types defined in XPathConstants.
java.lang.NullPointerException
- If returnType
is null.
|
evaluate
java.lang.Object evaluate(java.lang.Object item,
QName returnType)
throws XPathExpressionException
Evaluate the compiled XPath expression in the specified context and return the result as the specified type.
See Evaluation of XPath Expressions for context item evaluation,
variable, function and QName resolution and return type conversion.
If returnType is not one of the types defined in XPathConstants ,
then an IllegalArgumentException is thrown.
If a null value is provided for
item, an empty document will be used for the
context.
If returnType is null, then a NullPointerException is thrown.
Parameters:
item - The starting context (node or node list, for example).
returnType - The desired return type.
Returns:
The Object that is the result of evaluating the expression and converting the result to
returnType.
Throws:
XPathExpressionException - If the expression cannot be evaluated.
java.lang.IllegalArgumentException - If returnType is not one of the types defined in XPathConstants .
java.lang.NullPointerException - If returnType is null.
|
evaluate
java.lang.Object evaluate(java.lang.Object item,
QName returnType)
throws XPathExpressionException
Evaluate the compiled XPath expression in the specified context and return the result as the specified type.
See Evaluation of XPath Expressions for context item evaluation,
variable, function and QName resolution and return type conversion.
If returnType is not one of the types defined in XPathConstants ,
then an IllegalArgumentException is thrown.
If a null value is provided for
item, an empty document will be used for the
context.
If returnType is null, then a NullPointerException is thrown.
Parameters:
item - The starting context (a node, for example).
returnType - The desired return type.
Returns:
The Object that is the result of evaluating the expression and converting the result to
returnType.
Throws:
XPathExpressionException - If the expression cannot be evaluated.
java.lang.IllegalArgumentException - If returnType is not one of the types defined in XPathConstants .
java.lang.NullPointerException - If returnType is null.
|
javax.xml.xpath.XPathExpressionException (1 method)
XPathExpressionException.XPathExpressionException(java.lang.String)
XPathExpressionException
public XPathExpressionException(java.lang.String message)
Constructs a new XPathExpressionException
with the specified detail message.
The cause
is not initialized.
If message
is null
, then a NullPointerException
is thrown.
Parameters:
message
- The detail message.
Throws:
java.lang.NullPointerException
- When message
is null.
|
XPathExpressionException
public XPathExpressionException(java.lang.String message)
Constructs a new XPathExpressionException with the specified detail message.
The cause is not initialized.
If message is null, then a NullPointerException is thrown.
Parameters:
message - The detail message.
|
XPathExpressionException
public XPathExpressionException(java.lang.String message)
Constructs a new XPathExpressionException
with the specified detail message.
The cause is not initialized.
If message is null,
then a NullPointerException is thrown.
Parameters:
message - The detail message.
Throws:
java.lang.NullPointerException - When message is
null.
|
javax.xml.xpath.XPathFactory (4 methods)
CLASS_COMMENT XPathFactory() newInstance() newInstance(java.lang.String) newInstance(java.lang.String, java.lang.String, java.lang.ClassLoader)
XPathFactory.CLASS_COMMENT
javax.xml.xpath
Class XPathFactory
java.lang.Object
javax.xml.xpath.XPathFactory
public abstract class XPathFactory
extends java.lang.Object
An
XPathFactory
instance can be used to create XPath
objects.
See newInstance(String uri)
for lookup mechanism.
The
XPathFactory
class is not thread-safe. In other words, it is the application's responsibility to ensure that at most one thread is using a
XPathFactory
object at any given moment. Implementations are encouraged to mark methods as synchronized
to protect themselves from broken clients.
XPathFactory
is not re-entrant. While one of the newInstance
methods is being invoked, applications may not attempt to recursively invoke a newInstance
method, even from the same thread.
Since:
1.5
Version:
$Revision: 1.2 $, $Date: 2008/01/24 18:12:22 $
Author:
Norman Walsh
, Jeff Suttor
|
javax.xml.xpath
Class XPathFactory
java.lang.Object
javax.xml.xpath.XPathFactory
public abstract class XPathFactory
extends java.lang.Object
An XPathFactory instance can be used to create
XPath objects.
See newInstance(String uri) for lookup mechanism.
Since:
1.5
Version:
$Revision: 1.2 $, $Date: 2008/01/24 18:12:22 $
Author:
Norman Walsh, Jeff Suttor
|
javax.xml.xpath
Class XPathFactory
java.lang.Object
javax.xml.xpath.XPathFactory
public abstract class XPathFactory
extends java.lang.Object
An XPathFactory instance can be used to create
XPath objects.
See newInstance(String uri) for lookup mechanism.
The XPathFactory class is not thread-safe. In other words,
it is the application's responsibility to ensure that at most
one thread is using a XPathFactory object at any
given moment. Implementations are encouraged to mark methods
as synchronized to protect themselves from broken clients.
XPathFactory is not re-entrant. While one of the
newInstance methods is being invoked, applications
may not attempt to recursively invoke a newInstance method,
even from the same thread.
Since:
1.5
Version:
$Revision: 1.2 $, $Date: 2008/01/24 18:12:22 $
Author:
Norman Walsh, Jeff Suttor
|
XPathFactory.XPathFactory()
XPathFactory.newInstance()
newInstance
public static final XPathFactory newInstance()
Get a new XPathFactory
instance using the default object model, DEFAULT_OBJECT_MODEL_URI
, the W3C DOM.
This method is functionally equivalent to:
newInstance(DEFAULT_OBJECT_MODEL_URI)
Since the implementation for the W3C DOM is always available, this method will never fail.
Returns:
Instance of an XPathFactory.
Throws:
java.lang.RuntimeException
- When there is a failure in creating an XPathFactory
for the default object model.
|
newInstance
public static final XPathFactory newInstance()
Get a new XPathFactory instance using the default object model,
DEFAULT_OBJECT_MODEL_URI ,
the W3C DOM.
This method is functionally equivalent to:
newInstance(DEFAULT_OBJECT_MODEL_URI)
Since the implementation for the W3C DOM is always available, this method will never fail.
Returns:
Instance of an XPathFactory.
|
newInstance
public static final XPathFactory newInstance()
Get a new XPathFactory instance using the default object model,
DEFAULT_OBJECT_MODEL_URI ,
the W3C DOM.
This method is functionally equivalent to:
newInstance(DEFAULT_OBJECT_MODEL_URI)
Since the implementation for the W3C DOM is always available, this method will never fail.
Returns:
Instance of an XPathFactory.
Throws:
java.lang.RuntimeException - When there is a failure in creating an
XPathFactory for the default object model.
|
XPathFactory.newInstance(java.lang.String)
newInstance
public static final XPathFactory newInstance(java.lang.String uri)
throws XPathFactoryConfigurationException
Get a new XPathFactory
instance using the specified object model.
To find a XPathFactory
object, this method looks the following places in the following order where "the class loader" refers to the context class loader:
If the system property DEFAULT_PROPERTY_NAME
+ ":uri" is present, where uri is the parameter to this method, then its value is read as a class name. The method will try to create a new instance of this class by using the class loader, and returns it if it is successfully created.
${java.home}/lib/jaxp.properties is read and the value associated with the key being the system property above is looked for. If present, the value is processed just like above.
The class loader is asked for service provider provider-configuration files matching javax.xml.xpath.XPathFactory
in the resource directory META-INF/services. See the JAR File Specification for file format and parsing rules. Each potential service provider is required to implement the method:
isObjectModelSupported(String objectModel)
The first service provider found in class loader order that supports the specified object model is returned.
Platform default XPathFactory
is located in a platform specific way. There must be a platform default XPathFactory for the W3C DOM, i.e. DEFAULT_OBJECT_MODEL_URI.
If everything fails, an XPathFactoryConfigurationException
will be thrown.
Tip for Trouble-shooting:
See Properties.load(java.io.InputStream)
for exactly how a property file is parsed. In particular, colons ':' need to be escaped in a property file, so make sure the URIs are properly escaped in it. For example:
http\://java.sun.com/jaxp/xpath/dom=org.acme.DomXPathFactory
Parameters:
uri
- Identifies the underlying object model. The specification only defines the URI DEFAULT_OBJECT_MODEL_URI
, http://java.sun.com/jaxp/xpath/dom
for the W3C DOM, the org.w3c.dom package, and implementations are free to introduce other URIs for other object models.
Returns:
Instance of an XPathFactory.
Throws:
XPathFactoryConfigurationException
- If the specified object model is unavailable.
java.lang.NullPointerException
- If uri
is null.
java.lang.IllegalArgumentException
- If uri
is null
or uri.length() == 0.
|
newInstance
public static final XPathFactory newInstance(java.lang.String uri)
throws XPathFactoryConfigurationException
Get a new XPathFactory instance using the specified object model.
To find a XPathFactory object,
this method looks the following places in the following order where "the class loader" refers to the context class loader:
If the system property DEFAULT_PROPERTY_NAME + ":uri" is present,
where uri is the parameter to this method, then its value is read as a class name.
The method will try to create a new instance of this class by using the class loader,
and returns it if it is successfully created.
${java.home}/lib/jaxp.properties is read and the value associated with the key being the system property above is looked for.
If present, the value is processed just like above.
The class loader is asked for service provider provider-configuration files matching javax.xml.xpath.XPathFactory
in the resource directory META-INF/services.
See the JAR File Specification for file format and parsing rules.
Each potential service provider is required to implement the method:
isObjectModelSupported(String objectModel)
The first service provider found in class loader order that supports the specified object model is returned.
Platform default XPathFactory is located in a platform specific way.
There must be a platform default XPathFactory for the W3C DOM, i.e. DEFAULT_OBJECT_MODEL_URI .
If everything fails, an XPathFactoryConfigurationException will be thrown.
Tip for Trouble-shooting:
See Properties.load(java.io.InputStream) for exactly how a property file is parsed.
In particular, colons ':' need to be escaped in a property file, so make sure the URIs are properly escaped in it.
For example:
http\://java.sun.com/jaxp/xpath/dom=org.acme.DomXPathFactory
Parameters:
uri - Identifies the underlying object model.
The specification only defines the URI DEFAULT_OBJECT_MODEL_URI ,
http://java.sun.com/jaxp/xpath/dom for the W3C DOM,
the org.w3c.dom package, and implementations are free to introduce other URIs for other object models.
Returns:
Instance of an XPathFactory.
Throws:
XPathFactoryConfigurationException - If the specified object model is unavailable.
java.lang.NullPointerException - If uri is null.
java.lang.IllegalArgumentException - If uri.length() == 0.
|
newInstance
public static final XPathFactory newInstance(java.lang.String uri)
throws XPathFactoryConfigurationException
Get a new XPathFactory instance using the specified object model.
To find a XPathFactory object,
this method looks the following places in the following order where "the class loader" refers to the context class loader:
If the system property DEFAULT_PROPERTY_NAME + ":uri" is present,
where uri is the parameter to this method, then its value is read as a class name.
The method will try to create a new instance of this class by using the class loader,
and returns it if it is successfully created.
${java.home}/lib/jaxp.properties is read and the value associated with the key being the system property above is looked for.
If present, the value is processed just like above.
The class loader is asked for service provider provider-configuration files matching javax.xml.xpath.XPathFactory
in the resource directory META-INF/services.
See the JAR File Specification for file format and parsing rules.
Each potential service provider is required to implement the method:
isObjectModelSupported(String objectModel)
The first service provider found in class loader order that supports the specified object model is returned.
Platform default XPathFactory is located in a platform specific way.
There must be a platform default XPathFactory for the W3C DOM, i.e. DEFAULT_OBJECT_MODEL_URI .
If everything fails, an XPathFactoryConfigurationException will be thrown.
Tip for Trouble-shooting:
See Properties.load(java.io.InputStream) for exactly how a property file is parsed.
In particular, colons ':' need to be escaped in a property file, so make sure the URIs are properly escaped in it.
For example:
http\://java.sun.com/jaxp/xpath/dom=org.acme.DomXPathFactory
Parameters:
uri - Identifies the underlying object model.
The specification only defines the URI DEFAULT_OBJECT_MODEL_URI ,
http://java.sun.com/jaxp/xpath/dom for the W3C DOM,
the org.w3c.dom package, and implementations are free to introduce other URIs for other object models.
Returns:
Instance of an XPathFactory.
Throws:
XPathFactoryConfigurationException - If the specified object model is unavailable.
java.lang.NullPointerException - If uri is null.
java.lang.IllegalArgumentException - If uri is null
or uri.length() == 0.
|
XPathFactory.newInstance(java.lang.String, java.lang.String, java.lang.ClassLoader) (New)
newInstance
public static XPathFactory newInstance(java.lang.String uri,
java.lang.String factoryClassName,
java.lang.ClassLoader classLoader)
throws XPathFactoryConfigurationException
Obtain a new instance of a XPathFactory from a factory class name. XPathFactory
is returned if specified factory class supports the specified object model.
This function is useful when there are multiple providers in the classpath.
It gives more control to the application as it can specify which provider
should be loaded.
Tip for Trouble-shooting
Setting the jaxp.debug system property will cause
this method to print a lot of debug messages
to System.err about what it is doing and where it is looking at.
If you have problems try:
java -Djaxp.debug=1 YourProgram ....
Parameters:
uri - Identifies the underlying object model. The specification only defines the URI
DEFAULT_OBJECT_MODEL_URI ,http://java.sun.com/jaxp/xpath/dom
for the W3C DOM, the org.w3c.dom package, and implementations are free to introduce
other URIs for other object models.
factoryClassName - fully qualified factory class name that provides implementation of javax.xml.xpath.XPathFactory.
classLoader - ClassLoader used to load the factory class. If null
current Thread's context classLoader is used to load the factory class.
Returns:
New instance of a XPathFactory
Throws:
XPathFactoryConfigurationException - if factoryClassName is null, or
the factory class cannot be loaded, instantiated
or the factory class does not support the object model specified
in the uri parameter.
java.lang.NullPointerException - If uri is null.
java.lang.IllegalArgumentException - If uri is null
or uri.length() == 0.
Since:
1.6
See Also:
newInstance() ,
newInstance(String uri)
|
javax.xml.xpath.XPathFactoryConfigurationException (1 method)
XPathFactoryConfigurationException.XPathFactoryConfigurationException(java.lang.String)
XPathFactoryConfigurationException
public XPathFactoryConfigurationException(java.lang.String message)
Constructs a new XPathFactoryConfigurationException
with the specified detail message.
The cause
is not initialized.
If message
is null
, then a NullPointerException
is thrown.
Parameters:
message
- The detail message.
Throws:
java.lang.NullPointerException
- When message
is null.
|
XPathFactoryConfigurationException
public XPathFactoryConfigurationException(java.lang.String message)
Constructs a new XPathFactoryConfigurationException with the specified detail message.
The cause is not initialized.
If message is null, then a NullPointerException is thrown.
Parameters:
message - The detail message.
|
XPathFactoryConfigurationException
public XPathFactoryConfigurationException(java.lang.String message)
Constructs a new XPathFactoryConfigurationException with the specified detail message.
The cause is not initialized.
If message is null,
then a NullPointerException is thrown.
Parameters:
message - The detail message.
Throws:
java.lang.NullPointerException - When message is
null.
|
javax.xml.xpath.XPathFunctionException (1 method)
XPathFunctionException.XPathFunctionException(java.lang.String)
XPathFunctionException
public XPathFunctionException(java.lang.String message)
Constructs a new XPathFunctionException
with the specified detail message.
The cause
is not initialized.
If message
is null
, then a NullPointerException
is thrown.
Parameters:
message
- The detail message.
Throws:
java.lang.NullPointerException
- When message
is null.
|
XPathFunctionException
public XPathFunctionException(java.lang.String message)
Constructs a new XPathFunctionException with the specified detail message.
The cause is not initialized.
If message is null, then a NullPointerException is thrown.
Parameters:
message - The detail message.
|
XPathFunctionException
public XPathFunctionException(java.lang.String message)
Constructs a new XPathFunctionException with the specified detail message.
The cause is not initialized.
If message is null,
then a NullPointerException is thrown.
Parameters:
message - The detail message.
Throws:
java.lang.NullPointerException - When message is
null.
|
javax.xml.xpath.XPathVariableResolver
XPathVariableResolver.CLASS_COMMENT
javax.xml.xpath
Interface XPathVariableResolver
public interface XPathVariableResolver
XPathVariableResolver
provides access to the set of user defined XPath variables.
The
XPathVariableResolver
and the XPath evaluator must adhere to a contract that cannot be directly enforced by the API. Although variables may be mutable, that is, an application may wish to evaluate the same XPath expression more than once with different variable values, in the course of evaluating any single XPath expression, a variable's value
must
not change. be immutable.
Since:
1.5
Version:
$Revision: 1.2 $, $Date: 2008/01/24 18:12:22 $
Author:
Norman Walsh
, Jeff Suttor
|
javax.xml.xpath
Interface XPathVariableResolver
public interface XPathVariableResolver
XPathVariableResolver provides access to the set of user defined XPath variables.
The XPathVariableResolver and the XPath evaluator must adhere to a contract that
cannot be directly enforced by the API. Although variables may be mutable,
that is, an application may wish to evaluate the same XPath expression more
than once with different variable values, in the course of evaluating any
single XPath expression, a variable's value must be immutable.
Since:
1.5
Version:
$Revision: 1.2 $, $Date: 2008/01/24 18:12:22 $
Author:
Norman Walsh, Jeff Suttor
|
javax.xml.xpath
Interface XPathVariableResolver
public interface XPathVariableResolver
XPathVariableResolver provides access to the set of user defined XPath variables.
The XPathVariableResolver and the XPath evaluator must adhere to a contract that
cannot be directly enforced by the API. Although variables may be mutable,
that is, an application may wish to evaluate the same XPath expression more
than once with different variable values, in the course of evaluating any
single XPath expression, a variable's value must
not change.
Since:
1.5
Version:
$Revision: 1.2 $, $Date: 2008/01/24 18:12:22 $
Author:
Norman Walsh, Jeff Suttor
|
javax.xml.xpath.package-summary
package-summary.PACKAGE_DESCRIPTION
Package javax.xml.xpath Description
This package provides an
object-model neutral
API for the evaluation of XPath expressions and access to the evaluation environment.
The following XML standards apply:
XPath Overview
The XPath language provides a simple, concise syntax for selecting nodes from an XML document. XPath also provides rules for converting a node in an XML document object model (DOM) tree to a boolean, double, or string value. XPath is a W3C-defined language and an official W3C recommendation; the W3C hosts the XML Path Language (XPath) Version 1.0 specification.
XPath started in life in 1999 as a supplement to the XSLT and XPointer languages, but has more recently become popular as a stand-alone language, as a single XPath expression can be used to replace many lines of DOM API code.
XPath Expressions
An XPath
expression
is composed of a
location path
and one or more optional
predicates
. Expressions may also include XPath variables.
The following is an example of a simple XPath expression:
/foo/bar
This example would select the <bar>
element in an XML document such as the following:
<foo>
<bar/>
</foo>
The expression
/foo/bar
is an example of a location path. While XPath location paths resemble Unix-style file system paths, an important distinction is that XPath expressions return
all
nodes that match the expression. Thus, all three <bar>
elements in the following document would be selected by the
/foo/bar
expression:
<foo>
<bar/>
<bar/>
<bar/>
</foo>
A special location path operator,
//
, selects nodes at any depth in an XML document. The following example selects all <bar>
elements regardless of their location in a document:
//bar
A wildcard operator, *, causes all element nodes to be selected. The following example selects all children elements of a <foo>
element:
/foo/*
In addition to element nodes, XPath location paths may also address attribute nodes, text nodes, comment nodes, and processing instruction nodes. The following table gives examples of location paths for each of these node types:
Location Path
|
Description
|
/foo/bar/
@id
|
Selects the attribute id
of the <bar>
element
|
/foo/bar/
text()
|
Selects the text nodes of the <bar>
element. No distinction is made between escaped and non-escaped character data.
|
/foo/bar/
comment()
|
Selects all comment nodes contained in the <bar>
element.
|
/foo/bar/
processing-instruction()
|
Selects all processing-instruction nodes contained in the <bar>
element.
|
Predicates allow for refining the nodes selected by an XPath location path. Predicates are of the form
[
expression
]
. The following example selects all <foo>
elements that contain an
include
attribute with the value of
true
:
//foo[@include='true']
Predicates may be appended to each other to further refine an expression, such as:
//foo[@include='true'][@mode='bar']
Using the XPath API
The following example demonstrates using the XPath API to select one or more nodes from an XML document:
XPath xpath = XPathFactory.newInstance().newXPath();
String expression = "/widgets/widget";
InputSource inputSource = new InputSource("widgets.xml");
NodeList NodeSet nodes = (NodeList) (NodeSet) xpath.evaluate(expression, inputSource, XPathConstants.NODESET);
XPath Expressions and Types
While XPath expressions select nodes in the XML document, the XPath API allows the selected nodes to be coalesced into one of the following other data types:
The desired return type is specified by a QName
parameter in method call used to evaluate the expression, which is either a call to
XPathExpression.evalute(...)
or to one of the
XPath.evaluate(...)
convenience methods. The allowed QName values are specified as constants in the XPathConstants
class; they are:
When a
Boolean
return type is requested,
Boolean.TRUE
is returned if one or more nodes were selected; otherwise,
Boolean.FALSE
is returned.
The
String
return type is a convenience for retrieving the character data from a text node, attribute node, comment node, or processing-instruction node. When used on an element node, the value of the child text nodes is returned.
The
Number
return type attempts to coalesce the text of a node to a
double
data type.
XPath Context
XPath location paths may be relative to a particular node in the document, known as the
context
. Consider the following XML document:
<widgets>
<widget>
<manufacturer/>
<dimensions/>
</widget>
</widgets>
The <widget>
element can be selected with the following XPath API code:
// parse the XML as a W3C Document
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document document = builder.parse(new File("/widgets.xml"));
XPath xpath = XPathFactory.newInstance().newXPath();
String expression = "/widgets/widget";
Node widgetNode = (Node) xpath.evaluate(expression, document, XPathConstants.NODE);
With a reference to the <widget>
element, a relative XPath expression can now written to select the <manufacturer>
child element:
XPath xpath = XPathFactory.newInstance().newXPath();
String expression = "manufacturer";
Node manufacturerNode = (Node) xpath.evaluate(expression, widgetNode, XPathConstants.NODE);
|
Package javax.xml.xpath Description
This package provides an object-model neutral API for the
evaluation of XPath expressions and access to the evaluation
environment.
The following XML standards apply:
XPath Overview
The XPath language provides a simple, concise syntax for selecting
nodes from an XML document. XPath also provides rules for converting a
node in an XML document object model (DOM) tree to a boolean, double,
or string value. XPath is a W3C-defined language and an official W3C
recommendation; the W3C hosts the XML Path Language (XPath) Version
1.0 specification.
XPath started in life in 1999 as a supplement to the XSLT and
XPointer languages, but has more recently become popular as a
stand-alone language, as a single XPath expression can be used to
replace many lines of DOM API code.
XPath Expressions
An XPath expression is composed of a location
path and one or more optional predicates. Expressions
may also include XPath variables.
The following is an example of a simple XPath expression:
/foo/bar
This example would select the <bar> element in
an XML document such as the following:
<foo>
<bar/>
</foo>
The expression /foo/bar is an example of a location
path. While XPath location paths resemble Unix-style file system
paths, an important distinction is that XPath expressions return
all nodes that match the expression. Thus, all three
<bar> elements in the following document would be
selected by the /foo/bar expression:
<foo>
<bar/>
<bar/>
<bar/>
</foo>
A special location path operator, //, selects nodes at
any depth in an XML document. The following example selects all
<bar> elements regardless of their location in a
document:
//bar
A wildcard operator, *, causes all element nodes to be selected.
The following example selects all children elements of a
<foo> element:
/foo/*
In addition to element nodes, XPath location paths may also address
attribute nodes, text nodes, comment nodes, and processing instruction
nodes. The following table gives examples of location paths for each
of these node types:
Location Path
| Description
|
/foo/bar/@id
| Selects the attribute id of the <bar> element
| /foo/bar/text()
| Selects the text nodes of the <bar> element. No
distinction is made between escaped and non-escaped character data.
| /foo/bar/comment()
| Selects all comment nodes contained in the <bar> element.
| /foo/bar/processing-instruction()
| Selects all processing-instruction nodes contained in the
<bar> element.
|
Predicates allow for refining the nodes selected by an XPath
location path. Predicates are of the form
[expression]. The following example selects all
<foo> elements that contain an include
attribute with the value of true:
//foo[@include='true']
Predicates may be appended to each other to further refine an
expression, such as:
//foo[@include='true'][@mode='bar']
Using the XPath API
The following example demonstrates using the XPath API to select one
or more nodes from an XML document:
XPath xpath = XPathFactory.newInstance().newXPath();
String expression = "/widgets/widget";
InputSource inputSource = new InputSource("widgets.xml");
NodeSet nodes = (NodeSet) xpath.evaluate(expression, inputSource, XPathConstants.NODESET);
XPath Expressions and Types
While XPath expressions select nodes in the XML document, the XPath
API allows the selected nodes to be coalesced into one of the
following other data types:
The desired return type is specified by a QName parameter in method call used to evaluate
the expression, which is either a call to
XPathExpression.evalute(...) or to one of the
XPath.evaluate(...) convenience methods. The allowed
QName values are specified as constants in the XPathConstants class; they are:
When a Boolean return type is requested,
Boolean.TRUE is returned if one or more nodes were
selected; otherwise, Boolean.FALSE is returned.
The String return type is a convenience for retrieving
the character data from a text node, attribute node, comment node, or
processing-instruction node. When used on an element node, the value
of the child text nodes is returned.
The Number return type attempts to coalesce the text
of a node to a double data type.
XPath Context
XPath location paths may be relative to a particular node in the
document, known as the context. Consider the following
XML document:
<widgets>
<widget>
<manufacturer/>
<dimensions/>
</widget>
</widgets>
The <widget> element can be selected with the
following XPath API code:
// parse the XML as a W3C Document
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document document = builder.parse(new File("/widgets.xml"));
XPath xpath = XPathFactory.newInstance().newXPath();
String expression = "/widgets/widget";
Node widgetNode = (Node) xpath.evaluate(expression, document, XPathConstants.NODE);
With a reference to the <widget> element, a
relative XPath expression can now written to select the
<manufacturer> child element:
XPath xpath = XPathFactory.newInstance().newXPath();
String expression = "manufacturer";
Node manufacturerNode = (Node) xpath.evaluate(expression, widgetNode, XPathConstants.NODE);
|
Package javax.xml.xpath Description
This package provides an object-model neutral API for the
evaluation of XPath expressions and access to the evaluation
environment.
The following XML standards apply:
XPath Overview
The XPath language provides a simple, concise syntax for selecting
nodes from an XML document. XPath also provides rules for converting a
node in an XML document object model (DOM) tree to a boolean, double,
or string value. XPath is a W3C-defined language and an official W3C
recommendation; the W3C hosts the XML Path Language (XPath) Version
1.0 specification.
XPath started in life in 1999 as a supplement to the XSLT and
XPointer languages, but has more recently become popular as a
stand-alone language, as a single XPath expression can be used to
replace many lines of DOM API code.
XPath Expressions
An XPath expression is composed of a location
path and one or more optional predicates. Expressions
may also include XPath variables.
The following is an example of a simple XPath expression:
/foo/bar
This example would select the <bar> element in
an XML document such as the following:
<foo>
<bar/>
</foo>
The expression /foo/bar is an example of a location
path. While XPath location paths resemble Unix-style file system
paths, an important distinction is that XPath expressions return
all nodes that match the expression. Thus, all three
<bar> elements in the following document would be
selected by the /foo/bar expression:
<foo>
<bar/>
<bar/>
<bar/>
</foo>
A special location path operator, //, selects nodes at
any depth in an XML document. The following example selects all
<bar> elements regardless of their location in a
document:
//bar
A wildcard operator, *, causes all element nodes to be selected.
The following example selects all children elements of a
<foo> element:
/foo/*
In addition to element nodes, XPath location paths may also address
attribute nodes, text nodes, comment nodes, and processing instruction
nodes. The following table gives examples of location paths for each
of these node types:
Location Path
| Description
|
/foo/bar/@id
| Selects the attribute id of the <bar> element
| /foo/bar/text()
| Selects the text nodes of the <bar> element. No
distinction is made between escaped and non-escaped character data.
| /foo/bar/comment()
| Selects all comment nodes contained in the <bar> element.
| /foo/bar/processing-instruction()
| Selects all processing-instruction nodes contained in the
<bar> element.
|
Predicates allow for refining the nodes selected by an XPath
location path. Predicates are of the form
[expression]. The following example selects all
<foo> elements that contain an include
attribute with the value of true:
//foo[@include='true']
Predicates may be appended to each other to further refine an
expression, such as:
//foo[@include='true'][@mode='bar']
Using the XPath API
The following example demonstrates using the XPath API to select one
or more nodes from an XML document:
XPath xpath = XPathFactory.newInstance().newXPath();
String expression = "/widgets/widget";
InputSource inputSource = new InputSource("widgets.xml");
NodeList nodes = (NodeList) xpath.evaluate(expression, inputSource, XPathConstants.NODESET);
XPath Expressions and Types
While XPath expressions select nodes in the XML document, the XPath
API allows the selected nodes to be coalesced into one of the
following other data types:
The desired return type is specified by a QName parameter in method call used to evaluate
the expression, which is either a call to
XPathExpression.evalute(...) or to one of the
XPath.evaluate(...) convenience methods. The allowed
QName values are specified as constants in the XPathConstants class; they are:
When a Boolean return type is requested,
Boolean.TRUE is returned if one or more nodes were
selected; otherwise, Boolean.FALSE is returned.
The String return type is a convenience for retrieving
the character data from a text node, attribute node, comment node, or
processing-instruction node. When used on an element node, the value
of the child text nodes is returned.
The Number return type attempts to coalesce the text
of a node to a double data type.
XPath Context
XPath location paths may be relative to a particular node in the
document, known as the context. Consider the following
XML document:
<widgets>
<widget>
<manufacturer/>
<dimensions/>
</widget>
</widgets>
The <widget> element can be selected with the
following XPath API code:
// parse the XML as a W3C Document
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document document = builder.parse(new File("/widgets.xml"));
XPath xpath = XPathFactory.newInstance().newXPath();
String expression = "/widgets/widget";
Node widgetNode = (Node) xpath.evaluate(expression, document, XPathConstants.NODE);
With a reference to the <widget> element, a
relative XPath expression can now written to select the
<manufacturer> child element:
XPath xpath = XPathFactory.newInstance().newXPath();
String expression = "manufacturer";
Node manufacturerNode = (Node) xpath.evaluate(expression, widgetNode, XPathConstants.NODE);
|
org.w3c.dom.DOMImplementation (2 methods)
getFeature(java.lang.String, java.lang.String) hasFeature(java.lang.String, java.lang.String)
DOMImplementation.getFeature(java.lang.String, java.lang.String)
getFeature
java.lang.Object getFeature(java.lang.String feature,
java.lang.String version)
This method returns a specialized object which implements the specialized APIs of the specified feature and version, as specified in
DOM Features. The specialized object may also be obtained by using binding-specific casting methods but is not necessarily expected to, as discussed in . This method also allow the implementation to provide specialized objects which do not support the DOMImplementation
interface.
Parameters:
feature
- The name of the feature requested. Note that any plus sign "+" prepended to the name of the feature will be ignored since it is not significant in the context of this method.
version
- This is the version number of the feature to test.
Returns:
Returns an object which implements the specialized APIs of the specified feature and version, if any, or null
if there is no object which implements interfaces associated with that feature. If the DOMObject
returned by this method implements the DOMImplementation
interface, it must delegate to the primary core DOMImplementation
and not return results inconsistent with the primary core DOMImplementation
such as hasFeature
, getFeature
, etc.
Since:
DOM Level 3
|
getFeature
java.lang.Object getFeature(java.lang.String feature,
java.lang.String version)
This method returns a specialized object which implements the
specialized APIs of the specified feature and version, as specified
in . The specialized object may also be obtained by using
binding-specific casting methods but is not necessarily expected to,
as discussed in . This method also allow the implementation to
provide specialized objects which do not support the
DOMImplementation interface.
Parameters:
feature - The name of the feature requested. Note that any plus
sign "+" prepended to the name of the feature will be ignored since
it is not significant in the context of this method.
version - This is the version number of the feature to test.
Returns:
Returns an object which implements the specialized APIs of
the specified feature and version, if any, or null if
there is no object which implements interfaces associated with that
feature. If the DOMObject returned by this method
implements the DOMImplementation interface, it must
delegate to the primary core DOMImplementation and not
return results inconsistent with the primary core
DOMImplementation such as hasFeature,
getFeature, etc.
Since:
DOM Level 3
|
getFeature
java.lang.Object getFeature(java.lang.String feature,
java.lang.String version)
This method returns a specialized object which implements the
specialized APIs of the specified feature and version, as specified
in DOM Features. The specialized object may also be obtained by using
binding-specific casting methods but is not necessarily expected to,
as discussed in . This method also allow the implementation to
provide specialized objects which do not support the
DOMImplementation interface.
Parameters:
feature - The name of the feature requested. Note that any plus
sign "+" prepended to the name of the feature will be ignored since
it is not significant in the context of this method.
version - This is the version number of the feature to test.
Returns:
Returns an object which implements the specialized APIs of
the specified feature and version, if any, or null if
there is no object which implements interfaces associated with that
feature. If the DOMObject returned by this method
implements the DOMImplementation interface, it must
delegate to the primary core DOMImplementation and not
return results inconsistent with the primary core
DOMImplementation such as hasFeature,
getFeature, etc.
Since:
DOM Level 3
|
DOMImplementation.hasFeature(java.lang.String, java.lang.String)
hasFeature
boolean hasFeature(java.lang.String feature,
java.lang.String version)
Test if the DOM implementation implements a specific feature and version, as specified in
DOM Features.
Parameters:
feature
- The name of the feature to test.
version
- This is the version number of the feature to test.
Returns:
true
if the feature is implemented in the specified version, false
otherwise.
|
hasFeature
boolean hasFeature(java.lang.String feature,
java.lang.String version)
Test if the DOM implementation implements a specific feature and
version, as specified in .
Parameters:
feature - The name of the feature to test.
version - This is the version number of the feature to test.
Returns:
true if the feature is implemented in the
specified version, false otherwise.
|
hasFeature
boolean hasFeature(java.lang.String feature,
java.lang.String version)
Test if the DOM implementation implements a specific feature and
version, as specified in DOM Features.
Parameters:
feature - The name of the feature to test.
version - This is the version number of the feature to test.
Returns:
true if the feature is implemented in the
specified version, false otherwise.
|
org.w3c.dom.Document (1 method)
Document.getDoctype()
getDoctype
DocumentType getDoctype()
The Document Type Declaration (see DocumentType
) associated with this document. For XML documents without a document type declaration this returns null. For HTML documents, a DocumentType
object may be returned, independently of the presence or absence of document type declaration in the HTML document.
This provides direct access to the DocumentType
node, child node of this Document. This node can be set at document creation time and later changed through the use of child nodes manipulation methods, such as Node.insertBefore
, or Node.replaceChild. Note, however, that while some implementations may instantiate different types of Document
objects supporting additional features than the "Core", such as "HTML" [DOM Level 2 HTML
] , based on the DocumentType
specified at creation time, changing it afterwards is very unlikely to result in a change of the features supported.
Since:
DOM Level 3
|
getDoctype
DocumentType getDoctype()
The Document Type Declaration (see DocumentType)
associated with this document. For XML documents without a document
type declaration this returns null. For HTML documents,
a DocumentType object may be returned, independently of
the presence or absence of document type declaration in the HTML
document.
This provides direct access to the DocumentType node,
child node of this Document. This node can be set at
document creation time and later changed through the use of child
nodes manipulation methods, such as Node.insertBefore,
or Node.replaceChild. Note, however, that while some
implementations may instantiate different types of
Document objects supporting additional features than the
"Core", such as "HTML" [DOM Level 2 HTML]
, based on the DocumentType specified at creation time,
changing it afterwards is very unlikely to result in a change of the
features supported.
|
getDoctype
DocumentType getDoctype()
The Document Type Declaration (see DocumentType)
associated with this document. For XML documents without a document
type declaration this returns null. For HTML documents,
a DocumentType object may be returned, independently of
the presence or absence of document type declaration in the HTML
document.
This provides direct access to the DocumentType node,
child node of this Document. This node can be set at
document creation time and later changed through the use of child
nodes manipulation methods, such as Node.insertBefore,
or Node.replaceChild. Note, however, that while some
implementations may instantiate different types of
Document objects supporting additional features than the
"Core", such as "HTML" [DOM Level 2 HTML]
, based on the DocumentType specified at creation time,
changing it afterwards is very unlikely to result in a change of the
features supported.
Since:
DOM Level 3
|
org.w3c.dom.Node (6 methods)
appendChild(org.w3c.dom.Node) getOwnerDocument() insertBefore(org.w3c.dom.Node, org.w3c.dom.Node) normalize() removeChild(org.w3c.dom.Node) replaceChild(org.w3c.dom.Node, org.w3c.dom.Node)
Node.appendChild(org.w3c.dom.Node)
appendChild
Node appendChild(Node newChild)
throws DOMException
Adds the node newChild
to the end of the list of children of this node. If the newChild
is already in the tree, it is first removed.
Parameters:
newChild
- The node to add.If it is a DocumentFragment
object, the entire contents of the document fragment are moved into the child list of this node
Returns:
The node added.
Throws:
DOMException
- HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the newChild
node, or if the node to append is one of this node's ancestors or this node itself, or if this node is of type Document
and the DOM application attempts to append a second DocumentType
or Element
node.
WRONG_DOCUMENT_ERR: Raised if newChild
was created from a different document than the one that created this node.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or if the previous parent of the node being inserted is readonly.
NOT_SUPPORTED_ERR: if the newChild
node is a child of the Document
node, this exception might be raised if the DOM implementation doesn't support the removal of the DocumentType
child or Element
child.
Since:
DOM Level 3
|
appendChild
Node appendChild(Node newChild)
throws DOMException
Adds the node newChild to the end of the list of children
of this node. If the newChild is already in the tree, it
is first removed.
Parameters:
newChild - The node to add.If it is a
DocumentFragment object, the entire contents of the
document fragment are moved into the child list of this node
Returns:
The node added.
Throws:
DOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
allow children of the type of the newChild node, or if
the node to append is one of this node's ancestors or this node
itself, or if this node is of type Document and the
DOM application attempts to append a second
DocumentType or Element node.
WRONG_DOCUMENT_ERR: Raised if newChild was created
from a different document than the one that created this node.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or
if the previous parent of the node being inserted is readonly.
NOT_SUPPORTED_ERR: if the newChild node is a child
of the Document node, this exception might be raised
if the DOM implementation doesn't support the removal of the
DocumentType child or Element child.
|
appendChild
Node appendChild(Node newChild)
throws DOMException
Adds the node newChild to the end of the list of children
of this node. If the newChild is already in the tree, it
is first removed.
Parameters:
newChild - The node to add.If it is a
DocumentFragment object, the entire contents of the
document fragment are moved into the child list of this node
Returns:
The node added.
Throws:
DOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
allow children of the type of the newChild node, or if
the node to append is one of this node's ancestors or this node
itself, or if this node is of type Document and the
DOM application attempts to append a second
DocumentType or Element node.
WRONG_DOCUMENT_ERR: Raised if newChild was created
from a different document than the one that created this node.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or
if the previous parent of the node being inserted is readonly.
NOT_SUPPORTED_ERR: if the newChild node is a child
of the Document node, this exception might be raised
if the DOM implementation doesn't support the removal of the
DocumentType child or Element child.
Since:
DOM Level 3
|
Node.getOwnerDocument()
getOwnerDocument
Document getOwnerDocument()
The Document
object associated with this node. This is also the Document
object used to create new nodes. When this node is a Document
or a DocumentType
which is not used with any Document
yet, this is null.
Since:
DOM Level 2
|
getOwnerDocument
Document getOwnerDocument()
The Document object associated with this node. This is
also the Document object used to create new nodes. When
this node is a Document or a DocumentType
which is not used with any Document yet, this is
null.
|
getOwnerDocument
Document getOwnerDocument()
The Document object associated with this node. This is
also the Document object used to create new nodes. When
this node is a Document or a DocumentType
which is not used with any Document yet, this is
null.
Since:
DOM Level 2
|
Node.insertBefore(org.w3c.dom.Node, org.w3c.dom.Node)
insertBefore
Node insertBefore(Node newChild,
Node refChild)
throws DOMException
Inserts the node newChild
before the existing child node refChild. If refChild
is null
, insert newChild
at the end of the list of children.
If newChild
is a DocumentFragment
object, all of its children are inserted, in the same order, before refChild. If the newChild
is already in the tree, it is first removed.
Note:
Inserting a node before itself is implementation dependent.
Parameters:
newChild
- The node to insert.
refChild
- The reference node, i.e., the node before which the new node must be inserted.
Returns:
The node being inserted.
Throws:
DOMException
- HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the newChild
node, or if the node to insert is one of this node's ancestors or this node itself, or if this node is of type Document
and the DOM application attempts to insert a second DocumentType
or Element
node.
WRONG_DOCUMENT_ERR: Raised if newChild
was created from a different document than the one that created this node.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or if the parent of the node being inserted is readonly.
NOT_FOUND_ERR: Raised if refChild
is not a child of this node.
NOT_SUPPORTED_ERR: if this node is of type Document
, this exception might be raised if the DOM implementation doesn't support the insertion of a DocumentType
or Element
node.
Since:
DOM Level 3
|
insertBefore
Node insertBefore(Node newChild,
Node refChild)
throws DOMException
Inserts the node newChild before the existing child node
refChild. If refChild is null,
insert newChild at the end of the list of children.
If newChild is a DocumentFragment object,
all of its children are inserted, in the same order, before
refChild. If the newChild is already in the
tree, it is first removed.
Note: Inserting a node before itself is implementation
dependent.
Parameters:
newChild - The node to insert.
refChild - The reference node, i.e., the node before which the
new node must be inserted.
Returns:
The node being inserted.
Throws:
DOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
allow children of the type of the newChild node, or if
the node to insert is one of this node's ancestors or this node
itself, or if this node is of type Document and the
DOM application attempts to insert a second
DocumentType or Element node.
WRONG_DOCUMENT_ERR: Raised if newChild was created
from a different document than the one that created this node.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or
if the parent of the node being inserted is readonly.
NOT_FOUND_ERR: Raised if refChild is not a child of
this node.
NOT_SUPPORTED_ERR: if this node is of type Document,
this exception might be raised if the DOM implementation doesn't
support the insertion of a DocumentType or
Element node.
|
insertBefore
Node insertBefore(Node newChild,
Node refChild)
throws DOMException
Inserts the node newChild before the existing child node
refChild. If refChild is null,
insert newChild at the end of the list of children.
If newChild is a DocumentFragment object,
all of its children are inserted, in the same order, before
refChild. If the newChild is already in the
tree, it is first removed.
Note: Inserting a node before itself is implementation
dependent.
Parameters:
newChild - The node to insert.
refChild - The reference node, i.e., the node before which the
new node must be inserted.
Returns:
The node being inserted.
Throws:
DOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
allow children of the type of the newChild node, or if
the node to insert is one of this node's ancestors or this node
itself, or if this node is of type Document and the
DOM application attempts to insert a second
DocumentType or Element node.
WRONG_DOCUMENT_ERR: Raised if newChild was created
from a different document than the one that created this node.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or
if the parent of the node being inserted is readonly.
NOT_FOUND_ERR: Raised if refChild is not a child of
this node.
NOT_SUPPORTED_ERR: if this node is of type Document,
this exception might be raised if the DOM implementation doesn't
support the insertion of a DocumentType or
Element node.
Since:
DOM Level 3
|
Node.normalize()
normalize
void normalize()
Puts all Text
nodes in the full depth of the sub-tree underneath this Node
, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text
nodes, i.e., there are neither adjacent Text
nodes nor empty Text
nodes. This can be used to ensure that the DOM view of a document is the same as if it were saved and re-loaded, and is useful when operations (such as XPointer [XPointer
] lookups) that depend on a particular document tree structure are to be used. If the parameter "normalize-characters" of the DOMConfiguration
object attached to the Node.ownerDocument
is true
, this method will also fully normalize the characters of the Text
nodes.
Note:
In cases where the document contains CDATASections
, the normalize operation alone may not be sufficient, since XPointers do not differentiate between Text
nodes and CDATASection
nodes.
Since:
DOM Level 3
|
normalize
void normalize()
Puts all Text nodes in the full depth of the sub-tree
underneath this Node, including attribute nodes, into a
"normal" form where only structure (e.g., elements, comments,
processing instructions, CDATA sections, and entity references)
separates Text nodes, i.e., there are neither adjacent
Text nodes nor empty Text nodes. This can
be used to ensure that the DOM view of a document is the same as if
it were saved and re-loaded, and is useful when operations (such as
XPointer [XPointer]
lookups) that depend on a particular document tree structure are to
be used. If the parameter "normalize-characters" of the
DOMConfiguration object attached to the
Node.ownerDocument is true, this method
will also fully normalize the characters of the Text
nodes.
Note: In cases where the document contains
CDATASections, the normalize operation alone may not be
sufficient, since XPointers do not differentiate between
Text nodes and CDATASection nodes.
|
normalize
void normalize()
Puts all Text nodes in the full depth of the sub-tree
underneath this Node, including attribute nodes, into a
"normal" form where only structure (e.g., elements, comments,
processing instructions, CDATA sections, and entity references)
separates Text nodes, i.e., there are neither adjacent
Text nodes nor empty Text nodes. This can
be used to ensure that the DOM view of a document is the same as if
it were saved and re-loaded, and is useful when operations (such as
XPointer [XPointer]
lookups) that depend on a particular document tree structure are to
be used. If the parameter "normalize-characters" of the
DOMConfiguration object attached to the
Node.ownerDocument is true, this method
will also fully normalize the characters of the Text
nodes.
Note: In cases where the document contains
CDATASections, the normalize operation alone may not be
sufficient, since XPointers do not differentiate between
Text nodes and CDATASection nodes.
Since:
DOM Level 3
|
Node.removeChild(org.w3c.dom.Node)
removeChild
Node removeChild(Node oldChild)
throws DOMException
Removes the child node indicated by oldChild
from the list of children, and returns it.
Parameters:
oldChild
- The node being removed.
Returns:
The node removed.
Throws:
DOMException
- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
NOT_FOUND_ERR: Raised if oldChild
is not a child of this node.
NOT_SUPPORTED_ERR: if this node is of type Document
, this exception might be raised if the DOM implementation doesn't support the removal of the DocumentType
child or the Element
child.
Since:
DOM Level 3
|
removeChild
Node removeChild(Node oldChild)
throws DOMException
Removes the child node indicated by oldChild from the list
of children, and returns it.
Parameters:
oldChild - The node being removed.
Returns:
The node removed.
Throws:
DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
NOT_FOUND_ERR: Raised if oldChild is not a child of
this node.
NOT_SUPPORTED_ERR: if this node is of type Document,
this exception might be raised if the DOM implementation doesn't
support the removal of the DocumentType child or the
Element child.
|
removeChild
Node removeChild(Node oldChild)
throws DOMException
Removes the child node indicated by oldChild from the list
of children, and returns it.
Parameters:
oldChild - The node being removed.
Returns:
The node removed.
Throws:
DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
NOT_FOUND_ERR: Raised if oldChild is not a child of
this node.
NOT_SUPPORTED_ERR: if this node is of type Document,
this exception might be raised if the DOM implementation doesn't
support the removal of the DocumentType child or the
Element child.
Since:
DOM Level 3
|
Node.replaceChild(org.w3c.dom.Node, org.w3c.dom.Node)
replaceChild
Node replaceChild(Node newChild,
Node oldChild)
throws DOMException
Replaces the child node oldChild
with newChild
in the list of children, and returns the oldChild
node.
If newChild
is a DocumentFragment
object, oldChild
is replaced by all of the DocumentFragment
children, which are inserted in the same order. If the newChild
is already in the tree, it is first removed.
Note:
Replacing a node with itself is implementation dependent.
Parameters:
newChild
- The new node to put in the child list.
oldChild
- The node being replaced in the list.
Returns:
The node replaced.
Throws:
DOMException
- HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the newChild
node, or if the node to put in is one of this node's ancestors or this node itself, or if this node is of type Document
and the result of the replacement operation would add a second DocumentType
or Element
on the Document
node.
WRONG_DOCUMENT_ERR: Raised if newChild
was created from a different document than the one that created this node.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the parent of the new node is readonly.
NOT_FOUND_ERR: Raised if oldChild
is not a child of this node.
NOT_SUPPORTED_ERR: if this node is of type Document
, this exception might be raised if the DOM implementation doesn't support the replacement of the DocumentType
child or Element
child.
Since:
DOM Level 3
|
replaceChild
Node replaceChild(Node newChild,
Node oldChild)
throws DOMException
Replaces the child node oldChild with newChild
in the list of children, and returns the oldChild node.
If newChild is a DocumentFragment object,
oldChild is replaced by all of the
DocumentFragment children, which are inserted in the
same order. If the newChild is already in the tree, it
is first removed.
Note: Replacing a node with itself is implementation
dependent.
Parameters:
newChild - The new node to put in the child list.
oldChild - The node being replaced in the list.
Returns:
The node replaced.
Throws:
DOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
allow children of the type of the newChild node, or if
the node to put in is one of this node's ancestors or this node
itself, or if this node is of type Document and the
result of the replacement operation would add a second
DocumentType or Element on the
Document node.
WRONG_DOCUMENT_ERR: Raised if newChild was created
from a different document than the one that created this node.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the parent of
the new node is readonly.
NOT_FOUND_ERR: Raised if oldChild is not a child of
this node.
NOT_SUPPORTED_ERR: if this node is of type Document,
this exception might be raised if the DOM implementation doesn't
support the replacement of the DocumentType child or
Element child.
|
replaceChild
Node replaceChild(Node newChild,
Node oldChild)
throws DOMException
Replaces the child node oldChild with newChild
in the list of children, and returns the oldChild node.
If newChild is a DocumentFragment object,
oldChild is replaced by all of the
DocumentFragment children, which are inserted in the
same order. If the newChild is already in the tree, it
is first removed.
Note: Replacing a node with itself is implementation
dependent.
Parameters:
newChild - The new node to put in the child list.
oldChild - The node being replaced in the list.
Returns:
The node replaced.
Throws:
DOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
allow children of the type of the newChild node, or if
the node to put in is one of this node's ancestors or this node
itself, or if this node is of type Document and the
result of the replacement operation would add a second
DocumentType or Element on the
Document node.
WRONG_DOCUMENT_ERR: Raised if newChild was created
from a different document than the one that created this node.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the parent of
the new node is readonly.
NOT_FOUND_ERR: Raised if oldChild is not a child of
this node.
NOT_SUPPORTED_ERR: if this node is of type Document,
this exception might be raised if the DOM implementation doesn't
support the replacement of the DocumentType child or
Element child.
Since:
DOM Level 3
|
org.w3c.dom.Text (2 methods)
getWholeText() replaceWholeText(java.lang.String)
Text.getWholeText()
getWholeText
java.lang.String getWholeText()
Returns all text of Text
nodes logically-adjacent text nodes to this node, concatenated in document order.
For instance, in the example below wholeText
on the Text
node that contains "bar" returns "barfoo", while on the Text
node that contains "foo" it returns "barfoo".
+-----+
| <p> |
+-----+
/\
/ \
/-----\ +-------+
| bar | | &ent; |
\-----/ +-------+
|
|
/-----\
| foo |
\-----/
Figure: barTextNode.wholeText value is "barfoo"
Since:
DOM Level 3
|
getWholeText
java.lang.String getWholeText()
Returns all text of Text nodes logically-adjacent text
nodes to this node, concatenated in document order.
For instance, in the example below wholeText on the
Text node that contains "bar" returns "barfoo", while on
the Text node that contains "foo" it returns "barfoo".
Since:
DOM Level 3
|
getWholeText
java.lang.String getWholeText()
Returns all text of Text nodes logically-adjacent text
nodes to this node, concatenated in document order.
For instance, in the example below wholeText on the
Text node that contains "bar" returns "barfoo", while on
the Text node that contains "foo" it returns "barfoo".
+-----+
| <p> |
+-----+
/\
/ \
/-----\ +-------+
| bar | | &ent; |
\-----/ +-------+
|
|
/-----\
| foo |
\-----/
Figure: barTextNode.wholeText value is "barfoo"
Since:
DOM Level 3
|
Text.replaceWholeText(java.lang.String)
replaceWholeText
Text replaceWholeText(java.lang.String content)
throws DOMException
Replaces the text of the current node and all logically-adjacent text nodes with the specified text. All logically-adjacent text nodes are removed including the current node unless it was the recipient of the replacement text.
This method returns the node which received the replacement text. The returned node is:
null
, when the replacement text is the empty string;
the current node, except when the current node is read-only;
a new Text
node of the same type ( Text
or CDATASection
) as the current node inserted at the location of the replacement.
For instance, in the above example calling replaceWholeText
on the Text
node that contains "bar" with "yo" in argument results in the following:
+-----+
| <p> |
+-----+
|
|
/-----\
| yo |
\-----/
Figure: barTextNode.replaceWholeText("yo") modifies the textual content of barTextNode with "yo"
Where the nodes to be removed are read-only descendants of an EntityReference
, the EntityReference
must be removed instead of the read-only nodes. If any EntityReference
to be removed has descendants that are not EntityReference
, Text
, or CDATASection
nodes, the replaceWholeText
method must fail before performing any modification of the document, raising a DOMException
with the code NO_MODIFICATION_ALLOWED_ERR.
For instance, in the example below calling replaceWholeText
on the Text
node that contains "bar" fails, because the EntityReference
node "ent" contains an Element
node which cannot be removed.
Parameters:
content
- The content of the replacing Text
node.
Returns:
The Text
node created with the specified content.
Throws:
DOMException
- NO_MODIFICATION_ALLOWED_ERR: Raised if one of the Text
nodes being replaced is readonly.
Since:
DOM Level 3
|
replaceWholeText
Text replaceWholeText(java.lang.String content)
throws DOMException
Replaces the text of the current node and all logically-adjacent text
nodes with the specified text. All logically-adjacent text nodes are
removed including the current node unless it was the recipient of the
replacement text.
This method returns the node which received the replacement text.
The returned node is:
null, when the replacement text is
the empty string;
the current node, except when the current node is
read-only;
a new Text node of the same type (
Text or CDATASection) as the current node
inserted at the location of the replacement.
For instance, in the above example calling
replaceWholeText on the Text node that
contains "bar" with "yo" in argument results in the following:
Where the nodes to be removed are read-only descendants of an
EntityReference, the EntityReference must
be removed instead of the read-only nodes. If any
EntityReference to be removed has descendants that are
not EntityReference, Text, or
CDATASection nodes, the replaceWholeText
method must fail before performing any modification of the document,
raising a DOMException with the code
NO_MODIFICATION_ALLOWED_ERR.
For instance, in the example below calling
replaceWholeText on the Text node that
contains "bar" fails, because the EntityReference node
"ent" contains an Element node which cannot be removed.
Parameters:
content - The content of the replacing Text node.
Returns:
The Text node created with the specified content.
Throws:
DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if one of the Text
nodes being replaced is readonly.
Since:
DOM Level 3
|
replaceWholeText
Text replaceWholeText(java.lang.String content)
throws DOMException
Replaces the text of the current node and all logically-adjacent text
nodes with the specified text. All logically-adjacent text nodes are
removed including the current node unless it was the recipient of the
replacement text.
This method returns the node which received the replacement text.
The returned node is:
null, when the replacement text is
the empty string;
the current node, except when the current node is
read-only;
a new Text node of the same type (
Text or CDATASection) as the current node
inserted at the location of the replacement.
For instance, in the above example calling
replaceWholeText on the Text node that
contains "bar" with "yo" in argument results in the following:
+-----+
| <p> |
+-----+
|
|
/-----\
| yo |
\-----/
Figure: barTextNode.replaceWholeText("yo") modifies the
textual content of barTextNode with "yo"
Where the nodes to be removed are read-only descendants of an
EntityReference, the EntityReference must
be removed instead of the read-only nodes. If any
EntityReference to be removed has descendants that are
not EntityReference, Text, or
CDATASection nodes, the replaceWholeText
method must fail before performing any modification of the document,
raising a DOMException with the code
NO_MODIFICATION_ALLOWED_ERR.
For instance, in the example below calling
replaceWholeText on the Text node that
contains "bar" fails, because the EntityReference node
"ent" contains an Element node which cannot be removed.
Parameters:
content - The content of the replacing Text node.
Returns:
The Text node created with the specified content.
Throws:
DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if one of the Text
nodes being replaced is readonly.
Since:
DOM Level 3
|
org.w3c.dom.events.DocumentEvent (1 method)
DocumentEvent.createEvent(java.lang.String)
createEvent
Event createEvent(java.lang.String eventType)
throws DOMException
Parameters:
eventType eventTypeThe
- The eventType
parameter specifies the type of Event
interface to be created. If the Event
interface specified is supported by the implementation this method will return a new Event
of the interface type requested. If the Event
is to be dispatched via the dispatchEvent
method the appropriate event init method must be called after creation in order to initialize the Event
's values. As an example, a user wishing to synthesize some kind of UIEvent
would call createEvent
with the parameter "UIEvents". The initUIEvent
method could then be called on the newly created UIEvent
to set the specific type of UIEvent to be dispatched and set its context information.The createEvent
method is used in creating Event
s when it is either inconvenient or unnecessary for the user to create an Event
themselves. In cases where the implementation provided Event
is insufficient, users may supply their own Event
implementations for use with the dispatchEvent
method.
Returns:
The newly created Event
Throws:
DOMException
- NOT_SUPPORTED_ERR: Raised if the implementation does not support the type of Event
interface requested
|
createEvent
Event createEvent(java.lang.String eventType)
throws DOMException
Parameters:
eventTypeThe - eventType parameter specifies the
type of Event interface to be created. If the
Event interface specified is supported by the
implementation this method will return a new Event of
the interface type requested. If the Event is to be
dispatched via the dispatchEvent method the
appropriate event init method must be called after creation in
order to initialize the Event's values. As an example,
a user wishing to synthesize some kind of UIEvent
would call createEvent with the parameter "UIEvents".
The initUIEvent method could then be called on the
newly created UIEvent to set the specific type of
UIEvent to be dispatched and set its context information.The
createEvent method is used in creating
Events when it is either inconvenient or unnecessary
for the user to create an Event themselves. In cases
where the implementation provided Event is
insufficient, users may supply their own Event
implementations for use with the dispatchEvent method.
Returns:
The newly created Event
Throws:
DOMException - NOT_SUPPORTED_ERR: Raised if the implementation does not support the
type of Event interface requested
|
createEvent
Event createEvent(java.lang.String eventType)
throws DOMException
Parameters:
eventType - The eventType parameter specifies the
type of Event interface to be created. If the
Event interface specified is supported by the
implementation this method will return a new Event of
the interface type requested. If the Event is to be
dispatched via the dispatchEvent method the
appropriate event init method must be called after creation in
order to initialize the Event's values. As an example,
a user wishing to synthesize some kind of UIEvent
would call createEvent with the parameter "UIEvents".
The initUIEvent method could then be called on the
newly created UIEvent to set the specific type of
UIEvent to be dispatched and set its context information.The
createEvent method is used in creating
Events when it is either inconvenient or unnecessary
for the user to create an Event themselves. In cases
where the implementation provided Event is
insufficient, users may supply their own Event
implementations for use with the dispatchEvent method.
Returns:
The newly created Event
Throws:
DOMException - NOT_SUPPORTED_ERR: Raised if the implementation does not support the
type of Event interface requested
|
org.w3c.dom.events.Event (1 method)
Event.initEvent(java.lang.String, boolean, boolean)
initEvent
void initEvent(java.lang.String eventTypeArg,
boolean canBubbleArg,
boolean cancelableArg)
The initEvent
method is used to initialize the value of an Event
created through the DocumentEvent
interface. This method may only be called before the Event
has been dispatched via the dispatchEvent
method, though it may be called multiple times during that phase if necessary. If called multiple times the final invocation takes precedence. If called from a subclass of Event
interface only the values specified in the initEvent
method are modified, all other attributes are left unchanged.
Parameters:
eventTypeArg eventTypeArgSpecifies
- Specifies the event type. This type may be any event type currently defined in this specification or a new event type.. The string must be an XML name. Any new event type must not begin with any upper, lower, or mixed case version of the string "DOM". This prefix is reserved for future DOM event sets. It is also strongly recommended that third parties adding their own events use their own prefix to avoid confusion and lessen the probability of conflicts with other new events.
canBubbleArg canBubbleArgSpecifies
- Specifies whether or not the event can bubble.
cancelableArg cancelableArgSpecifies
- Specifies whether or not the event's default action can be prevented.
|
initEvent
void initEvent(java.lang.String eventTypeArg,
boolean canBubbleArg,
boolean cancelableArg)
The initEvent method is used to initialize the value of an
Event created through the DocumentEvent
interface. This method may only be called before the
Event has been dispatched via the
dispatchEvent method, though it may be called multiple
times during that phase if necessary. If called multiple times the
final invocation takes precedence. If called from a subclass of
Event interface only the values specified in the
initEvent method are modified, all other attributes are
left unchanged.
Parameters:
eventTypeArgSpecifies - the event type. This type may be any
event type currently defined in this specification or a new event
type.. The string must be an XML name. Any new event type must not
begin with any upper, lower, or mixed case version of the string
"DOM". This prefix is reserved for future DOM event sets. It is
also strongly recommended that third parties adding their own
events use their own prefix to avoid confusion and lessen the
probability of conflicts with other new events.
canBubbleArgSpecifies - whether or not the event can bubble.
cancelableArgSpecifies - whether or not the event's default
action can be prevented.
|
initEvent
void initEvent(java.lang.String eventTypeArg,
boolean canBubbleArg,
boolean cancelableArg)
The initEvent method is used to initialize the value of an
Event created through the DocumentEvent
interface. This method may only be called before the
Event has been dispatched via the
dispatchEvent method, though it may be called multiple
times during that phase if necessary. If called multiple times the
final invocation takes precedence. If called from a subclass of
Event interface only the values specified in the
initEvent method are modified, all other attributes are
left unchanged.
Parameters:
eventTypeArg - Specifies the event type. This type may be any
event type currently defined in this specification or a new event
type.. The string must be an XML name. Any new event type must not
begin with any upper, lower, or mixed case version of the string
"DOM". This prefix is reserved for future DOM event sets. It is
also strongly recommended that third parties adding their own
events use their own prefix to avoid confusion and lessen the
probability of conflicts with other new events.
canBubbleArg - Specifies whether or not the event can bubble.
cancelableArg - Specifies whether or not the event's default
action can be prevented.
|
org.w3c.dom.events.EventTarget (3 methods)
addEventListener(java.lang.String, org.w3c.dom.events.EventListener, boolean) dispatchEvent(org.w3c.dom.events.Event) removeEventListener(java.lang.String, org.w3c.dom.events.EventListener, boolean)
EventTarget.addEventListener(java.lang.String, org.w3c.dom.events.EventListener, boolean)
addEventListener
void addEventListener(java.lang.String type,
EventListener listener,
boolean useCapture)
This method allows the registration of event listeners on the event target. If an EventListener
is added to an EventTarget
while it is processing an event, it will not be triggered by the current actions but may be triggered during a later stage of event flow, such as the bubbling phase.
If multiple identical EventListener
s are registered on the same EventTarget
with the same parameters the duplicate instances are discarded. They do not cause the EventListener
to be called twice and since they are discarded they do not need to be removed with the removeEventListener
method.
Parameters:
type typeThe
- The event type for which the user is registering
listener listenerThe
- The listener
parameter takes an interface implemented by the user which contains the methods to be called when the event occurs.
useCapture useCaptureIf
- If true, useCapture
indicates that the user wishes to initiate capture. After initiating capture, all events of the specified type will be dispatched to the registered EventListener
before being dispatched to any EventTargets
beneath them in the tree. Events which are bubbling upward through the tree will not trigger an EventListener
designated to use capture.
|
addEventListener
void addEventListener(java.lang.String type,
EventListener listener,
boolean useCapture)
This method allows the registration of event listeners on the event
target. If an EventListener is added to an
EventTarget while it is processing an event, it will not
be triggered by the current actions but may be triggered during a
later stage of event flow, such as the bubbling phase.
If multiple identical EventListeners are registered
on the same EventTarget with the same parameters the
duplicate instances are discarded. They do not cause the
EventListener to be called twice and since they are
discarded they do not need to be removed with the
removeEventListener method.
Parameters:
typeThe - event type for which the user is registering
listenerThe - listener parameter takes an interface
implemented by the user which contains the methods to be called
when the event occurs.
useCaptureIf - true, useCapture indicates that the
user wishes to initiate capture. After initiating capture, all
events of the specified type will be dispatched to the registered
EventListener before being dispatched to any
EventTargets beneath them in the tree. Events which
are bubbling upward through the tree will not trigger an
EventListener designated to use capture.
|
addEventListener
void addEventListener(java.lang.String type,
EventListener listener,
boolean useCapture)
This method allows the registration of event listeners on the event
target. If an EventListener is added to an
EventTarget while it is processing an event, it will not
be triggered by the current actions but may be triggered during a
later stage of event flow, such as the bubbling phase.
If multiple identical EventListeners are registered
on the same EventTarget with the same parameters the
duplicate instances are discarded. They do not cause the
EventListener to be called twice and since they are
discarded they do not need to be removed with the
removeEventListener method.
Parameters:
type - The event type for which the user is registering
listener - The listener parameter takes an interface
implemented by the user which contains the methods to be called
when the event occurs.
useCapture - If true, useCapture indicates that the
user wishes to initiate capture. After initiating capture, all
events of the specified type will be dispatched to the registered
EventListener before being dispatched to any
EventTargets beneath them in the tree. Events which
are bubbling upward through the tree will not trigger an
EventListener designated to use capture.
|
EventTarget.dispatchEvent(org.w3c.dom.events.Event)
dispatchEvent
boolean dispatchEvent(Event evt)
throws EventException
This method allows the dispatch of events into the implementations event model. Events dispatched in this manner will have the same capturing and bubbling behavior as events dispatched directly by the implementation. The target of the event is the EventTarget
on which dispatchEvent
is called.
Parameters:
evt evtSpecifies
- Specifies the event type, behavior, and contextual information to be used in processing the event.
Returns:
The return value of dispatchEvent
indicates whether any of the listeners which handled the event called preventDefault. If preventDefault
was called the value is false, else the value is true.
Throws:
EventException
- UNSPECIFIED_EVENT_TYPE_ERR: Raised if the Event
's type was not specified by initializing the event before dispatchEvent
was called. Specification of the Event
's type as null
or an empty string will also trigger this exception.
|
dispatchEvent
boolean dispatchEvent(Event evt)
throws EventException
This method allows the dispatch of events into the implementations
event model. Events dispatched in this manner will have the same
capturing and bubbling behavior as events dispatched directly by the
implementation. The target of the event is the
EventTarget on which dispatchEvent is
called.
Parameters:
evtSpecifies - the event type, behavior, and contextual
information to be used in processing the event.
Returns:
The return value of dispatchEvent indicates
whether any of the listeners which handled the event called
preventDefault. If preventDefault was
called the value is false, else the value is true.
Throws:
EventException - UNSPECIFIED_EVENT_TYPE_ERR: Raised if the Event's type
was not specified by initializing the event before
dispatchEvent was called. Specification of the
Event's type as null or an empty string
will also trigger this exception.
|
dispatchEvent
boolean dispatchEvent(Event evt)
throws EventException
This method allows the dispatch of events into the implementations
event model. Events dispatched in this manner will have the same
capturing and bubbling behavior as events dispatched directly by the
implementation. The target of the event is the
EventTarget on which dispatchEvent is
called.
Parameters:
evt - Specifies the event type, behavior, and contextual
information to be used in processing the event.
Returns:
The return value of dispatchEvent indicates
whether any of the listeners which handled the event called
preventDefault. If preventDefault was
called the value is false, else the value is true.
Throws:
EventException - UNSPECIFIED_EVENT_TYPE_ERR: Raised if the Event's type
was not specified by initializing the event before
dispatchEvent was called. Specification of the
Event's type as null or an empty string
will also trigger this exception.
|
EventTarget.removeEventListener(java.lang.String, org.w3c.dom.events.EventListener, boolean)
removeEventListener
void removeEventListener(java.lang.String type,
EventListener listener,
boolean useCapture)
This method allows the removal of event listeners from the event target. If an EventListener
is removed from an EventTarget
while it is processing an event, it will not be triggered by the current actions. EventListener
s can never be invoked after being removed.
Calling removeEventListener
with arguments which do not identify any currently registered EventListener
on the EventTarget
has no effect.
Parameters:
type typeSpecifies
- Specifies the event type of the EventListener
being removed.
listener listenerThe
- The EventListener
parameter indicates the EventListener
to be removed.
useCapture useCaptureSpecifies
- Specifies whether the EventListener
being removed was registered as a capturing listener or not. If a listener was registered twice, one with capture and one without, each must be removed separately. Removal of a capturing listener does not affect a non-capturing version of the same listener, and vice versa.
|
removeEventListener
void removeEventListener(java.lang.String type,
EventListener listener,
boolean useCapture)
This method allows the removal of event listeners from the event
target. If an EventListener is removed from an
EventTarget while it is processing an event, it will not
be triggered by the current actions. EventListeners can
never be invoked after being removed.
Calling removeEventListener with arguments which do
not identify any currently registered EventListener on
the EventTarget has no effect.
Parameters:
typeSpecifies - the event type of the EventListener
being removed.
listenerThe - EventListener parameter indicates the
EventListener to be removed.
useCaptureSpecifies - whether the EventListener
being removed was registered as a capturing listener or not. If a
listener was registered twice, one with capture and one without,
each must be removed separately. Removal of a capturing listener
does not affect a non-capturing version of the same listener, and
vice versa.
|
removeEventListener
void removeEventListener(java.lang.String type,
EventListener listener,
boolean useCapture)
This method allows the removal of event listeners from the event
target. If an EventListener is removed from an
EventTarget while it is processing an event, it will not
be triggered by the current actions. EventListeners can
never be invoked after being removed.
Calling removeEventListener with arguments which do
not identify any currently registered EventListener on
the EventTarget has no effect.
Parameters:
type - Specifies the event type of the EventListener
being removed.
listener - The EventListener parameter indicates the
EventListener to be removed.
useCapture - Specifies whether the EventListener
being removed was registered as a capturing listener or not. If a
listener was registered twice, one with capture and one without,
each must be removed separately. Removal of a capturing listener
does not affect a non-capturing version of the same listener, and
vice versa.
|
org.w3c.dom.events.MouseEvent (1 method)
MouseEvent.initMouseEvent(java.lang.String, boolean, boolean, org.w3c.dom.views.AbstractView, int, int, int, int, int, boolean, boolean, boolean, boolean, short, org.w3c.dom.events.EventTarget)
initMouseEvent
void initMouseEvent(java.lang.String typeArg,
boolean canBubbleArg,
boolean cancelableArg,
org.w3c.dom.views.AbstractView viewArg,
int detailArg,
int screenXArg,
int screenYArg,
int clientXArg,
int clientYArg,
boolean ctrlKeyArg,
boolean altKeyArg,
boolean shiftKeyArg,
boolean metaKeyArg,
short buttonArg,
EventTarget relatedTargetArg)
The initMouseEvent
method is used to initialize the value of a MouseEvent
created through the DocumentEvent
interface. This method may only be called before the MouseEvent
has been dispatched via the dispatchEvent
method, though it may be called multiple times during that phase if necessary. If called multiple times, the final invocation takes precedence.
Parameters:
typeArg typeArgSpecifies
- Specifies the event type.
canBubbleArg canBubbleArgSpecifies
- Specifies whether or not the event can bubble.
cancelableArg cancelableArgSpecifies
- Specifies whether or not the event's default action can be prevented.
viewArg viewArgSpecifies
- Specifies the Event
's AbstractView.
detailArg detailArgSpecifies
- Specifies the Event
's mouse click count.
screenXArg screenXArgSpecifies
- Specifies the Event
's screen x coordinate
screenYArg screenYArgSpecifies
- Specifies the Event
's screen y coordinate
clientXArg clientXArgSpecifies
- Specifies the Event
's client x coordinate
clientYArg clientYArgSpecifies
- Specifies the Event
's client y coordinate
ctrlKeyArg ctrlKeyArgSpecifies
- Specifies whether or not control key was depressed during the Event.
altKeyArg altKeyArgSpecifies
- Specifies whether or not alt key was depressed during the Event.
shiftKeyArg shiftKeyArgSpecifies
- Specifies whether or not shift key was depressed during the Event.
metaKeyArg metaKeyArgSpecifies
- Specifies whether or not meta key was depressed during the Event.
buttonArg buttonArgSpecifies
- Specifies the Event
's mouse button.
relatedTargetArg relatedTargetArgSpecifies
- Specifies the Event
's related EventTarget.
|
initMouseEvent
void initMouseEvent(java.lang.String typeArg,
boolean canBubbleArg,
boolean cancelableArg,
org.w3c.dom.views.AbstractView viewArg,
int detailArg,
int screenXArg,
int screenYArg,
int clientXArg,
int clientYArg,
boolean ctrlKeyArg,
boolean altKeyArg,
boolean shiftKeyArg,
boolean metaKeyArg,
short buttonArg,
EventTarget relatedTargetArg)
The initMouseEvent method is used to initialize the value
of a MouseEvent created through the
DocumentEvent interface. This method may only be called
before the MouseEvent has been dispatched via the
dispatchEvent method, though it may be called multiple
times during that phase if necessary. If called multiple times, the
final invocation takes precedence.
Parameters:
typeArgSpecifies - the event type.
canBubbleArgSpecifies - whether or not the event can bubble.
cancelableArgSpecifies - whether or not the event's default
action can be prevented.
viewArgSpecifies - the Event's
AbstractView.
detailArgSpecifies - the Event's mouse click count.
screenXArgSpecifies - the Event's screen x coordinate
screenYArgSpecifies - the Event's screen y coordinate
clientXArgSpecifies - the Event's client x coordinate
clientYArgSpecifies - the Event's client y coordinate
ctrlKeyArgSpecifies - whether or not control key was depressed
during the Event.
altKeyArgSpecifies - whether or not alt key was depressed during
the Event.
shiftKeyArgSpecifies - whether or not shift key was depressed
during the Event.
metaKeyArgSpecifies - whether or not meta key was depressed
during the Event.
buttonArgSpecifies - the Event's mouse button.
relatedTargetArgSpecifies - the Event's related
EventTarget.
|
initMouseEvent
void initMouseEvent(java.lang.String typeArg,
boolean canBubbleArg,
boolean cancelableArg,
org.w3c.dom.views.AbstractView viewArg,
int detailArg,
int screenXArg,
int screenYArg,
int clientXArg,
int clientYArg,
boolean ctrlKeyArg,
boolean altKeyArg,
boolean shiftKeyArg,
boolean metaKeyArg,
short buttonArg,
EventTarget relatedTargetArg)
The initMouseEvent method is used to initialize the value
of a MouseEvent created through the
DocumentEvent interface. This method may only be called
before the MouseEvent has been dispatched via the
dispatchEvent method, though it may be called multiple
times during that phase if necessary. If called multiple times, the
final invocation takes precedence.
Parameters:
typeArg - Specifies the event type.
canBubbleArg - Specifies whether or not the event can bubble.
cancelableArg - Specifies whether or not the event's default
action can be prevented.
viewArg - Specifies the Event's
AbstractView.
detailArg - Specifies the Event's mouse click count.
screenXArg - Specifies the Event's screen x
coordinate
screenYArg - Specifies the Event's screen y
coordinate
clientXArg - Specifies the Event's client x
coordinate
clientYArg - Specifies the Event's client y
coordinate
ctrlKeyArg - Specifies whether or not control key was depressed
during the Event.
altKeyArg - Specifies whether or not alt key was depressed during
the Event.
shiftKeyArg - Specifies whether or not shift key was depressed
during the Event.
metaKeyArg - Specifies whether or not meta key was depressed
during the Event.
buttonArg - Specifies the Event's mouse button.
relatedTargetArg - Specifies the Event's related
EventTarget.
|
org.w3c.dom.events.MutationEvent (3 methods)
getNewValue() getPrevValue() initMutationEvent(java.lang.String, boolean, boolean, org.w3c.dom.Node, java.lang.String, java.lang.String, java.lang.String, short)
MutationEvent.getNewValue()
getNewValue
java.lang.String getNewValue()
newValue
indicates the new value of the Attr
node in DOMAttrModified events, and of the CharacterData
node in DOMCharacterDataModified DOMCharDataModified events.
|
getNewValue
java.lang.String getNewValue()
newValue indicates the new value of the Attr
node in DOMAttrModified events, and of the CharacterData
node in DOMCharDataModified events.
|
getNewValue
java.lang.String getNewValue()
newValue indicates the new value of the Attr
node in DOMAttrModified events, and of the CharacterData
node in DOMCharacterDataModified events.
|
MutationEvent.getPrevValue()
getPrevValue
java.lang.String getPrevValue()
prevValue
indicates the previous value of the Attr
node in DOMAttrModified events, and of the CharacterData
node in DOMCharacterDataModified DOMCharDataModified events.
|
getPrevValue
java.lang.String getPrevValue()
prevValue indicates the previous value of the
Attr node in DOMAttrModified events, and of the
CharacterData node in DOMCharDataModified events.
|
getPrevValue
java.lang.String getPrevValue()
prevValue indicates the previous value of the
Attr node in DOMAttrModified events, and of the
CharacterData node in DOMCharacterDataModified events.
|
MutationEvent.initMutationEvent(java.lang.String, boolean, boolean, org.w3c.dom.Node, java.lang.String, java.lang.String, java.lang.String, short)
initMutationEvent
void initMutationEvent(java.lang.String typeArg,
boolean canBubbleArg,
boolean cancelableArg,
Node relatedNodeArg,
java.lang.String prevValueArg,
java.lang.String newValueArg,
java.lang.String attrNameArg,
short attrChangeArg)
The initMutationEvent
method is used to initialize the value of a MutationEvent
created through the DocumentEvent
interface. This method may only be called before the MutationEvent
has been dispatched via the dispatchEvent
method, though it may be called multiple times during that phase if necessary. If called multiple times, the final invocation takes precedence.
Parameters:
typeArg typeArgSpecifies
- Specifies the event type.
canBubbleArg canBubbleArgSpecifies
- Specifies whether or not the event can bubble.
cancelableArg cancelableArgSpecifies
- Specifies whether or not the event's default action can be prevented.
relatedNodeArg relatedNodeArgSpecifies
- Specifies the Event
's related Node.
prevValueArg prevValueArgSpecifies
- Specifies the Event
's prevValue
attribute. This value may be null.
newValueArg newValueArgSpecifies
- Specifies the Event
's newValue
attribute. This value may be null.
attrNameArg attrNameArgSpecifies
- Specifies the Event
's attrName
attribute. This value may be null.
attrChangeArg attrChangeArgSpecifies
- Specifies the Event
's attrChange
attribute
|
initMutationEvent
void initMutationEvent(java.lang.String typeArg,
boolean canBubbleArg,
boolean cancelableArg,
Node relatedNodeArg,
java.lang.String prevValueArg,
java.lang.String newValueArg,
java.lang.String attrNameArg,
short attrChangeArg)
The initMutationEvent method is used to initialize the
value of a MutationEvent created through the
DocumentEvent interface. This method may only be called
before the MutationEvent has been dispatched via the
dispatchEvent method, though it may be called multiple
times during that phase if necessary. If called multiple times, the
final invocation takes precedence.
Parameters:
typeArgSpecifies - the event type.
canBubbleArgSpecifies - whether or not the event can bubble.
cancelableArgSpecifies - whether or not the event's default
action can be prevented.
relatedNodeArgSpecifies - the Event's related Node.
prevValueArgSpecifies - the Event's
prevValue attribute. This value may be null.
newValueArgSpecifies - the Event's
newValue attribute. This value may be null.
attrNameArgSpecifies - the Event's
attrName attribute. This value may be null.
attrChangeArgSpecifies - the Event's
attrChange attribute
|
initMutationEvent
void initMutationEvent(java.lang.String typeArg,
boolean canBubbleArg,
boolean cancelableArg,
Node relatedNodeArg,
java.lang.String prevValueArg,
java.lang.String newValueArg,
java.lang.String attrNameArg,
short attrChangeArg)
The initMutationEvent method is used to initialize the
value of a MutationEvent created through the
DocumentEvent interface. This method may only be called
before the MutationEvent has been dispatched via the
dispatchEvent method, though it may be called multiple
times during that phase if necessary. If called multiple times, the
final invocation takes precedence.
Parameters:
typeArg - Specifies the event type.
canBubbleArg - Specifies whether or not the event can bubble.
cancelableArg - Specifies whether or not the event's default
action can be prevented.
relatedNodeArg - Specifies the Event's related Node.
prevValueArg - Specifies the Event's
prevValue attribute. This value may be null.
newValueArg - Specifies the Event's
newValue attribute. This value may be null.
attrNameArg - Specifies the Event's
attrName attribute. This value may be null.
attrChangeArg - Specifies the Event's
attrChange attribute
|
org.w3c.dom.events.UIEvent (1 method)
UIEvent.initUIEvent(java.lang.String, boolean, boolean, org.w3c.dom.views.AbstractView, int)
initUIEvent
void initUIEvent(java.lang.String typeArg,
boolean canBubbleArg,
boolean cancelableArg,
org.w3c.dom.views.AbstractView viewArg,
int detailArg)
The initUIEvent
method is used to initialize the value of a UIEvent
created through the DocumentEvent
interface. This method may only be called before the UIEvent
has been dispatched via the dispatchEvent
method, though it may be called multiple times during that phase if necessary. If called multiple times, the final invocation takes precedence.
Parameters:
typeArg typeArgSpecifies
- Specifies the event type.
canBubbleArg canBubbleArgSpecifies
- Specifies whether or not the event can bubble.
cancelableArg cancelableArgSpecifies
- Specifies whether or not the event's default action can be prevented.
viewArg viewArgSpecifies
- Specifies the Event
's AbstractView.
detailArg detailArgSpecifies
- Specifies the Event
's detail.
|
initUIEvent
void initUIEvent(java.lang.String typeArg,
boolean canBubbleArg,
boolean cancelableArg,
org.w3c.dom.views.AbstractView viewArg,
int detailArg)
The initUIEvent method is used to initialize the value of
a UIEvent created through the DocumentEvent
interface. This method may only be called before the
UIEvent has been dispatched via the
dispatchEvent method, though it may be called multiple
times during that phase if necessary. If called multiple times, the
final invocation takes precedence.
Parameters:
typeArgSpecifies - the event type.
canBubbleArgSpecifies - whether or not the event can bubble.
cancelableArgSpecifies - whether or not the event's default
action can be prevented.
viewArgSpecifies - the Event's
AbstractView.
detailArgSpecifies - the Event's detail.
|
initUIEvent
void initUIEvent(java.lang.String typeArg,
boolean canBubbleArg,
boolean cancelableArg,
org.w3c.dom.views.AbstractView viewArg,
int detailArg)
The initUIEvent method is used to initialize the value of
a UIEvent created through the DocumentEvent
interface. This method may only be called before the
UIEvent has been dispatched via the
dispatchEvent method, though it may be called multiple
times during that phase if necessary. If called multiple times, the
final invocation takes precedence.
Parameters:
typeArg - Specifies the event type.
canBubbleArg - Specifies whether or not the event can bubble.
cancelableArg - Specifies whether or not the event's default
action can be prevented.
viewArg - Specifies the Event's
AbstractView.
detailArg - Specifies the Event's detail.
|
org.w3c.dom.package-summary
package-summary.PACKAGE_DESCRIPTION (Deleted)
Package org.w3c.dom Description
Provides the interfaces for the Document Object Model (DOM) which is a
component API of the Java API for XML
Processing. The Document Object Model Level 2 Core API allows programs
to dynamically access and update the content and structure of documents.
See the specification
for more information.
Since:
JDK1.4
|
org.w3c.dom.ranges.package-summary
package-summary.PACKAGE_DESCRIPTION (Deleted)
Package org.w3c.dom.ranges Description
Document Object Model Level 2 Traversal and Range is a
platform and language-neutral interfaces that allow programs
and scripts to dynamically traverse and identify a range of
content in a document. The Document Object Model Level 2
Traversal and Range build on the Document Object Model Level 2
Core.
The DOM Level 2 Traversal and Range specification is composed
of two modules. The two modules contain specialized interfaces
dedicated to traversing the document structure and identifying
and manipulating a range in a document.
W3C IPR SOFTWARE NOTICE
Copyright © 2000 World Wide Web
Consortium, (Massachusetts
Institute of Technology, Institut
National de Recherche en Informatique et en Automatique, Keio University). All Rights
Reserved.
The DOM bindings are published under the W3C Software Copyright Notice
and License. The software license requires "Notice of any changes or
modifications to the W3C files, including the date changes were made."
Consequently, modified versions of the DOM bindings must document that
they do not conform to the W3C standard; in the case of the IDL binding,
the pragma prefix can no longer be 'w3c.org'; in the case of the Java
binding, the package names can no longer be in the 'org.w3c' package.
Note: The original version of the W3C Software Copyright Notice
and License could be found at http://www.w3.org/Consortium/Legal/copyright-software-19980720
This W3C work (including software, documents, or other related items) is
being provided by the copyright holders under the following license. By
obtaining, using and/or copying this work, you (the licensee) agree that
you have read, understood, and will comply with the following terms and
conditions:
Permission to use, copy, and modify this software and its documentation,
with or without modification, for any purpose and without fee or
royalty is hereby granted, provided that you include the following on ALL
copies of the software and documentation or portions thereof, including
modifications, that you make:
The full text of this NOTICE in a location viewable to users of the
redistributed or derivative work.
Any pre-existing intellectual property disclaimers, notices, or terms
and conditions. If none exist, a short notice of the following form
(hypertext is preferred, text is permitted) should be used within the
body of any redistributed or derivative code: "Copyright ©
[$date-of-software] World Wide Web
Consortium, (Massachusetts
Institute of Technology, Institut
National de Recherche en Informatique et en Automatique, Keio University). All Rights
Reserved. http://www.w3.org/Consortium/Legal/"
Notice of any changes or modifications to the W3C files, including the
date changes were made. (We recommend you provide URIs to the location
from which the code is derived.)
THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT
HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR
DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
TRADEMARKS OR OTHER RIGHTS.
COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR
DOCUMENTATION.
The name and trademarks of copyright holders may NOT be used in
advertising or publicity pertaining to the software without specific,
written prior permission. Title to copyright in this software and any
associated documentation will at all times remain with copyright
holders.
|
org.xml.sax.HandlerBase (1 method)
HandlerBase.endDocument()
endDocument
public void endDocument()
throws SAXException
Deprecated.
Receive notification of the end of the document.
By default, do nothing. Application writers may override this method in a subclass to take specific actions at the end beginning of a document (such as finalising a tree or closing an output file).
Specified by:
endDocument
in interface DocumentHandler
Throws:
SAXException
- Any SAX exception, possibly wrapping another exception.
See Also:
DocumentHandler.endDocument()
|
endDocument
public void endDocument()
throws SAXException
Deprecated.
Receive notification of the end of the document.
By default, do nothing. Application writers may override this
method in a subclass to take specific actions at the beginning
of a document (such as finalising a tree or closing an output
file).
Specified by:
endDocument in interface DocumentHandler
Throws:
SAXException - Any SAX exception, possibly
wrapping another exception.
See Also:
DocumentHandler.endDocument()
|
endDocument
public void endDocument()
throws SAXException
Deprecated.
Receive notification of the end of the document.
By default, do nothing. Application writers may override this
method in a subclass to take specific actions at the end
of a document (such as finalising a tree or closing an output
file).
Specified by:
endDocument in interface DocumentHandler
Throws:
SAXException - Any SAX exception, possibly
wrapping another exception.
See Also:
DocumentHandler.endDocument()
|
org.xml.sax.ext.DefaultHandler2 (1 method)
DefaultHandler2.resolveEntity(java.lang.String, java.lang.String)
resolveEntity
public InputSource resolveEntity(java.lang.String publicId,
java.lang.String systemId)
throws SAXException,
java.io.IOException
Invokes EntityResolver2.resolveEntity()
with null entity name and base URI. You only need to override that method to use this class.
Specified by:
resolveEntity
in interface EntityResolver
Overrides:
resolveEntity
in class DefaultHandler
Parameters:
publicId
- The public identifier, identifer, or null if none is available.
systemId
- The system identifier provided in the XML document.
Returns:
The new input source, or null to require the default behaviour.
Throws:
SAXException
- Any SAX exception, possibly wrapping another exception.
java.io.IOException
- A Java-specific IO exception, possibly the result of creating a new InputStream or Reader for the InputSource.
See Also:
EntityResolver.resolveEntity(java.lang.String, java.lang.String)
|
resolveEntity
public InputSource resolveEntity(java.lang.String publicId,
java.lang.String systemId)
throws SAXException,
java.io.IOException
Invokes
EntityResolver2.resolveEntity()
with null entity name and base URI.
You only need to override that method to use this class.
Specified by:
resolveEntity in interface EntityResolver
Overrides:
resolveEntity in class DefaultHandler
Parameters:
publicId - The public identifer, or null if none is
available.
systemId - The system identifier provided in the XML
document.
Returns:
The new input source, or null to require the
default behaviour.
Throws:
SAXException - Any SAX exception, possibly
wrapping another exception.
java.io.IOException - A Java-specific IO exception,
possibly the result of creating a new InputStream
or Reader for the InputSource.
See Also:
EntityResolver.resolveEntity(java.lang.String, java.lang.String)
|
resolveEntity
public InputSource resolveEntity(java.lang.String publicId,
java.lang.String systemId)
throws SAXException,
java.io.IOException
Invokes
EntityResolver2.resolveEntity()
with null entity name and base URI.
You only need to override that method to use this class.
Specified by:
resolveEntity in interface EntityResolver
Overrides:
resolveEntity in class DefaultHandler
Parameters:
publicId - The public identifier, or null if none is
available.
systemId - The system identifier provided in the XML
document.
Returns:
The new input source, or null to require the
default behaviour.
Throws:
SAXException - Any SAX exception, possibly
wrapping another exception.
java.io.IOException - A Java-specific IO exception,
possibly the result of creating a new InputStream
or Reader for the InputSource.
See Also:
EntityResolver.resolveEntity(java.lang.String, java.lang.String)
|
org.xml.sax.helpers.DefaultHandler (2 methods)
error(org.xml.sax.SAXParseException) resolveEntity(java.lang.String, java.lang.String)
DefaultHandler.error(org.xml.sax.SAXParseException)
DefaultHandler.resolveEntity(java.lang.String, java.lang.String)
resolveEntity
public InputSource resolveEntity(java.lang.String publicId,
java.lang.String systemId)
throws java.io.IOException,
SAXException
Resolve an external entity.
Always return null, so that the parser will use the system identifier provided in the XML document. This method implements the SAX default behaviour: application writers can override it in a subclass to do special translations such as catalog lookups or URI redirection.
Specified by:
resolveEntity
in interface EntityResolver
Parameters:
publicId
- The public identifier, identifer, or null if none is available.
systemId
- The system identifier provided in the XML document.
Returns:
The new input source, or null to require the default behaviour.
Throws:
java.io.IOException
- If there is an error setting up the new input source.
SAXException
- Any SAX exception, possibly wrapping another exception.
See Also:
EntityResolver.resolveEntity(java.lang.String, java.lang.String)
|
resolveEntity
public InputSource resolveEntity(java.lang.String publicId,
java.lang.String systemId)
throws java.io.IOException,
SAXException
Resolve an external entity.
Always return null, so that the parser will use the system
identifier provided in the XML document. This method implements
the SAX default behaviour: application writers can override it
in a subclass to do special translations such as catalog lookups
or URI redirection.
Specified by:
resolveEntity in interface EntityResolver
Parameters:
publicId - The public identifer, or null if none is
available.
systemId - The system identifier provided in the XML
document.
Returns:
The new input source, or null to require the
default behaviour.
Throws:
java.io.IOException - If there is an error setting
up the new input source.
SAXException - Any SAX exception, possibly
wrapping another exception.
See Also:
EntityResolver.resolveEntity(java.lang.String, java.lang.String)
|
resolveEntity
public InputSource resolveEntity(java.lang.String publicId,
java.lang.String systemId)
throws java.io.IOException,
SAXException
Resolve an external entity.
Always return null, so that the parser will use the system
identifier provided in the XML document. This method implements
the SAX default behaviour: application writers can override it
in a subclass to do special translations such as catalog lookups
or URI redirection.
Specified by:
resolveEntity in interface EntityResolver
Parameters:
publicId - The public identifier, or null if none is
available.
systemId - The system identifier provided in the XML
document.
Returns:
The new input source, or null to require the
default behaviour.
Throws:
java.io.IOException - If there is an error setting
up the new input source.
SAXException - Any SAX exception, possibly
wrapping another exception.
See Also:
EntityResolver.resolveEntity(java.lang.String, java.lang.String)
|
|
|