mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 11:04:34 +02:00
8042244: Re-examine the supportedness of non-SE org.w3c.dom.** API
Reviewed-by: mchung, alanb, lancea
This commit is contained in:
parent
3334a718c9
commit
b6cd67bd3b
103 changed files with 159 additions and 1740 deletions
|
@ -108,32 +108,6 @@ public class CoreDOMImplementationImpl
|
||||||
|
|
||||||
boolean anyVersion = version == null || version.length() == 0;
|
boolean anyVersion = version == null || version.length() == 0;
|
||||||
|
|
||||||
// check if Xalan implementation is around and if yes report true for supporting
|
|
||||||
// XPath API
|
|
||||||
// if a plus sign "+" is prepended to any feature name, implementations
|
|
||||||
// are considered in which the specified feature may not be directly
|
|
||||||
// castable DOMImplementation.getFeature(feature, version). Without a
|
|
||||||
// plus, only features whose interfaces are directly castable are considered.
|
|
||||||
if ((feature.equalsIgnoreCase("+XPath"))
|
|
||||||
&& (anyVersion || version.equals("3.0"))) {
|
|
||||||
try {
|
|
||||||
Class xpathClass = ObjectFactory.findProviderClass(
|
|
||||||
"com.sun.org.apache.xpath.internal.domapi.XPathEvaluatorImpl", true);
|
|
||||||
|
|
||||||
// Check if the DOM XPath implementation implements
|
|
||||||
// the interface org.w3c.dom.XPathEvaluator
|
|
||||||
Class interfaces[] = xpathClass.getInterfaces();
|
|
||||||
for (int i = 0; i < interfaces.length; i++) {
|
|
||||||
if (interfaces[i].getName().equals(
|
|
||||||
"org.w3c.dom.xpath.XPathEvaluator")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (feature.startsWith("+")) {
|
if (feature.startsWith("+")) {
|
||||||
feature = feature.substring(1);
|
feature = feature.substring(1);
|
||||||
}
|
}
|
||||||
|
@ -281,25 +255,7 @@ public class CoreDOMImplementationImpl
|
||||||
*/
|
*/
|
||||||
public Object getFeature(String feature, String version) {
|
public Object getFeature(String feature, String version) {
|
||||||
if (singleton.hasFeature(feature, version)) {
|
if (singleton.hasFeature(feature, version)) {
|
||||||
if ((feature.equalsIgnoreCase("+XPath"))) {
|
return singleton;
|
||||||
try {
|
|
||||||
Class xpathClass = ObjectFactory.findProviderClass(
|
|
||||||
"com.sun.org.apache.xpath.internal.domapi.XPathEvaluatorImpl", true);
|
|
||||||
// Check if the DOM XPath implementation implements
|
|
||||||
// the interface org.w3c.dom.XPathEvaluator
|
|
||||||
Class interfaces[] = xpathClass.getInterfaces();
|
|
||||||
for (int i = 0; i < interfaces.length; i++) {
|
|
||||||
if (interfaces[i].getName().equals(
|
|
||||||
"org.w3c.dom.xpath.XPathEvaluator")) {
|
|
||||||
return xpathClass.newInstance();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return singleton;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -498,44 +498,6 @@ extends ParentNode implements Document {
|
||||||
* @since DOM Level 3
|
* @since DOM Level 3
|
||||||
*/
|
*/
|
||||||
public Object getFeature(String feature, String version) {
|
public Object getFeature(String feature, String version) {
|
||||||
|
|
||||||
boolean anyVersion = version == null || version.length() == 0;
|
|
||||||
|
|
||||||
// if a plus sign "+" is prepended to any feature name, implementations
|
|
||||||
// are considered in which the specified feature may not be directly
|
|
||||||
// castable DOMImplementation.getFeature(feature, version). Without a
|
|
||||||
// plus, only features whose interfaces are directly castable are
|
|
||||||
// considered.
|
|
||||||
if ((feature.equalsIgnoreCase("+XPath"))
|
|
||||||
&& (anyVersion || version.equals("3.0"))) {
|
|
||||||
|
|
||||||
// If an XPathEvaluator was created previously
|
|
||||||
// return it otherwise create a new one.
|
|
||||||
if (fXPathEvaluator != null) {
|
|
||||||
return fXPathEvaluator;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Class xpathClass = ObjectFactory.findProviderClass (
|
|
||||||
"com.sun.org.apache.xpath.internal.domapi.XPathEvaluatorImpl", true);
|
|
||||||
Constructor xpathClassConstr =
|
|
||||||
xpathClass.getConstructor(new Class[] { Document.class });
|
|
||||||
|
|
||||||
// Check if the DOM XPath implementation implements
|
|
||||||
// the interface org.w3c.dom.XPathEvaluator
|
|
||||||
Class interfaces[] = xpathClass.getInterfaces();
|
|
||||||
for (int i = 0; i < interfaces.length; i++) {
|
|
||||||
if (interfaces[i].getName().equals(
|
|
||||||
"org.w3c.dom.xpath.XPathEvaluator")) {
|
|
||||||
fXPathEvaluator = xpathClassConstr.newInstance(new Object[] { this });
|
|
||||||
return fXPathEvaluator;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
} catch (Exception e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return super.getFeature(feature, version);
|
return super.getFeature(feature, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,6 @@ import java.io.UnsupportedEncodingException;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.DocumentType;
|
import org.w3c.dom.DocumentType;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.html.HTMLDocument;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -273,45 +272,6 @@ public class OutputFormat
|
||||||
setIndenting( indenting );
|
setIndenting( indenting );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new output format with the proper method,
|
|
||||||
* document type identifiers and media type for the specified
|
|
||||||
* document.
|
|
||||||
*
|
|
||||||
* @param doc The document to output
|
|
||||||
* @see #whichMethod
|
|
||||||
*/
|
|
||||||
public OutputFormat( Document doc )
|
|
||||||
{
|
|
||||||
setMethod( whichMethod( doc ) );
|
|
||||||
setDoctype( whichDoctypePublic( doc ), whichDoctypeSystem( doc ) );
|
|
||||||
setMediaType( whichMediaType( getMethod() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new output format with the proper method,
|
|
||||||
* document type identifiers and media type for the specified
|
|
||||||
* document, and with the specified encoding. If <tt>indent</tt>
|
|
||||||
* is true, the document will be pretty printed with the default
|
|
||||||
* indentation level and default line wrapping.
|
|
||||||
*
|
|
||||||
* @param doc The document to output
|
|
||||||
* @param encoding The specified encoding
|
|
||||||
* @param indenting True for pretty printing
|
|
||||||
* @see #setEncoding
|
|
||||||
* @see #setIndenting
|
|
||||||
* @see #whichMethod
|
|
||||||
*/
|
|
||||||
public OutputFormat( Document doc, String encoding, boolean indenting )
|
|
||||||
{
|
|
||||||
this( doc );
|
|
||||||
setEncoding( encoding );
|
|
||||||
setIndenting( indenting );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the method specified for this output format.
|
* Returns the method specified for this output format.
|
||||||
* Typically the method will be <tt>xml</tt>, <tt>html</tt>
|
* Typically the method will be <tt>xml</tt>, <tt>html</tt>
|
||||||
|
@ -840,110 +800,6 @@ public class OutputFormat
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine the output method for the specified document.
|
|
||||||
* If the document is an instance of {@link org.w3c.dom.html.HTMLDocument}
|
|
||||||
* then the method is said to be <tt>html</tt>. If the root
|
|
||||||
* element is 'html' and all text nodes preceding the root
|
|
||||||
* element are all whitespace, then the method is said to be
|
|
||||||
* <tt>html</tt>. Otherwise the method is <tt>xml</tt>.
|
|
||||||
*
|
|
||||||
* @param doc The document to check
|
|
||||||
* @return The suitable method
|
|
||||||
*/
|
|
||||||
public static String whichMethod( Document doc )
|
|
||||||
{
|
|
||||||
Node node;
|
|
||||||
String value;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
// If document is derived from HTMLDocument then the default
|
|
||||||
// method is html.
|
|
||||||
if ( doc instanceof HTMLDocument )
|
|
||||||
return Method.HTML;
|
|
||||||
|
|
||||||
// Lookup the root element and the text nodes preceding it.
|
|
||||||
// If root element is html and all text nodes contain whitespace
|
|
||||||
// only, the method is html.
|
|
||||||
|
|
||||||
// FIXME (SM) should we care about namespaces here?
|
|
||||||
|
|
||||||
node = doc.getFirstChild();
|
|
||||||
while (node != null) {
|
|
||||||
// If the root element is html, the method is html.
|
|
||||||
if ( node.getNodeType() == Node.ELEMENT_NODE ) {
|
|
||||||
if ( node.getNodeName().equalsIgnoreCase( "html" ) ) {
|
|
||||||
return Method.HTML;
|
|
||||||
} else if ( node.getNodeName().equalsIgnoreCase( "root" ) ) {
|
|
||||||
return Method.FOP;
|
|
||||||
} else {
|
|
||||||
return Method.XML;
|
|
||||||
}
|
|
||||||
} else if ( node.getNodeType() == Node.TEXT_NODE ) {
|
|
||||||
// If a text node preceding the root element contains
|
|
||||||
// only whitespace, this might be html, otherwise it's
|
|
||||||
// definitely xml.
|
|
||||||
value = node.getNodeValue();
|
|
||||||
for ( i = 0 ; i < value.length() ; ++i )
|
|
||||||
if ( value.charAt( i ) != 0x20 && value.charAt( i ) != 0x0A &&
|
|
||||||
value.charAt( i ) != 0x09 && value.charAt( i ) != 0x0D )
|
|
||||||
return Method.XML;
|
|
||||||
}
|
|
||||||
node = node.getNextSibling();
|
|
||||||
}
|
|
||||||
// Anything else, the method is xml.
|
|
||||||
return Method.XML;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the document type public identifier
|
|
||||||
* specified for this document, or null.
|
|
||||||
*/
|
|
||||||
public static String whichDoctypePublic( Document doc )
|
|
||||||
{
|
|
||||||
DocumentType doctype;
|
|
||||||
|
|
||||||
/* DOM Level 2 was introduced into the code base*/
|
|
||||||
doctype = doc.getDoctype();
|
|
||||||
if ( doctype != null ) {
|
|
||||||
// Note on catch: DOM Level 1 does not specify this method
|
|
||||||
// and the code will throw a NoSuchMethodError
|
|
||||||
try {
|
|
||||||
return doctype.getPublicId();
|
|
||||||
} catch ( Error except ) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( doc instanceof HTMLDocument )
|
|
||||||
return DTD.XHTMLPublicId;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the document type system identifier
|
|
||||||
* specified for this document, or null.
|
|
||||||
*/
|
|
||||||
public static String whichDoctypeSystem( Document doc )
|
|
||||||
{
|
|
||||||
DocumentType doctype;
|
|
||||||
|
|
||||||
/* DOM Level 2 was introduced into the code base*/
|
|
||||||
doctype = doc.getDoctype();
|
|
||||||
if ( doctype != null ) {
|
|
||||||
// Note on catch: DOM Level 1 does not specify this method
|
|
||||||
// and the code will throw a NoSuchMethodError
|
|
||||||
try {
|
|
||||||
return doctype.getSystemId();
|
|
||||||
} catch ( Error except ) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( doc instanceof HTMLDocument )
|
|
||||||
return DTD.XHTMLSystemId;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the suitable media format for a document
|
* Returns the suitable media format for a document
|
||||||
* output with the specified method.
|
* output with the specified method.
|
||||||
|
|
|
@ -637,26 +637,8 @@ class Lexer
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// To older XPath code it doesn't matter if
|
m_processor.error(XPATHErrorResources.ER_PREFIX_MUST_RESOLVE,
|
||||||
// error() is called or errorForDOM3().
|
new String[] {prefix}); //"Prefix must resolve to a namespace: {0}";
|
||||||
m_processor.errorForDOM3(XPATHErrorResources.ER_PREFIX_MUST_RESOLVE,
|
|
||||||
new String[] {prefix}); //"Prefix must resolve to a namespace: {0}";
|
|
||||||
|
|
||||||
/** old code commented out 17-Sep-2004
|
|
||||||
// error("Could not locate namespace for prefix: "+prefix);
|
|
||||||
// m_processor.error(XPATHErrorResources.ER_PREFIX_MUST_RESOLVE,
|
|
||||||
// new String[] {prefix}); //"Prefix must resolve to a namespace: {0}";
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*** Old code commented out 10-Jan-2001
|
|
||||||
addToTokenQueue(prefix);
|
|
||||||
addToTokenQueue(":");
|
|
||||||
|
|
||||||
String s = pat.substring(posOfNSSep + 1, posOfScan);
|
|
||||||
|
|
||||||
if (s.length() > 0)
|
|
||||||
addToTokenQueue(s);
|
|
||||||
***/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -28,7 +28,6 @@ import javax.xml.transform.TransformerException;
|
||||||
import com.sun.org.apache.xalan.internal.res.XSLMessages;
|
import com.sun.org.apache.xalan.internal.res.XSLMessages;
|
||||||
import com.sun.org.apache.xml.internal.utils.PrefixResolver;
|
import com.sun.org.apache.xml.internal.utils.PrefixResolver;
|
||||||
import com.sun.org.apache.xpath.internal.XPathProcessorException;
|
import com.sun.org.apache.xpath.internal.XPathProcessorException;
|
||||||
import com.sun.org.apache.xpath.internal.domapi.XPathStylesheetDOM3Exception;
|
|
||||||
import com.sun.org.apache.xpath.internal.objects.XNumber;
|
import com.sun.org.apache.xpath.internal.objects.XNumber;
|
||||||
import com.sun.org.apache.xpath.internal.objects.XString;
|
import com.sun.org.apache.xpath.internal.objects.XString;
|
||||||
import com.sun.org.apache.xpath.internal.res.XPATHErrorResources;
|
import com.sun.org.apache.xpath.internal.res.XPATHErrorResources;
|
||||||
|
@ -622,50 +621,6 @@ public class XPathParser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is added to support DOM 3 XPath API.
|
|
||||||
* <p>
|
|
||||||
* This method is exactly like error(String, Object[]); except that
|
|
||||||
* the underlying TransformerException is
|
|
||||||
* XpathStylesheetDOM3Exception (which extends TransformerException).
|
|
||||||
* <p>
|
|
||||||
* So older XPath code in Xalan is not affected by this. To older XPath code
|
|
||||||
* the behavior of whether error() or errorForDOM3() is called because it is
|
|
||||||
* always catching TransformerException objects and is oblivious to
|
|
||||||
* the new subclass of XPathStylesheetDOM3Exception. Older XPath code
|
|
||||||
* runs as before.
|
|
||||||
* <p>
|
|
||||||
* However, newer DOM3 XPath code upon catching a TransformerException can
|
|
||||||
* can check if the exception is an instance of XPathStylesheetDOM3Exception
|
|
||||||
* and take appropriate action.
|
|
||||||
*
|
|
||||||
* @param msg An error msgkey that corresponds to one of the constants found
|
|
||||||
* in {@link com.sun.org.apache.xpath.internal.res.XPATHErrorResources}, which is
|
|
||||||
* a key for a format string.
|
|
||||||
* @param args An array of arguments represented in the format string, which
|
|
||||||
* may be null.
|
|
||||||
*
|
|
||||||
* @throws TransformerException if the current ErrorListoner determines to
|
|
||||||
* throw an exception.
|
|
||||||
*/
|
|
||||||
void errorForDOM3(String msg, Object[] args) throws TransformerException
|
|
||||||
{
|
|
||||||
|
|
||||||
String fmsg = XSLMessages.createXPATHMessage(msg, args);
|
|
||||||
ErrorListener ehandler = this.getErrorListener();
|
|
||||||
|
|
||||||
TransformerException te = new XPathStylesheetDOM3Exception(fmsg, m_sourceLocator);
|
|
||||||
if (null != ehandler)
|
|
||||||
{
|
|
||||||
// TO DO: Need to get stylesheet Locator from here.
|
|
||||||
ehandler.fatalError(te);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// System.err.println(fmsg);
|
|
||||||
throw te;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Dump the remaining token queue.
|
* Dump the remaining token queue.
|
||||||
* Thanks to Craig for this.
|
* Thanks to Craig for this.
|
||||||
|
|
|
@ -1,273 +0,0 @@
|
||||||
/*
|
|
||||||
* reserved comment block
|
|
||||||
* DO NOT REMOVE OR ALTER!
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Copyright 2002-2005 The Apache Software Foundation.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* $Id: XPathEvaluatorImpl.java,v 1.2.4.1 2005/09/10 04:04:07 jeffsuttor Exp $
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.sun.org.apache.xpath.internal.domapi;
|
|
||||||
|
|
||||||
import javax.xml.transform.TransformerException;
|
|
||||||
|
|
||||||
import com.sun.org.apache.xml.internal.utils.PrefixResolver;
|
|
||||||
import com.sun.org.apache.xpath.internal.XPath;
|
|
||||||
import com.sun.org.apache.xpath.internal.res.XPATHErrorResources;
|
|
||||||
import com.sun.org.apache.xpath.internal.res.XPATHMessages;
|
|
||||||
import org.w3c.dom.DOMException;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Node;
|
|
||||||
import org.w3c.dom.xpath.XPathEvaluator;
|
|
||||||
import org.w3c.dom.xpath.XPathException;
|
|
||||||
import org.w3c.dom.xpath.XPathExpression;
|
|
||||||
import org.w3c.dom.xpath.XPathNSResolver;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* The class provides an implementation of XPathEvaluator according
|
|
||||||
* to the DOM L3 XPath Specification, Working Group Note 26 February 2004.
|
|
||||||
*
|
|
||||||
* <p>See also the <a href='http://www.w3.org/TR/2004/NOTE-DOM-Level-3-XPath-20040226'>Document Object Model (DOM) Level 3 XPath Specification</a>.</p>
|
|
||||||
*
|
|
||||||
* </p>The evaluation of XPath expressions is provided by
|
|
||||||
* <code>XPathEvaluator</code>, which will provide evaluation of XPath 1.0
|
|
||||||
* expressions with no specialized extension functions or variables. It is
|
|
||||||
* expected that the <code>XPathEvaluator</code> interface will be
|
|
||||||
* implemented on the same object which implements the <code>Document</code>
|
|
||||||
* interface in an implementation which supports the XPath DOM module.
|
|
||||||
* <code>XPathEvaluator</code> implementations may be available from other
|
|
||||||
* sources that may provide support for special extension functions or
|
|
||||||
* variables which are not defined in this specification.</p>
|
|
||||||
*
|
|
||||||
* @see org.w3c.dom.xpath.XPathEvaluator
|
|
||||||
*
|
|
||||||
* @xsl.usage internal
|
|
||||||
*/
|
|
||||||
public final class XPathEvaluatorImpl implements XPathEvaluator {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This prefix resolver is created whenever null is passed to the
|
|
||||||
* evaluate method. Its purpose is to satisfy the DOM L3 XPath API
|
|
||||||
* requirement that if a null prefix resolver is used, an exception
|
|
||||||
* should only be thrown when an attempt is made to resolve a prefix.
|
|
||||||
*/
|
|
||||||
private class DummyPrefixResolver implements PrefixResolver {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for DummyPrefixResolver.
|
|
||||||
*/
|
|
||||||
DummyPrefixResolver() {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @exception DOMException
|
|
||||||
* NAMESPACE_ERR: Always throws this exceptionn
|
|
||||||
*
|
|
||||||
* @see com.sun.org.apache.xml.internal.utils.PrefixResolver#getNamespaceForPrefix(String, Node)
|
|
||||||
*/
|
|
||||||
public String getNamespaceForPrefix(String prefix, Node context) {
|
|
||||||
String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_NULL_RESOLVER, null);
|
|
||||||
throw new DOMException(DOMException.NAMESPACE_ERR, fmsg); // Unable to resolve prefix with null prefix resolver.
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @exception DOMException
|
|
||||||
* NAMESPACE_ERR: Always throws this exceptionn
|
|
||||||
*
|
|
||||||
* @see com.sun.org.apache.xml.internal.utils.PrefixResolver#getNamespaceForPrefix(String)
|
|
||||||
*/
|
|
||||||
public String getNamespaceForPrefix(String prefix) {
|
|
||||||
return getNamespaceForPrefix(prefix,null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see com.sun.org.apache.xml.internal.utils.PrefixResolver#handlesNullPrefixes()
|
|
||||||
*/
|
|
||||||
public boolean handlesNullPrefixes() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see com.sun.org.apache.xml.internal.utils.PrefixResolver#getBaseIdentifier()
|
|
||||||
*/
|
|
||||||
public String getBaseIdentifier() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The document to be searched to parallel the case where the XPathEvaluator
|
|
||||||
* is obtained by casting a Document.
|
|
||||||
*/
|
|
||||||
private final Document m_doc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for XPathEvaluatorImpl.
|
|
||||||
*
|
|
||||||
* @param doc The document to be searched, to parallel the case where''
|
|
||||||
* the XPathEvaluator is obtained by casting the document.
|
|
||||||
*/
|
|
||||||
public XPathEvaluatorImpl(Document doc) {
|
|
||||||
m_doc = doc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor in the case that the XPath expression can be evaluated
|
|
||||||
* without needing an XML document at all.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public XPathEvaluatorImpl() {
|
|
||||||
m_doc = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a parsed XPath expression with resolved namespaces. This is
|
|
||||||
* useful when an expression will be reused in an application since it
|
|
||||||
* makes it possible to compile the expression string into a more
|
|
||||||
* efficient internal form and preresolve all namespace prefixes which
|
|
||||||
* occur within the expression.
|
|
||||||
*
|
|
||||||
* @param expression The XPath expression string to be parsed.
|
|
||||||
* @param resolver The <code>resolver</code> permits translation of
|
|
||||||
* prefixes within the XPath expression into appropriate namespace URIs
|
|
||||||
* . If this is specified as <code>null</code>, any namespace prefix
|
|
||||||
* within the expression will result in <code>DOMException</code>
|
|
||||||
* being thrown with the code <code>NAMESPACE_ERR</code>.
|
|
||||||
* @return The compiled form of the XPath expression.
|
|
||||||
* @exception XPathException
|
|
||||||
* INVALID_EXPRESSION_ERR: Raised if the expression is not legal
|
|
||||||
* according to the rules of the <code>XPathEvaluator</code>i
|
|
||||||
* @exception DOMException
|
|
||||||
* NAMESPACE_ERR: Raised if the expression contains namespace prefixes
|
|
||||||
* which cannot be resolved by the specified
|
|
||||||
* <code>XPathNSResolver</code>.
|
|
||||||
*
|
|
||||||
* @see org.w3c.dom.xpath.XPathEvaluator#createExpression(String, XPathNSResolver)
|
|
||||||
*/
|
|
||||||
public XPathExpression createExpression(
|
|
||||||
String expression,
|
|
||||||
XPathNSResolver resolver)
|
|
||||||
throws XPathException, DOMException {
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
// If the resolver is null, create a dummy prefix resolver
|
|
||||||
XPath xpath = new XPath(expression,null,
|
|
||||||
((null == resolver) ? new DummyPrefixResolver() : ((PrefixResolver)resolver)),
|
|
||||||
XPath.SELECT);
|
|
||||||
|
|
||||||
return new XPathExpressionImpl(xpath, m_doc);
|
|
||||||
|
|
||||||
} catch (TransformerException e) {
|
|
||||||
// Need to pass back exception code DOMException.NAMESPACE_ERR also.
|
|
||||||
// Error found in DOM Level 3 XPath Test Suite.
|
|
||||||
if(e instanceof XPathStylesheetDOM3Exception)
|
|
||||||
throw new DOMException(DOMException.NAMESPACE_ERR,e.getMessageAndLocation());
|
|
||||||
else
|
|
||||||
throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,e.getMessageAndLocation());
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adapts any DOM node to resolve namespaces so that an XPath expression
|
|
||||||
* can be easily evaluated relative to the context of the node where it
|
|
||||||
* appeared within the document. This adapter works like the DOM Level 3
|
|
||||||
* method <code>lookupNamespaceURI</code> on nodes in resolving the
|
|
||||||
* namespaceURI from a given prefix using the current information available
|
|
||||||
* in the node's hierarchy at the time lookupNamespaceURI is called, also
|
|
||||||
* correctly resolving the implicit xml prefix.
|
|
||||||
*
|
|
||||||
* @param nodeResolver The node to be used as a context for namespace
|
|
||||||
* resolution.
|
|
||||||
* @return <code>XPathNSResolver</code> which resolves namespaces with
|
|
||||||
* respect to the definitions in scope for a specified node.
|
|
||||||
*
|
|
||||||
* @see org.w3c.dom.xpath.XPathEvaluator#createNSResolver(Node)
|
|
||||||
*/
|
|
||||||
public XPathNSResolver createNSResolver(Node nodeResolver) {
|
|
||||||
|
|
||||||
return new XPathNSResolverImpl((nodeResolver.getNodeType() == Node.DOCUMENT_NODE)
|
|
||||||
? ((Document) nodeResolver).getDocumentElement() : nodeResolver);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Evaluates an XPath expression string and returns a result of the
|
|
||||||
* specified type if possible.
|
|
||||||
*
|
|
||||||
* @param expression The XPath expression string to be parsed and
|
|
||||||
* evaluated.
|
|
||||||
* @param contextNode The <code>context</code> is context node for the
|
|
||||||
* evaluation of this XPath expression. If the XPathEvaluator was
|
|
||||||
* obtained by casting the <code>Document</code> then this must be
|
|
||||||
* owned by the same document and must be a <code>Document</code>,
|
|
||||||
* <code>Element</code>, <code>Attribute</code>, <code>Text</code>,
|
|
||||||
* <code>CDATASection</code>, <code>Comment</code>,
|
|
||||||
* <code>ProcessingInstruction</code>, or <code>XPathNamespace</code>
|
|
||||||
* node. If the context node is a <code>Text</code> or a
|
|
||||||
* <code>CDATASection</code>, then the context is interpreted as the
|
|
||||||
* whole logical text node as seen by XPath, unless the node is empty
|
|
||||||
* in which case it may not serve as the XPath context.
|
|
||||||
* @param resolver The <code>resolver</code> permits translation of
|
|
||||||
* prefixes within the XPath expression into appropriate namespace URIs
|
|
||||||
* . If this is specified as <code>null</code>, any namespace prefix
|
|
||||||
* within the expression will result in <code>DOMException</code>
|
|
||||||
* being thrown with the code <code>NAMESPACE_ERR</code>.
|
|
||||||
* @param type If a specific <code>type</code> is specified, then the
|
|
||||||
* result will be coerced to return the specified type relying on
|
|
||||||
* XPath type conversions and fail if the desired coercion is not
|
|
||||||
* possible. This must be one of the type codes of
|
|
||||||
* <code>XPathResult</code>.
|
|
||||||
* @param result The <code>result</code> specifies a specific result
|
|
||||||
* object which may be reused and returned by this method. If this is
|
|
||||||
* specified as <code>null</code>or the implementation does not reuse
|
|
||||||
* the specified result, a new result object will be constructed and
|
|
||||||
* returned.For XPath 1.0 results, this object will be of type
|
|
||||||
* <code>XPathResult</code>.
|
|
||||||
* @return The result of the evaluation of the XPath expression.For XPath
|
|
||||||
* 1.0 results, this object will be of type <code>XPathResult</code>.
|
|
||||||
* @exception XPathException
|
|
||||||
* INVALID_EXPRESSION_ERR: Raised if the expression is not legal
|
|
||||||
* according to the rules of the <code>XPathEvaluator</code>i
|
|
||||||
* <br>TYPE_ERR: Raised if the result cannot be converted to return the
|
|
||||||
* specified type.
|
|
||||||
* @exception DOMException
|
|
||||||
* NAMESPACE_ERR: Raised if the expression contains namespace prefixes
|
|
||||||
* which cannot be resolved by the specified
|
|
||||||
* <code>XPathNSResolver</code>.
|
|
||||||
* <br>WRONG_DOCUMENT_ERR: The Node is from a document that is not
|
|
||||||
* supported by this XPathEvaluator.
|
|
||||||
* <br>NOT_SUPPORTED_ERR: The Node is not a type permitted as an XPath
|
|
||||||
* context node.
|
|
||||||
*
|
|
||||||
* @see org.w3c.dom.xpath.XPathEvaluator#evaluate(String, Node, XPathNSResolver, short, XPathResult)
|
|
||||||
*/
|
|
||||||
public Object evaluate(
|
|
||||||
String expression,
|
|
||||||
Node contextNode,
|
|
||||||
XPathNSResolver resolver,
|
|
||||||
short type,
|
|
||||||
Object result)
|
|
||||||
throws XPathException, DOMException {
|
|
||||||
|
|
||||||
XPathExpression xpathExpression = createExpression(expression, resolver);
|
|
||||||
|
|
||||||
return xpathExpression.evaluate(contextNode, type, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,185 +0,0 @@
|
||||||
/*
|
|
||||||
* reserved comment block
|
|
||||||
* DO NOT REMOVE OR ALTER!
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Copyright 2002-2005 The Apache Software Foundation.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* $Id: XPathExpressionImpl.java,v 1.2.4.1 2005/09/10 04:06:55 jeffsuttor Exp $
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
package com.sun.org.apache.xpath.internal.domapi;
|
|
||||||
|
|
||||||
import javax.xml.transform.TransformerException;
|
|
||||||
|
|
||||||
import com.sun.org.apache.xpath.internal.XPath;
|
|
||||||
import com.sun.org.apache.xpath.internal.XPathContext;
|
|
||||||
import com.sun.org.apache.xpath.internal.objects.XObject;
|
|
||||||
import com.sun.org.apache.xpath.internal.res.XPATHErrorResources;
|
|
||||||
import com.sun.org.apache.xpath.internal.res.XPATHMessages;
|
|
||||||
import org.w3c.dom.DOMException;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Node;
|
|
||||||
import org.w3c.dom.xpath.XPathException;
|
|
||||||
import org.w3c.dom.xpath.XPathExpression;
|
|
||||||
import org.w3c.dom.xpath.XPathNamespace;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* The class provides an implementation of XPathExpression according
|
|
||||||
* to the DOM L3 XPath Specification, Working Group Note 26 February 2004.
|
|
||||||
*
|
|
||||||
* <p>See also the <a href='http://www.w3.org/TR/2004/NOTE-DOM-Level-3-XPath-20040226'>Document Object Model (DOM) Level 3 XPath Specification</a>.</p>
|
|
||||||
*
|
|
||||||
* <p>The <code>XPathExpression</code> interface represents a parsed and resolved
|
|
||||||
* XPath expression.</p>
|
|
||||||
*
|
|
||||||
* @see org.w3c.dom.xpath.XPathExpression
|
|
||||||
*
|
|
||||||
* @xsl.usage internal
|
|
||||||
*/
|
|
||||||
class XPathExpressionImpl implements XPathExpression {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The xpath object that this expression wraps
|
|
||||||
*/
|
|
||||||
final private XPath m_xpath;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The document to be searched to parallel the case where the XPathEvaluator
|
|
||||||
* is obtained by casting a Document.
|
|
||||||
*/
|
|
||||||
final private Document m_doc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for XPathExpressionImpl.
|
|
||||||
*
|
|
||||||
* @param xpath The wrapped XPath object.
|
|
||||||
* @param doc The document to be searched, to parallel the case where''
|
|
||||||
* the XPathEvaluator is obtained by casting the document.
|
|
||||||
*/
|
|
||||||
XPathExpressionImpl(XPath xpath, Document doc) {
|
|
||||||
m_xpath = xpath;
|
|
||||||
m_doc = doc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* This method provides an implementation XPathResult.evaluate according
|
|
||||||
* to the DOM L3 XPath Specification, Working Group Note 26 February 2004.
|
|
||||||
*
|
|
||||||
* <p>See also the <a href='http://www.w3.org/TR/2004/NOTE-DOM-Level-3-XPath-20040226'>Document Object Model (DOM) Level 3 XPath Specification</a>.</p>
|
|
||||||
*
|
|
||||||
* <p>Evaluates this XPath expression and returns a result.</p>
|
|
||||||
* @param contextNode The <code>context</code> is context node for the
|
|
||||||
* evaluation of this XPath expression.If the XPathEvaluator was
|
|
||||||
* obtained by casting the <code>Document</code> then this must be
|
|
||||||
* owned by the same document and must be a <code>Document</code>,
|
|
||||||
* <code>Element</code>, <code>Attribute</code>, <code>Text</code>,
|
|
||||||
* <code>CDATASection</code>, <code>Comment</code>,
|
|
||||||
* <code>ProcessingInstruction</code>, or <code>XPathNamespace</code>
|
|
||||||
* node.If the context node is a <code>Text</code> or a
|
|
||||||
* <code>CDATASection</code>, then the context is interpreted as the
|
|
||||||
* whole logical text node as seen by XPath, unless the node is empty
|
|
||||||
* in which case it may not serve as the XPath context.
|
|
||||||
* @param type If a specific <code>type</code> is specified, then the
|
|
||||||
* result will be coerced to return the specified type relying on
|
|
||||||
* XPath conversions and fail if the desired coercion is not possible.
|
|
||||||
* This must be one of the type codes of <code>XPathResult</code>.
|
|
||||||
* @param result The <code>result</code> specifies a specific result
|
|
||||||
* object which may be reused and returned by this method. If this is
|
|
||||||
* specified as <code>null</code>or the implementation does not reuse
|
|
||||||
* the specified result, a new result object will be constructed and
|
|
||||||
* returned.For XPath 1.0 results, this object will be of type
|
|
||||||
* <code>XPathResult</code>.
|
|
||||||
* @return The result of the evaluation of the XPath expression.For XPath
|
|
||||||
* 1.0 results, this object will be of type <code>XPathResult</code>.
|
|
||||||
* @exception XPathException
|
|
||||||
* TYPE_ERR: Raised if the result cannot be converted to return the
|
|
||||||
* specified type.
|
|
||||||
* @exception DOMException
|
|
||||||
* WRONG_DOCUMENT_ERR: The Node is from a document that is not supported
|
|
||||||
* by the XPathEvaluator that created this
|
|
||||||
* <code>XPathExpression</code>.
|
|
||||||
* <br>NOT_SUPPORTED_ERR: The Node is not a type permitted as an XPath
|
|
||||||
* context node.
|
|
||||||
*
|
|
||||||
* @see org.w3c.dom.xpath.XPathExpression#evaluate(Node, short, XPathResult)
|
|
||||||
* @xsl.usage internal
|
|
||||||
*/
|
|
||||||
public Object evaluate(
|
|
||||||
Node contextNode,
|
|
||||||
short type,
|
|
||||||
Object result)
|
|
||||||
throws XPathException, DOMException {
|
|
||||||
|
|
||||||
// If the XPathEvaluator was determined by "casting" the document
|
|
||||||
if (m_doc != null) {
|
|
||||||
|
|
||||||
// Check that the context node is owned by the same document
|
|
||||||
if ((contextNode != m_doc) && (!contextNode.getOwnerDocument().equals(m_doc))) {
|
|
||||||
String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_WRONG_DOCUMENT, null);
|
|
||||||
throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, fmsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check that the context node is an acceptable node type
|
|
||||||
short nodeType = contextNode.getNodeType();
|
|
||||||
if ((nodeType != Document.DOCUMENT_NODE) &&
|
|
||||||
(nodeType != Document.ELEMENT_NODE) &&
|
|
||||||
(nodeType != Document.ATTRIBUTE_NODE) &&
|
|
||||||
(nodeType != Document.TEXT_NODE) &&
|
|
||||||
(nodeType != Document.CDATA_SECTION_NODE) &&
|
|
||||||
(nodeType != Document.COMMENT_NODE) &&
|
|
||||||
(nodeType != Document.PROCESSING_INSTRUCTION_NODE) &&
|
|
||||||
(nodeType != XPathNamespace.XPATH_NAMESPACE_NODE)) {
|
|
||||||
String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_WRONG_NODETYPE, null);
|
|
||||||
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, fmsg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// If the type is not a supported type, throw an exception and be
|
|
||||||
// done with it!
|
|
||||||
if (!XPathResultImpl.isValidType(type)) {
|
|
||||||
String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_INVALID_XPATH_TYPE, new Object[] {new Integer(type)});
|
|
||||||
throw new XPathException(XPathException.TYPE_ERR,fmsg); // Invalid XPath type argument: {0}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cache xpath context?
|
|
||||||
XPathContext xpathSupport = new XPathContext();
|
|
||||||
|
|
||||||
// if m_document is not null, build the DTM from the document
|
|
||||||
if (null != m_doc) {
|
|
||||||
xpathSupport.getDTMHandleFromNode(m_doc);
|
|
||||||
}
|
|
||||||
|
|
||||||
XObject xobj = null;
|
|
||||||
try {
|
|
||||||
xobj = m_xpath.execute(xpathSupport, contextNode, null);
|
|
||||||
} catch (TransformerException te) {
|
|
||||||
// What should we do here?
|
|
||||||
throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,te.getMessageAndLocation());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a new XPathResult object
|
|
||||||
// Reuse result object passed in?
|
|
||||||
// The constructor will check the compatibility of type and xobj and
|
|
||||||
// throw an exception if they are not compatible.
|
|
||||||
return new XPathResultImpl(type,xobj,contextNode, m_xpath);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
/*
|
|
||||||
* reserved comment block
|
|
||||||
* DO NOT REMOVE OR ALTER!
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Copyright 2002-2005 The Apache Software Foundation.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* $Id: XPathNSResolverImpl.java,v 1.2.4.1 2005/09/10 04:13:19 jeffsuttor Exp $
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.sun.org.apache.xpath.internal.domapi;
|
|
||||||
|
|
||||||
import com.sun.org.apache.xml.internal.utils.PrefixResolverDefault;
|
|
||||||
import org.w3c.dom.Node;
|
|
||||||
import org.w3c.dom.xpath.XPathNSResolver;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* The class provides an implementation XPathNSResolver according
|
|
||||||
* to the DOM L3 XPath Specification, Working Group Note 26 February 2004.
|
|
||||||
*
|
|
||||||
* <p>See also the <a href='http://www.w3.org/TR/2004/NOTE-DOM-Level-3-XPath-20040226'>Document Object Model (DOM) Level 3 XPath Specification</a>.</p>
|
|
||||||
*
|
|
||||||
* <p>The <code>XPathNSResolver</code> interface permit <code>prefix</code>
|
|
||||||
* strings in the expression to be properly bound to
|
|
||||||
* <code>namespaceURI</code> strings. <code>XPathEvaluator</code> can
|
|
||||||
* construct an implementation of <code>XPathNSResolver</code> from a node,
|
|
||||||
* or the interface may be implemented by any application.</p>
|
|
||||||
*
|
|
||||||
* @see org.w3c.dom.xpath.XPathNSResolver
|
|
||||||
* @xsl.usage internal
|
|
||||||
*/
|
|
||||||
class XPathNSResolverImpl extends PrefixResolverDefault implements XPathNSResolver {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for XPathNSResolverImpl.
|
|
||||||
* @param xpathExpressionContext
|
|
||||||
*/
|
|
||||||
public XPathNSResolverImpl(Node xpathExpressionContext) {
|
|
||||||
super(xpathExpressionContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.xpath.XPathNSResolver#lookupNamespaceURI(String)
|
|
||||||
*/
|
|
||||||
public String lookupNamespaceURI(String prefix) {
|
|
||||||
return super.getNamespaceForPrefix(prefix);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,324 +0,0 @@
|
||||||
/*
|
|
||||||
* reserved comment block
|
|
||||||
* DO NOT REMOVE OR ALTER!
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Copyright 2002-2004 The Apache Software Foundation.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* $Id: XPathNamespaceImpl.java,v 1.2.4.1 2005/09/10 04:10:02 jeffsuttor Exp $
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
package com.sun.org.apache.xpath.internal.domapi;
|
|
||||||
|
|
||||||
import org.w3c.dom.Attr;
|
|
||||||
import org.w3c.dom.DOMException;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
import org.w3c.dom.NamedNodeMap;
|
|
||||||
import org.w3c.dom.Node;
|
|
||||||
import org.w3c.dom.NodeList;
|
|
||||||
import org.w3c.dom.xpath.XPathNamespace;
|
|
||||||
|
|
||||||
import org.w3c.dom.UserDataHandler;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* The <code>XPathNamespace</code> interface is returned by
|
|
||||||
* <code>XPathResult</code> interfaces to represent the XPath namespace node
|
|
||||||
* type that DOM lacks. There is no public constructor for this node type.
|
|
||||||
* Attempts to place it into a hierarchy or a NamedNodeMap result in a
|
|
||||||
* <code>DOMException</code> with the code <code>HIERARCHY_REQUEST_ERR</code>
|
|
||||||
* . This node is read only, so methods or setting of attributes that would
|
|
||||||
* mutate the node result in a DOMException with the code
|
|
||||||
* <code>NO_MODIFICATION_ALLOWED_ERR</code>.
|
|
||||||
* <p>The core specification describes attributes of the <code>Node</code>
|
|
||||||
* interface that are different for different node node types but does not
|
|
||||||
* describe <code>XPATH_NAMESPACE_NODE</code>, so here is a description of
|
|
||||||
* those attributes for this node type. All attributes of <code>Node</code>
|
|
||||||
* not described in this section have a <code>null</code> or
|
|
||||||
* <code>false</code> value.
|
|
||||||
* <p><code>ownerDocument</code> matches the <code>ownerDocument</code> of the
|
|
||||||
* <code>ownerElement</code> even if the element is later adopted.
|
|
||||||
* <p><code>prefix</code> is the prefix of the namespace represented by the
|
|
||||||
* node.
|
|
||||||
* <p><code>nodeName</code> is the same as <code>prefix</code>.
|
|
||||||
* <p><code>nodeType</code> is equal to <code>XPATH_NAMESPACE_NODE</code>.
|
|
||||||
* <p><code>namespaceURI</code> is the namespace URI of the namespace
|
|
||||||
* represented by the node.
|
|
||||||
* <p><code>adoptNode</code>, <code>cloneNode</code>, and
|
|
||||||
* <code>importNode</code> fail on this node type by raising a
|
|
||||||
* <code>DOMException</code> with the code <code>NOT_SUPPORTED_ERR</code>.In
|
|
||||||
* future versions of the XPath specification, the definition of a namespace
|
|
||||||
* node may be changed incomatibly, in which case incompatible changes to
|
|
||||||
* field values may be required to implement versions beyond XPath 1.0.
|
|
||||||
* <p>See also the <a href='http://www.w3.org/TR/2004/NOTE-DOM-Level-3-XPath-20040226'>Document Object Model (DOM) Level 3 XPath Specification</a>.
|
|
||||||
*
|
|
||||||
* This implementation wraps the DOM attribute node that contained the
|
|
||||||
* namespace declaration.
|
|
||||||
* @xsl.usage internal
|
|
||||||
*/
|
|
||||||
|
|
||||||
class XPathNamespaceImpl implements XPathNamespace {
|
|
||||||
|
|
||||||
// Node that XPathNamespaceImpl wraps
|
|
||||||
final private Node m_attributeNode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for XPathNamespaceImpl.
|
|
||||||
*/
|
|
||||||
XPathNamespaceImpl(Node node) {
|
|
||||||
m_attributeNode = node;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see com.sun.org.apache.xalan.internal.dom3.xpath.XPathNamespace#getOwnerElement()
|
|
||||||
*/
|
|
||||||
public Element getOwnerElement() {
|
|
||||||
return ((Attr)m_attributeNode).getOwnerElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.Node#getNodeName()
|
|
||||||
*/
|
|
||||||
public String getNodeName() {
|
|
||||||
return "#namespace";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.Node#getNodeValue()
|
|
||||||
*/
|
|
||||||
public String getNodeValue() throws DOMException {
|
|
||||||
return m_attributeNode.getNodeValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.Node#setNodeValue(String)
|
|
||||||
*/
|
|
||||||
public void setNodeValue(String arg0) throws DOMException {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.Node#getNodeType()
|
|
||||||
*/
|
|
||||||
public short getNodeType() {
|
|
||||||
return XPathNamespace.XPATH_NAMESPACE_NODE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.Node#getParentNode()
|
|
||||||
*/
|
|
||||||
public Node getParentNode() {
|
|
||||||
return m_attributeNode.getParentNode();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.Node#getChildNodes()
|
|
||||||
*/
|
|
||||||
public NodeList getChildNodes() {
|
|
||||||
return m_attributeNode.getChildNodes();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.Node#getFirstChild()
|
|
||||||
*/
|
|
||||||
public Node getFirstChild() {
|
|
||||||
return m_attributeNode.getFirstChild();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.Node#getLastChild()
|
|
||||||
*/
|
|
||||||
public Node getLastChild() {
|
|
||||||
return m_attributeNode.getLastChild();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.Node#getPreviousSibling()
|
|
||||||
*/
|
|
||||||
public Node getPreviousSibling() {
|
|
||||||
return m_attributeNode.getPreviousSibling();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.Node#getNextSibling()
|
|
||||||
*/
|
|
||||||
public Node getNextSibling() {
|
|
||||||
return m_attributeNode.getNextSibling();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.Node#getAttributes()
|
|
||||||
*/
|
|
||||||
public NamedNodeMap getAttributes() {
|
|
||||||
return m_attributeNode.getAttributes();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.Node#getOwnerDocument()
|
|
||||||
*/
|
|
||||||
public Document getOwnerDocument() {
|
|
||||||
return m_attributeNode.getOwnerDocument();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.Node#insertBefore(Node, Node)
|
|
||||||
*/
|
|
||||||
public Node insertBefore(Node arg0, Node arg1) throws DOMException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.Node#replaceChild(Node, Node)
|
|
||||||
*/
|
|
||||||
public Node replaceChild(Node arg0, Node arg1) throws DOMException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.Node#removeChild(Node)
|
|
||||||
*/
|
|
||||||
public Node removeChild(Node arg0) throws DOMException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.Node#appendChild(Node)
|
|
||||||
*/
|
|
||||||
public Node appendChild(Node arg0) throws DOMException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.Node#hasChildNodes()
|
|
||||||
*/
|
|
||||||
public boolean hasChildNodes() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.Node#cloneNode(boolean)
|
|
||||||
*/
|
|
||||||
public Node cloneNode(boolean arg0) {
|
|
||||||
throw new DOMException(DOMException.NOT_SUPPORTED_ERR,null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.Node#normalize()
|
|
||||||
*/
|
|
||||||
public void normalize() {
|
|
||||||
m_attributeNode.normalize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.Node#isSupported(String, String)
|
|
||||||
*/
|
|
||||||
public boolean isSupported(String arg0, String arg1) {
|
|
||||||
return m_attributeNode.isSupported(arg0, arg1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.Node#getNamespaceURI()
|
|
||||||
*/
|
|
||||||
public String getNamespaceURI() {
|
|
||||||
|
|
||||||
// For namespace node, the namespaceURI is the namespace URI
|
|
||||||
// of the namespace represented by the node.
|
|
||||||
return m_attributeNode.getNodeValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.Node#getPrefix()
|
|
||||||
*/
|
|
||||||
public String getPrefix() {
|
|
||||||
return m_attributeNode.getPrefix();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.Node#setPrefix(String)
|
|
||||||
*/
|
|
||||||
public void setPrefix(String arg0) throws DOMException {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.Node#getLocalName()
|
|
||||||
*/
|
|
||||||
public String getLocalName() {
|
|
||||||
|
|
||||||
// For namespace node, the local name is the same as the prefix
|
|
||||||
return m_attributeNode.getPrefix();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.Node#hasAttributes()
|
|
||||||
*/
|
|
||||||
public boolean hasAttributes() {
|
|
||||||
return m_attributeNode.hasAttributes();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBaseURI ( ) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public short compareDocumentPosition(Node other) throws DOMException {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String textContent;
|
|
||||||
|
|
||||||
public String getTextContent() throws DOMException {
|
|
||||||
return textContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTextContent(String textContent) throws DOMException {
|
|
||||||
this.textContent = textContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSameNode(Node other) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String lookupPrefix(String namespaceURI) {
|
|
||||||
return ""; //PENDING
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDefaultNamespace(String namespaceURI) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String lookupNamespaceURI(String prefix) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEqualNode(Node arg) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getFeature(String feature, String version) {
|
|
||||||
return null; //PENDING
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object setUserData(String key,
|
|
||||||
Object data,
|
|
||||||
UserDataHandler handler) {
|
|
||||||
return null; //PENDING
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getUserData(String key) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,512 +0,0 @@
|
||||||
/*
|
|
||||||
* reserved comment block
|
|
||||||
* DO NOT REMOVE OR ALTER!
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Copyright 2002-2005 The Apache Software Foundation.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* $Id: XPathResultImpl.java,v 1.2.4.1 2005/09/10 04:18:54 jeffsuttor Exp $
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
package com.sun.org.apache.xpath.internal.domapi;
|
|
||||||
|
|
||||||
import javax.xml.transform.TransformerException;
|
|
||||||
|
|
||||||
import com.sun.org.apache.xpath.internal.XPath;
|
|
||||||
import com.sun.org.apache.xpath.internal.objects.XObject;
|
|
||||||
import com.sun.org.apache.xpath.internal.res.XPATHErrorResources;
|
|
||||||
import com.sun.org.apache.xpath.internal.res.XPATHMessages;
|
|
||||||
import org.w3c.dom.DOMException;
|
|
||||||
import org.w3c.dom.Node;
|
|
||||||
import org.w3c.dom.NodeList;
|
|
||||||
import org.w3c.dom.events.Event;
|
|
||||||
import org.w3c.dom.events.EventListener;
|
|
||||||
import org.w3c.dom.events.EventTarget;
|
|
||||||
import org.w3c.dom.traversal.NodeIterator;
|
|
||||||
import org.w3c.dom.xpath.XPathException;
|
|
||||||
import org.w3c.dom.xpath.XPathResult;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* The class provides an implementation XPathResult according
|
|
||||||
* to the DOM L3 XPath Specification, Working Group Note 26 February 2004.
|
|
||||||
*
|
|
||||||
* <p>See also the <a href='http://www.w3.org/TR/2004/NOTE-DOM-Level-3-XPath-20040226'>Document Object Model (DOM) Level 3 XPath Specification</a>.</p>
|
|
||||||
*
|
|
||||||
* <p>The <code>XPathResult</code> interface represents the result of the
|
|
||||||
* evaluation of an XPath expression within the context of a particular
|
|
||||||
* node. Since evaluation of an XPath expression can result in various
|
|
||||||
* result types, this object makes it possible to discover and manipulate
|
|
||||||
* the type and value of the result.</p>
|
|
||||||
*
|
|
||||||
* <p>This implementation wraps an <code>XObject</code>.
|
|
||||||
*
|
|
||||||
* @see com.sun.org.apache.xpath.internal.objects.XObject
|
|
||||||
* @see org.w3c.dom.xpath.XPathResult
|
|
||||||
*
|
|
||||||
* @xsl.usage internal
|
|
||||||
*/
|
|
||||||
class XPathResultImpl implements XPathResult, EventListener {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The wrapped XObject
|
|
||||||
*/
|
|
||||||
final private XObject m_resultObj;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The xpath object that wraps the expression used for this result.
|
|
||||||
*/
|
|
||||||
final private XPath m_xpath;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This the type specified by the user during construction. Typically
|
|
||||||
* the constructor will be called by com.sun.org.apache.xpath.internal.XPath.evaluate().
|
|
||||||
*/
|
|
||||||
final private short m_resultType;
|
|
||||||
|
|
||||||
private boolean m_isInvalidIteratorState = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Only used to attach a mutation event handler when specified
|
|
||||||
* type is an iterator type.
|
|
||||||
*/
|
|
||||||
final private Node m_contextNode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The iterator, if this is an iterator type.
|
|
||||||
*/
|
|
||||||
private NodeIterator m_iterator = null;;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The list, if this is a snapshot type.
|
|
||||||
*/
|
|
||||||
private NodeList m_list = null;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for XPathResultImpl.
|
|
||||||
*
|
|
||||||
* For internal use only.
|
|
||||||
*/
|
|
||||||
XPathResultImpl(short type, XObject result, Node contextNode, XPath xpath) {
|
|
||||||
// Check that the type is valid
|
|
||||||
if (!isValidType(type)) {
|
|
||||||
String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_INVALID_XPATH_TYPE, new Object[] {new Integer(type)});
|
|
||||||
throw new XPathException(XPathException.TYPE_ERR,fmsg); // Invalid XPath type argument: {0}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Result object should never be null!
|
|
||||||
if (null == result) {
|
|
||||||
String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_EMPTY_XPATH_RESULT, null);
|
|
||||||
throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,fmsg); // Empty XPath result object
|
|
||||||
}
|
|
||||||
|
|
||||||
this.m_resultObj = result;
|
|
||||||
this.m_contextNode = contextNode;
|
|
||||||
this.m_xpath = xpath;
|
|
||||||
|
|
||||||
// If specified result was ANY_TYPE, determine XObject type
|
|
||||||
if (type == ANY_TYPE) {
|
|
||||||
this.m_resultType = getTypeFromXObject(result);
|
|
||||||
} else {
|
|
||||||
this.m_resultType = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the context node supports DOM Events and the type is one of the iterator
|
|
||||||
// types register this result as an event listener
|
|
||||||
if (((m_resultType == XPathResult.ORDERED_NODE_ITERATOR_TYPE) ||
|
|
||||||
(m_resultType == XPathResult.UNORDERED_NODE_ITERATOR_TYPE))) {
|
|
||||||
addEventListener();
|
|
||||||
|
|
||||||
}// else can we handle iterator types if contextNode doesn't support EventTarget??
|
|
||||||
|
|
||||||
// If this is an iterator type get the iterator
|
|
||||||
if ((m_resultType == ORDERED_NODE_ITERATOR_TYPE) ||
|
|
||||||
(m_resultType == UNORDERED_NODE_ITERATOR_TYPE) ||
|
|
||||||
(m_resultType == ANY_UNORDERED_NODE_TYPE) ||
|
|
||||||
(m_resultType == FIRST_ORDERED_NODE_TYPE)) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
m_iterator = m_resultObj.nodeset();
|
|
||||||
} catch (TransformerException te) {
|
|
||||||
// probably not a node type
|
|
||||||
String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_INCOMPATIBLE_TYPES, new Object[] {m_xpath.getPatternString(), getTypeString(getTypeFromXObject(m_resultObj)),getTypeString(m_resultType)});
|
|
||||||
throw new XPathException(XPathException.TYPE_ERR, fmsg); // "The XPathResult of XPath expression {0} has an XPathResultType of {1} which cannot be coerced into the specified XPathResultType of {2}."},
|
|
||||||
}
|
|
||||||
|
|
||||||
// If user requested ordered nodeset and result is unordered
|
|
||||||
// need to sort...TODO
|
|
||||||
// if ((m_resultType == ORDERED_NODE_ITERATOR_TYPE) &&
|
|
||||||
// (!(((DTMNodeIterator)m_iterator).getDTMIterator().isDocOrdered()))) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
// If it's a snapshot type, get the nodelist
|
|
||||||
} else if ((m_resultType == UNORDERED_NODE_SNAPSHOT_TYPE) ||
|
|
||||||
(m_resultType == ORDERED_NODE_SNAPSHOT_TYPE)) {
|
|
||||||
try {
|
|
||||||
m_list = m_resultObj.nodelist();
|
|
||||||
} catch (TransformerException te) {
|
|
||||||
// probably not a node type
|
|
||||||
String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_INCOMPATIBLE_TYPES, new Object[] {m_xpath.getPatternString(), getTypeString(getTypeFromXObject(m_resultObj)),getTypeString(m_resultType)});
|
|
||||||
throw new XPathException(XPathException.TYPE_ERR, fmsg); // "The XPathResult of XPath expression {0} has an XPathResultType of {1} which cannot be coerced into the specified XPathResultType of {2}."},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.xpath.XPathResult#getResultType()
|
|
||||||
*/
|
|
||||||
public short getResultType() {
|
|
||||||
return m_resultType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The value of this number result.
|
|
||||||
* @exception XPathException
|
|
||||||
* TYPE_ERR: raised if <code>resultType</code> is not
|
|
||||||
* <code>NUMBER_TYPE</code>.
|
|
||||||
* @see org.w3c.dom.xpath.XPathResult#getNumberValue()
|
|
||||||
*/
|
|
||||||
public double getNumberValue() throws XPathException {
|
|
||||||
if (getResultType() != NUMBER_TYPE) {
|
|
||||||
String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_CANT_CONVERT_XPATHRESULTTYPE_TO_NUMBER, new Object[] {m_xpath.getPatternString(), getTypeString(m_resultType)});
|
|
||||||
throw new XPathException(XPathException.TYPE_ERR,fmsg);
|
|
||||||
// "The XPathResult of XPath expression {0} has an XPathResultType of {1} which cannot be converted to a number"
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
return m_resultObj.num();
|
|
||||||
} catch (Exception e) {
|
|
||||||
// Type check above should prevent this exception from occurring.
|
|
||||||
throw new XPathException(XPathException.TYPE_ERR,e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The value of this string result.
|
|
||||||
* @exception XPathException
|
|
||||||
* TYPE_ERR: raised if <code>resultType</code> is not
|
|
||||||
* <code>STRING_TYPE</code>.
|
|
||||||
*
|
|
||||||
* @see org.w3c.dom.xpath.XPathResult#getStringValue()
|
|
||||||
*/
|
|
||||||
public String getStringValue() throws XPathException {
|
|
||||||
if (getResultType() != STRING_TYPE) {
|
|
||||||
String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_CANT_CONVERT_TO_STRING, new Object[] {m_xpath.getPatternString(), m_resultObj.getTypeString()});
|
|
||||||
throw new XPathException(XPathException.TYPE_ERR,fmsg);
|
|
||||||
// "The XPathResult of XPath expression {0} has an XPathResultType of {1} which cannot be converted to a string."
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
return m_resultObj.str();
|
|
||||||
} catch (Exception e) {
|
|
||||||
// Type check above should prevent this exception from occurring.
|
|
||||||
throw new XPathException(XPathException.TYPE_ERR,e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.xpath.XPathResult#getBooleanValue()
|
|
||||||
*/
|
|
||||||
public boolean getBooleanValue() throws XPathException {
|
|
||||||
if (getResultType() != BOOLEAN_TYPE) {
|
|
||||||
String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_CANT_CONVERT_TO_BOOLEAN, new Object[] {m_xpath.getPatternString(), getTypeString(m_resultType)});
|
|
||||||
throw new XPathException(XPathException.TYPE_ERR,fmsg);
|
|
||||||
// "The XPathResult of XPath expression {0} has an XPathResultType of {1} which cannot be converted to a boolean."
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
return m_resultObj.bool();
|
|
||||||
} catch (TransformerException e) {
|
|
||||||
// Type check above should prevent this exception from occurring.
|
|
||||||
throw new XPathException(XPathException.TYPE_ERR,e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The value of this single node result, which may be <code>null</code>.
|
|
||||||
* @exception XPathException
|
|
||||||
* TYPE_ERR: raised if <code>resultType</code> is not
|
|
||||||
* <code>ANY_UNORDERED_NODE_TYPE</code> or
|
|
||||||
* <code>FIRST_ORDERED_NODE_TYPE</code>.
|
|
||||||
*
|
|
||||||
* @see org.w3c.dom.xpath.XPathResult#getSingleNodeValue()
|
|
||||||
*/
|
|
||||||
public Node getSingleNodeValue() throws XPathException {
|
|
||||||
|
|
||||||
if ((m_resultType != ANY_UNORDERED_NODE_TYPE) &&
|
|
||||||
(m_resultType != FIRST_ORDERED_NODE_TYPE)) {
|
|
||||||
String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_CANT_CONVERT_TO_SINGLENODE, new Object[] {m_xpath.getPatternString(), getTypeString(m_resultType)});
|
|
||||||
throw new XPathException(XPathException.TYPE_ERR,fmsg);
|
|
||||||
// "The XPathResult of XPath expression {0} has an XPathResultType of {1} which cannot be converted to a single node.
|
|
||||||
// This method applies only to types ANY_UNORDERED_NODE_TYPE and FIRST_ORDERED_NODE_TYPE."
|
|
||||||
}
|
|
||||||
|
|
||||||
NodeIterator result = null;
|
|
||||||
try {
|
|
||||||
result = m_resultObj.nodeset();
|
|
||||||
} catch (TransformerException te) {
|
|
||||||
throw new XPathException(XPathException.TYPE_ERR,te.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null == result) return null;
|
|
||||||
|
|
||||||
Node node = result.nextNode();
|
|
||||||
|
|
||||||
// Wrap "namespace node" in an XPathNamespace
|
|
||||||
if (isNamespaceNode(node)) {
|
|
||||||
return new XPathNamespaceImpl(node);
|
|
||||||
} else {
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.xpath.XPathResult#getInvalidIteratorState()
|
|
||||||
*/
|
|
||||||
public boolean getInvalidIteratorState() {
|
|
||||||
return m_isInvalidIteratorState;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The number of nodes in the result snapshot. Valid values for
|
|
||||||
* snapshotItem indices are <code>0</code> to
|
|
||||||
* <code>snapshotLength-1</code> inclusive.
|
|
||||||
* @exception XPathException
|
|
||||||
* TYPE_ERR: raised if <code>resultType</code> is not
|
|
||||||
* <code>UNORDERED_NODE_SNAPSHOT_TYPE</code> or
|
|
||||||
* <code>ORDERED_NODE_SNAPSHOT_TYPE</code>.
|
|
||||||
*
|
|
||||||
* @see org.w3c.dom.xpath.XPathResult#getSnapshotLength()
|
|
||||||
*/
|
|
||||||
public int getSnapshotLength() throws XPathException {
|
|
||||||
|
|
||||||
if ((m_resultType != UNORDERED_NODE_SNAPSHOT_TYPE) &&
|
|
||||||
(m_resultType != ORDERED_NODE_SNAPSHOT_TYPE)) {
|
|
||||||
String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_CANT_GET_SNAPSHOT_LENGTH, new Object[] {m_xpath.getPatternString(), getTypeString(m_resultType)});
|
|
||||||
throw new XPathException(XPathException.TYPE_ERR,fmsg);
|
|
||||||
// "The method getSnapshotLength cannot be called on the XPathResult of XPath expression {0} because its XPathResultType is {1}.
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_list.getLength();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Iterates and returns the next node from the node set or
|
|
||||||
* <code>null</code>if there are no more nodes.
|
|
||||||
* @return Returns the next node.
|
|
||||||
* @exception XPathException
|
|
||||||
* TYPE_ERR: raised if <code>resultType</code> is not
|
|
||||||
* <code>UNORDERED_NODE_ITERATOR_TYPE</code> or
|
|
||||||
* <code>ORDERED_NODE_ITERATOR_TYPE</code>.
|
|
||||||
* @exception DOMException
|
|
||||||
* INVALID_STATE_ERR: The document has been mutated since the result was
|
|
||||||
* returned.
|
|
||||||
* @see org.w3c.dom.xpath.XPathResult#iterateNext()
|
|
||||||
*/
|
|
||||||
public Node iterateNext() throws XPathException, DOMException {
|
|
||||||
if ((m_resultType != UNORDERED_NODE_ITERATOR_TYPE) &&
|
|
||||||
(m_resultType != ORDERED_NODE_ITERATOR_TYPE)) {
|
|
||||||
String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_NON_ITERATOR_TYPE, new Object[] {m_xpath.getPatternString(), getTypeString(m_resultType)});
|
|
||||||
throw new XPathException(XPathException.TYPE_ERR, fmsg);
|
|
||||||
// "The method iterateNext cannot be called on the XPathResult of XPath expression {0} because its XPathResultType is {1}.
|
|
||||||
// This method applies only to types UNORDERED_NODE_ITERATOR_TYPE and ORDERED_NODE_ITERATOR_TYPE."},
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getInvalidIteratorState()) {
|
|
||||||
String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_DOC_MUTATED, null);
|
|
||||||
throw new DOMException(DOMException.INVALID_STATE_ERR,fmsg); // Document mutated since result was returned. Iterator is invalid.
|
|
||||||
}
|
|
||||||
|
|
||||||
Node node = m_iterator.nextNode();
|
|
||||||
if(null == node)
|
|
||||||
removeEventListener(); // JIRA 1673
|
|
||||||
// Wrap "namespace node" in an XPathNamespace
|
|
||||||
if (isNamespaceNode(node)) {
|
|
||||||
return new XPathNamespaceImpl(node);
|
|
||||||
} else {
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the <code>index</code>th item in the snapshot collection. If
|
|
||||||
* <code>index</code> is greater than or equal to the number of nodes in
|
|
||||||
* the list, this method returns <code>null</code>. Unlike the iterator
|
|
||||||
* result, the snapshot does not become invalid, but may not correspond
|
|
||||||
* to the current document if it is mutated.
|
|
||||||
* @param index Index into the snapshot collection.
|
|
||||||
* @return The node at the <code>index</code>th position in the
|
|
||||||
* <code>NodeList</code>, or <code>null</code> if that is not a valid
|
|
||||||
* index.
|
|
||||||
* @exception XPathException
|
|
||||||
* TYPE_ERR: raised if <code>resultType</code> is not
|
|
||||||
* <code>UNORDERED_NODE_SNAPSHOT_TYPE</code> or
|
|
||||||
* <code>ORDERED_NODE_SNAPSHOT_TYPE</code>.
|
|
||||||
*
|
|
||||||
* @see org.w3c.dom.xpath.XPathResult#snapshotItem(int)
|
|
||||||
*/
|
|
||||||
public Node snapshotItem(int index) throws XPathException {
|
|
||||||
|
|
||||||
if ((m_resultType != UNORDERED_NODE_SNAPSHOT_TYPE) &&
|
|
||||||
(m_resultType != ORDERED_NODE_SNAPSHOT_TYPE)) {
|
|
||||||
String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_NON_SNAPSHOT_TYPE, new Object[] {m_xpath.getPatternString(), getTypeString(m_resultType)});
|
|
||||||
throw new XPathException(XPathException.TYPE_ERR, fmsg);
|
|
||||||
// "The method snapshotItem cannot be called on the XPathResult of XPath expression {0} because its XPathResultType is {1}.
|
|
||||||
// This method applies only to types UNORDERED_NODE_SNAPSHOT_TYPE and ORDERED_NODE_SNAPSHOT_TYPE."},
|
|
||||||
}
|
|
||||||
|
|
||||||
Node node = m_list.item(index);
|
|
||||||
|
|
||||||
// Wrap "namespace node" in an XPathNamespace
|
|
||||||
if (isNamespaceNode(node)) {
|
|
||||||
return new XPathNamespaceImpl(node);
|
|
||||||
} else {
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the specified type is one of the supported types.
|
|
||||||
* @param type The specified type
|
|
||||||
*
|
|
||||||
* @return true If the specified type is supported; otherwise, returns false.
|
|
||||||
*/
|
|
||||||
static boolean isValidType( short type ) {
|
|
||||||
switch (type) {
|
|
||||||
case ANY_TYPE:
|
|
||||||
case NUMBER_TYPE:
|
|
||||||
case STRING_TYPE:
|
|
||||||
case BOOLEAN_TYPE:
|
|
||||||
case UNORDERED_NODE_ITERATOR_TYPE:
|
|
||||||
case ORDERED_NODE_ITERATOR_TYPE:
|
|
||||||
case UNORDERED_NODE_SNAPSHOT_TYPE:
|
|
||||||
case ORDERED_NODE_SNAPSHOT_TYPE:
|
|
||||||
case ANY_UNORDERED_NODE_TYPE:
|
|
||||||
case FIRST_ORDERED_NODE_TYPE: return true;
|
|
||||||
default: return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.w3c.dom.events.EventListener#handleEvent(Event)
|
|
||||||
*/
|
|
||||||
public void handleEvent(Event event) {
|
|
||||||
|
|
||||||
if (event.getType().equals("DOMSubtreeModified")) {
|
|
||||||
// invalidate the iterator
|
|
||||||
m_isInvalidIteratorState = true;
|
|
||||||
|
|
||||||
// deregister as a listener to reduce computational load
|
|
||||||
removeEventListener();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a request type, return the equivalent string.
|
|
||||||
* For diagnostic purposes.
|
|
||||||
*
|
|
||||||
* @return type string
|
|
||||||
*/
|
|
||||||
private String getTypeString(int type)
|
|
||||||
{
|
|
||||||
switch (type) {
|
|
||||||
case ANY_TYPE: return "ANY_TYPE";
|
|
||||||
case ANY_UNORDERED_NODE_TYPE: return "ANY_UNORDERED_NODE_TYPE";
|
|
||||||
case BOOLEAN_TYPE: return "BOOLEAN";
|
|
||||||
case FIRST_ORDERED_NODE_TYPE: return "FIRST_ORDERED_NODE_TYPE";
|
|
||||||
case NUMBER_TYPE: return "NUMBER_TYPE";
|
|
||||||
case ORDERED_NODE_ITERATOR_TYPE: return "ORDERED_NODE_ITERATOR_TYPE";
|
|
||||||
case ORDERED_NODE_SNAPSHOT_TYPE: return "ORDERED_NODE_SNAPSHOT_TYPE";
|
|
||||||
case STRING_TYPE: return "STRING_TYPE";
|
|
||||||
case UNORDERED_NODE_ITERATOR_TYPE: return "UNORDERED_NODE_ITERATOR_TYPE";
|
|
||||||
case UNORDERED_NODE_SNAPSHOT_TYPE: return "UNORDERED_NODE_SNAPSHOT_TYPE";
|
|
||||||
default: return "#UNKNOWN";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given an XObject, determine the corresponding DOM XPath type
|
|
||||||
*
|
|
||||||
* @return type string
|
|
||||||
*/
|
|
||||||
private short getTypeFromXObject(XObject object) {
|
|
||||||
switch (object.getType()) {
|
|
||||||
case XObject.CLASS_BOOLEAN: return BOOLEAN_TYPE;
|
|
||||||
case XObject.CLASS_NODESET: return UNORDERED_NODE_ITERATOR_TYPE;
|
|
||||||
case XObject.CLASS_NUMBER: return NUMBER_TYPE;
|
|
||||||
case XObject.CLASS_STRING: return STRING_TYPE;
|
|
||||||
// XPath 2.0 types
|
|
||||||
// case XObject.CLASS_DATE:
|
|
||||||
// case XObject.CLASS_DATETIME:
|
|
||||||
// case XObject.CLASS_DTDURATION:
|
|
||||||
// case XObject.CLASS_GDAY:
|
|
||||||
// case XObject.CLASS_GMONTH:
|
|
||||||
// case XObject.CLASS_GMONTHDAY:
|
|
||||||
// case XObject.CLASS_GYEAR:
|
|
||||||
// case XObject.CLASS_GYEARMONTH:
|
|
||||||
// case XObject.CLASS_TIME:
|
|
||||||
// case XObject.CLASS_YMDURATION: return STRING_TYPE; // treat all date types as strings?
|
|
||||||
|
|
||||||
case XObject.CLASS_RTREEFRAG: return UNORDERED_NODE_ITERATOR_TYPE;
|
|
||||||
case XObject.CLASS_NULL: return ANY_TYPE; // throw exception ?
|
|
||||||
default: return ANY_TYPE; // throw exception ?
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a node, determine if it is a namespace node.
|
|
||||||
*
|
|
||||||
* @param node
|
|
||||||
*
|
|
||||||
* @return boolean Returns true if this is a namespace node; otherwise, returns false.
|
|
||||||
*/
|
|
||||||
private boolean isNamespaceNode(Node node) {
|
|
||||||
|
|
||||||
if ((null != node) &&
|
|
||||||
(node.getNodeType() == Node.ATTRIBUTE_NODE) &&
|
|
||||||
(node.getNodeName().startsWith("xmlns:") || node.getNodeName().equals("xmlns"))) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add m_contextNode to Event Listner to listen for Mutations Events
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private void addEventListener(){
|
|
||||||
if(m_contextNode instanceof EventTarget)
|
|
||||||
((EventTarget)m_contextNode).addEventListener("DOMSubtreeModified",this,true);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove m_contextNode to Event Listner to listen for Mutations Events
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private void removeEventListener(){
|
|
||||||
if(m_contextNode instanceof EventTarget)
|
|
||||||
((EventTarget)m_contextNode).removeEventListener("DOMSubtreeModified",this,true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
/*
|
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
||||||
*
|
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License version 2 only, as
|
|
||||||
* published by the Free Software Foundation. Oracle designates this
|
|
||||||
* particular file as subject to the "Classpath" exception as provided
|
|
||||||
* by Oracle in the LICENSE file that accompanied this code.
|
|
||||||
*
|
|
||||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* version 2 for more details (a copy is included in the LICENSE file that
|
|
||||||
* accompanied this code).
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License version
|
|
||||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is available under and governed by the GNU General Public
|
|
||||||
* License version 2 only, as published by the Free Software Foundation.
|
|
||||||
* However, the following notice accompanied the original version of this
|
|
||||||
* file and, per its terms, should not be removed:
|
|
||||||
*
|
|
||||||
* Copyright (c) 2002 World Wide Web Consortium,
|
|
||||||
* (Massachusetts Institute of Technology, Institut National de
|
|
||||||
* Recherche en Informatique et en Automatique, Keio University). All
|
|
||||||
* Rights Reserved. This program is distributed under the W3C's Software
|
|
||||||
* Intellectual Property License. This program is distributed in the
|
|
||||||
* hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
|
||||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE.
|
|
||||||
* See W3C License http://www.w3.org/Consortium/Legal/ for more details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.sun.org.apache.xpath.internal.domapi;
|
|
||||||
|
|
||||||
import javax.xml.transform.SourceLocator;
|
|
||||||
import javax.xml.transform.TransformerException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* A new exception to add support for DOM Level 3 XPath API.
|
|
||||||
* This class is needed to throw a org.w3c.dom.DOMException with proper error code in
|
|
||||||
* createExpression method of XPathEvaluatorImpl (a DOM Level 3 class).
|
|
||||||
*
|
|
||||||
* This class extends TransformerException because the error message includes information
|
|
||||||
* about where the XPath problem is in the stylesheet as well as the XPath expression itself.
|
|
||||||
*
|
|
||||||
* @xsl.usage internal
|
|
||||||
*/
|
|
||||||
final public class XPathStylesheetDOM3Exception extends TransformerException {
|
|
||||||
public XPathStylesheetDOM3Exception(String msg, SourceLocator arg1)
|
|
||||||
{
|
|
||||||
super(msg, arg1);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
<!--
|
|
||||||
* reserved comment block
|
|
||||||
* DO NOT REMOVE OR ALTER!
|
|
||||||
-->
|
|
||||||
<!--
|
|
||||||
* Copyright 2000-2005 The Apache Software Foundation.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
-->
|
|
||||||
<!-- $Id: package.html,v 1.1.4.1 2005/09/07 22:27:28 jeffsuttor Exp $ -->
|
|
||||||
<html>
|
|
||||||
<title>XPath domapi Package.</title>
|
|
||||||
<body>
|
|
||||||
<p>Implements DOM Level 3 XPath API<p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
|
||||||
|
<title>W3C IPR SOFTWARE NOTICE</title>
|
||||||
|
<style type="text/css">
|
||||||
|
<!--
|
||||||
|
html, body { background: #fff; color: #000; } /* body for Windows IE3 */
|
||||||
|
-->
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>
|
||||||
|
W3C IPR SOFTWARE NOTICE
|
||||||
|
</h1>
|
||||||
|
<h3>
|
||||||
|
Copyright © 2002 <a href="http://www.w3.org/">World Wide Web
|
||||||
|
Consortium</a>, (<a href="http://www.lcs.mit.edu/">Massachusetts
|
||||||
|
Institute of Technology</a>, <a href="http://www.inria.fr/">Institut
|
||||||
|
National de Recherche en Informatique et en Automatique</a>, <a
|
||||||
|
href="http://www.keio.ac.jp/">Keio University</a>). All Rights
|
||||||
|
Reserved.
|
||||||
|
</h3>
|
||||||
|
<p>
|
||||||
|
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
|
||||||
|
definitions, the pragma prefix can no longer be 'w3c.org'; in the case of
|
||||||
|
the Java language binding, the package names can no longer be in the
|
||||||
|
'org.w3c' package.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<b>Note:</b> The original version of the W3C Software Copyright Notice
|
||||||
|
and License could be found at <a
|
||||||
|
href='http://www.w3.org/Consortium/Legal/copyright-software-19980720'>http://www.w3.org/Consortium/Legal/copyright-software-19980720</a>
|
||||||
|
</p>
|
||||||
|
<h3>
|
||||||
|
Copyright © 1994-2002 <a href="http://www.w3.org/">World Wide Web
|
||||||
|
Consortium</a>, (<a href="http://www.lcs.mit.edu/">Massachusetts
|
||||||
|
Institute of Technology</a>, <a href="http://www.inria.fr/">Institut
|
||||||
|
National de Recherche en Informatique et en Automatique</a>, <a
|
||||||
|
href="http://www.keio.ac.jp/">Keio University</a>). All Rights
|
||||||
|
Reserved. http://www.w3.org/Consortium/Legal/
|
||||||
|
</h3>
|
||||||
|
<p>
|
||||||
|
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:
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
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:
|
||||||
|
</p>
|
||||||
|
<ol>
|
||||||
|
<li>
|
||||||
|
The full text of this NOTICE in a location viewable to users of the
|
||||||
|
redistributed or derivative work.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
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] <a href="http://www.w3.org/">World Wide Web
|
||||||
|
Consortium</a>, (<a href="http://www.lcs.mit.edu/">Massachusetts
|
||||||
|
Institute of Technology</a>, <a href="http://www.inria.fr/">Institut
|
||||||
|
National de Recherche en Informatique et en Automatique</a>, <a
|
||||||
|
href="http://www.keio.ac.jp/">Keio University</a>). All Rights
|
||||||
|
Reserved. http://www.w3.org/Consortium/Legal/"
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
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.)
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
<p>
|
||||||
|
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.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
|
||||||
|
CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR
|
||||||
|
DOCUMENTATION.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
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.
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -47,6 +47,8 @@ package org.w3c.dom.xpath;
|
||||||
* <p>See also the <a href='http://www.w3.org/2002/08/WD-DOM-Level-3-XPath-20020820'>Document Object Model (DOM) Level 3 XPath Specification</a>.
|
* <p>See also the <a href='http://www.w3.org/2002/08/WD-DOM-Level-3-XPath-20020820'>Document Object Model (DOM) Level 3 XPath Specification</a>.
|
||||||
*/
|
*/
|
||||||
public class XPathException extends RuntimeException {
|
public class XPathException extends RuntimeException {
|
||||||
|
private static final long serialVersionUID = 3471034171575979943L;
|
||||||
|
|
||||||
public XPathException(short code, String message) {
|
public XPathException(short code, String message) {
|
||||||
super(message);
|
super(message);
|
||||||
this.code = code;
|
this.code = code;
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue