nokogiri 1.11.0.rc4-java → 1.11.5-java
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of nokogiri might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/LICENSE-DEPENDENCIES.md +12 -12
- data/LICENSE.md +1 -1
- data/README.md +168 -91
- data/dependencies.yml +12 -12
- data/ext/java/nokogiri/EncodingHandler.java +76 -89
- data/ext/java/nokogiri/HtmlDocument.java +135 -144
- data/ext/java/nokogiri/HtmlElementDescription.java +102 -117
- data/ext/java/nokogiri/HtmlEntityLookup.java +33 -60
- data/ext/java/nokogiri/HtmlSaxParserContext.java +218 -222
- data/ext/java/nokogiri/HtmlSaxPushParser.java +162 -169
- data/ext/java/nokogiri/NokogiriService.java +595 -556
- data/ext/java/nokogiri/XmlAttr.java +118 -126
- data/ext/java/nokogiri/XmlAttributeDecl.java +95 -106
- data/ext/java/nokogiri/XmlCdata.java +35 -58
- data/ext/java/nokogiri/XmlComment.java +46 -67
- data/ext/java/nokogiri/XmlDocument.java +645 -572
- data/ext/java/nokogiri/XmlDocumentFragment.java +125 -137
- data/ext/java/nokogiri/XmlDtd.java +448 -414
- data/ext/java/nokogiri/XmlElement.java +23 -48
- data/ext/java/nokogiri/XmlElementContent.java +343 -316
- data/ext/java/nokogiri/XmlElementDecl.java +124 -125
- data/ext/java/nokogiri/XmlEntityDecl.java +119 -127
- data/ext/java/nokogiri/XmlEntityReference.java +49 -72
- data/ext/java/nokogiri/XmlNamespace.java +175 -175
- data/ext/java/nokogiri/XmlNode.java +1843 -1620
- data/ext/java/nokogiri/XmlNodeSet.java +361 -331
- data/ext/java/nokogiri/XmlProcessingInstruction.java +47 -69
- data/ext/java/nokogiri/XmlReader.java +513 -450
- data/ext/java/nokogiri/XmlRelaxng.java +85 -104
- data/ext/java/nokogiri/XmlSaxParserContext.java +328 -315
- data/ext/java/nokogiri/XmlSaxPushParser.java +227 -220
- data/ext/java/nokogiri/XmlSchema.java +328 -295
- data/ext/java/nokogiri/XmlSyntaxError.java +113 -115
- data/ext/java/nokogiri/XmlText.java +55 -76
- data/ext/java/nokogiri/XmlXpathContext.java +240 -238
- data/ext/java/nokogiri/XsltStylesheet.java +280 -269
- data/ext/java/nokogiri/internals/ClosedStreamException.java +5 -2
- data/ext/java/nokogiri/internals/HtmlDomParserContext.java +201 -202
- data/ext/java/nokogiri/internals/IgnoreSchemaErrorsErrorHandler.java +17 -10
- data/ext/java/nokogiri/internals/NokogiriBlockingQueueInputStream.java +43 -16
- data/ext/java/nokogiri/internals/NokogiriDomParser.java +63 -80
- data/ext/java/nokogiri/internals/NokogiriEntityResolver.java +107 -88
- data/ext/java/nokogiri/internals/NokogiriErrorHandler.java +27 -52
- data/ext/java/nokogiri/internals/NokogiriHandler.java +316 -286
- data/ext/java/nokogiri/internals/NokogiriHelpers.java +736 -652
- data/ext/java/nokogiri/internals/NokogiriNamespaceCache.java +184 -173
- data/ext/java/nokogiri/internals/NokogiriNamespaceContext.java +81 -98
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java +64 -79
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java +84 -99
- data/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java +48 -65
- data/ext/java/nokogiri/internals/NokogiriXPathFunction.java +116 -131
- data/ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java +34 -56
- data/ext/java/nokogiri/internals/NokogiriXPathVariableResolver.java +23 -46
- data/ext/java/nokogiri/internals/NokogiriXsltErrorListener.java +55 -72
- data/ext/java/nokogiri/internals/ParserContext.java +206 -211
- data/ext/java/nokogiri/internals/ReaderNode.java +478 -403
- data/ext/java/nokogiri/internals/SaveContextVisitor.java +822 -739
- data/ext/java/nokogiri/internals/SchemaErrorHandler.java +31 -54
- data/ext/java/nokogiri/internals/XalanDTMManagerPatch.java +129 -123
- data/ext/java/nokogiri/internals/XmlDeclHandler.java +3 -34
- data/ext/java/nokogiri/internals/XmlDomParserContext.java +206 -207
- data/ext/java/nokogiri/internals/XmlSaxParser.java +22 -47
- data/ext/java/nokogiri/internals/c14n/AttrCompare.java +71 -68
- data/ext/java/nokogiri/internals/c14n/C14nHelper.java +137 -118
- data/ext/java/nokogiri/internals/c14n/CanonicalFilter.java +27 -21
- data/ext/java/nokogiri/internals/c14n/CanonicalizationException.java +74 -61
- data/ext/java/nokogiri/internals/c14n/Canonicalizer.java +230 -205
- data/ext/java/nokogiri/internals/c14n/Canonicalizer11.java +572 -547
- data/ext/java/nokogiri/internals/c14n/Canonicalizer11_OmitComments.java +17 -10
- data/ext/java/nokogiri/internals/c14n/Canonicalizer11_WithComments.java +17 -10
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315.java +323 -302
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315Excl.java +232 -219
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclOmitComments.java +22 -15
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclWithComments.java +23 -16
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315OmitComments.java +23 -16
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315WithComments.java +22 -15
- data/ext/java/nokogiri/internals/c14n/CanonicalizerBase.java +575 -545
- data/ext/java/nokogiri/internals/c14n/CanonicalizerPhysical.java +141 -120
- data/ext/java/nokogiri/internals/c14n/CanonicalizerSpi.java +39 -38
- data/ext/java/nokogiri/internals/c14n/Constants.java +13 -10
- data/ext/java/nokogiri/internals/c14n/ElementProxy.java +279 -247
- data/ext/java/nokogiri/internals/c14n/HelperNodeList.java +66 -53
- data/ext/java/nokogiri/internals/c14n/IgnoreAllErrorHandler.java +44 -37
- data/ext/java/nokogiri/internals/c14n/InclusiveNamespaces.java +135 -120
- data/ext/java/nokogiri/internals/c14n/InvalidCanonicalizerException.java +59 -48
- data/ext/java/nokogiri/internals/c14n/NameSpaceSymbTable.java +384 -334
- data/ext/java/nokogiri/internals/c14n/NodeFilter.java +25 -24
- data/ext/java/nokogiri/internals/c14n/UtfHelpper.java +151 -140
- data/ext/java/nokogiri/internals/c14n/XMLUtils.java +456 -423
- data/ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java +1466 -1500
- data/ext/java/nokogiri/internals/dom2dtm/DOM2DTMdefaultNamespaceDeclarationNode.java +626 -574
- data/ext/nokogiri/depend +34 -474
- data/ext/nokogiri/extconf.rb +270 -183
- data/ext/nokogiri/html_document.c +10 -15
- data/ext/nokogiri/html_element_description.c +84 -71
- data/ext/nokogiri/html_entity_lookup.c +21 -16
- data/ext/nokogiri/html_sax_parser_context.c +67 -64
- data/ext/nokogiri/html_sax_push_parser.c +42 -34
- data/ext/nokogiri/libxml2_backwards_compat.c +121 -0
- data/ext/nokogiri/nokogiri.c +190 -60
- data/ext/nokogiri/test_global_handlers.c +40 -0
- data/ext/nokogiri/xml_attr.c +15 -15
- data/ext/nokogiri/xml_attribute_decl.c +18 -18
- data/ext/nokogiri/xml_cdata.c +13 -18
- data/ext/nokogiri/xml_comment.c +19 -26
- data/ext/nokogiri/xml_document.c +246 -188
- data/ext/nokogiri/xml_document_fragment.c +13 -15
- data/ext/nokogiri/xml_dtd.c +54 -48
- data/ext/nokogiri/xml_element_content.c +30 -27
- data/ext/nokogiri/xml_element_decl.c +22 -22
- data/ext/nokogiri/xml_encoding_handler.c +17 -11
- data/ext/nokogiri/xml_entity_decl.c +32 -30
- data/ext/nokogiri/xml_entity_reference.c +16 -18
- data/ext/nokogiri/xml_namespace.c +56 -49
- data/ext/nokogiri/xml_node.c +371 -320
- data/ext/nokogiri/xml_node_set.c +168 -156
- data/ext/nokogiri/xml_processing_instruction.c +17 -19
- data/ext/nokogiri/xml_reader.c +191 -157
- data/ext/nokogiri/xml_relax_ng.c +29 -23
- data/ext/nokogiri/xml_sax_parser.c +117 -112
- data/ext/nokogiri/xml_sax_parser_context.c +101 -84
- data/ext/nokogiri/xml_sax_push_parser.c +36 -27
- data/ext/nokogiri/xml_schema.c +48 -42
- data/ext/nokogiri/xml_syntax_error.c +42 -21
- data/ext/nokogiri/xml_text.c +13 -17
- data/ext/nokogiri/xml_xpath_context.c +134 -127
- data/ext/nokogiri/xslt_stylesheet.c +157 -157
- data/lib/nokogiri.rb +2 -6
- data/lib/nokogiri/css/parser.rb +1 -1
- data/lib/nokogiri/extension.rb +26 -0
- data/lib/nokogiri/html/document_fragment.rb +15 -15
- data/lib/nokogiri/nokogiri.jar +0 -0
- data/lib/nokogiri/version/constant.rb +1 -1
- data/lib/nokogiri/version/info.rb +32 -8
- data/lib/nokogiri/xml/document.rb +74 -28
- data/lib/nokogiri/xml/node.rb +39 -42
- data/lib/nokogiri/xml/reader.rb +2 -9
- data/lib/nokogiri/xml/xpath.rb +1 -3
- data/lib/nokogiri/xml/xpath/syntax_error.rb +1 -1
- metadata +62 -127
- data/ext/nokogiri/xml_io.c +0 -63
- data/ext/nokogiri/xml_libxml2_hacks.c +0 -112
@@ -1,7 +1,3 @@
|
|
1
|
-
/*
|
2
|
-
* reserved comment block
|
3
|
-
* DO NOT REMOVE OR ALTER!
|
4
|
-
*/
|
5
1
|
/*
|
6
2
|
* Copyright 1999-2004 The Apache Software Foundation.
|
7
3
|
*
|
@@ -57,239 +53,279 @@ import org.w3c.dom.DOMException;
|
|
57
53
|
* in DTM space, but given how DOM2DTM is currently written I think
|
58
54
|
* this is simplest.
|
59
55
|
* */
|
60
|
-
public class DOM2DTMdefaultNamespaceDeclarationNode implements Attr,TypeInfo
|
56
|
+
public class DOM2DTMdefaultNamespaceDeclarationNode implements Attr, TypeInfo
|
61
57
|
{
|
62
|
-
final String NOT_SUPPORTED_ERR="Unsupported operation on pseudonode";
|
58
|
+
final String NOT_SUPPORTED_ERR = "Unsupported operation on pseudonode";
|
63
59
|
|
64
60
|
Element pseudoparent;
|
65
|
-
String prefix,uri,nodename;
|
61
|
+
String prefix, uri, nodename;
|
66
62
|
int handle;
|
67
|
-
DOM2DTMdefaultNamespaceDeclarationNode(Element pseudoparent,String prefix,String uri,int handle)
|
63
|
+
DOM2DTMdefaultNamespaceDeclarationNode(Element pseudoparent, String prefix, String uri, int handle)
|
68
64
|
{
|
69
|
-
this.pseudoparent=pseudoparent;
|
70
|
-
this.prefix=prefix;
|
71
|
-
this.uri=uri;
|
72
|
-
this.handle=handle;
|
73
|
-
this.nodename="xmlns:"+prefix;
|
65
|
+
this.pseudoparent = pseudoparent;
|
66
|
+
this.prefix = prefix;
|
67
|
+
this.uri = uri;
|
68
|
+
this.handle = handle;
|
69
|
+
this.nodename = "xmlns:" + prefix;
|
70
|
+
}
|
71
|
+
public String
|
72
|
+
getNodeName() {return nodename;}
|
73
|
+
public String
|
74
|
+
getName() {return nodename;}
|
75
|
+
public String
|
76
|
+
getNamespaceURI() {return "http://www.w3.org/2000/xmlns/";}
|
77
|
+
public String
|
78
|
+
getPrefix() {return prefix;}
|
79
|
+
public String
|
80
|
+
getLocalName() {return prefix;}
|
81
|
+
public String
|
82
|
+
getNodeValue() {return uri;}
|
83
|
+
public String
|
84
|
+
getValue() {return uri;}
|
85
|
+
public Element
|
86
|
+
getOwnerElement() {return pseudoparent;}
|
87
|
+
|
88
|
+
public boolean
|
89
|
+
isSupported(String feature, String version) {return false;}
|
90
|
+
public boolean
|
91
|
+
hasChildNodes() {return false;}
|
92
|
+
public boolean
|
93
|
+
hasAttributes() {return false;}
|
94
|
+
public Node
|
95
|
+
getParentNode() {return null;}
|
96
|
+
public Node
|
97
|
+
getFirstChild() {return null;}
|
98
|
+
public Node
|
99
|
+
getLastChild() {return null;}
|
100
|
+
public Node
|
101
|
+
getPreviousSibling() {return null;}
|
102
|
+
public Node
|
103
|
+
getNextSibling() {return null;}
|
104
|
+
public boolean
|
105
|
+
getSpecified() {return false;}
|
106
|
+
public void
|
107
|
+
normalize() {return;}
|
108
|
+
public NodeList
|
109
|
+
getChildNodes() {return null;}
|
110
|
+
public NamedNodeMap
|
111
|
+
getAttributes() {return null;}
|
112
|
+
public short
|
113
|
+
getNodeType() {return Node.ATTRIBUTE_NODE;}
|
114
|
+
public void
|
115
|
+
setNodeValue(String value) {throw new DTMException(NOT_SUPPORTED_ERR);}
|
116
|
+
public void
|
117
|
+
setValue(String value) {throw new DTMException(NOT_SUPPORTED_ERR);}
|
118
|
+
public void
|
119
|
+
setPrefix(String value) {throw new DTMException(NOT_SUPPORTED_ERR);}
|
120
|
+
public Node
|
121
|
+
insertBefore(Node a, Node b) {throw new DTMException(NOT_SUPPORTED_ERR);}
|
122
|
+
public Node
|
123
|
+
replaceChild(Node a, Node b) {throw new DTMException(NOT_SUPPORTED_ERR);}
|
124
|
+
public Node
|
125
|
+
appendChild(Node a) {throw new DTMException(NOT_SUPPORTED_ERR);}
|
126
|
+
public Node
|
127
|
+
removeChild(Node a) {throw new DTMException(NOT_SUPPORTED_ERR);}
|
128
|
+
public Document
|
129
|
+
getOwnerDocument() {return pseudoparent.getOwnerDocument();}
|
130
|
+
public Node
|
131
|
+
cloneNode(boolean deep) {throw new DTMException(NOT_SUPPORTED_ERR);}
|
132
|
+
|
133
|
+
/** Non-DOM method, part of the temporary kluge
|
134
|
+
* %REVIEW% This would be a pruning problem, but since it will always be
|
135
|
+
* added to the root element and we prune on elements, we shouldn't have
|
136
|
+
* to worry.
|
137
|
+
*/
|
138
|
+
public int
|
139
|
+
getHandleOfNode()
|
140
|
+
{
|
141
|
+
return handle;
|
74
142
|
}
|
75
|
-
public String getNodeName() {return nodename;}
|
76
|
-
public String getName() {return nodename;}
|
77
|
-
public String getNamespaceURI() {return "http://www.w3.org/2000/xmlns/";}
|
78
|
-
public String getPrefix() {return prefix;}
|
79
|
-
public String getLocalName() {return prefix;}
|
80
|
-
public String getNodeValue() {return uri;}
|
81
|
-
public String getValue() {return uri;}
|
82
|
-
public Element getOwnerElement() {return pseudoparent;}
|
83
|
-
|
84
|
-
public boolean isSupported(String feature, String version) {return false;}
|
85
|
-
public boolean hasChildNodes() {return false;}
|
86
|
-
public boolean hasAttributes() {return false;}
|
87
|
-
public Node getParentNode() {return null;}
|
88
|
-
public Node getFirstChild() {return null;}
|
89
|
-
public Node getLastChild() {return null;}
|
90
|
-
public Node getPreviousSibling() {return null;}
|
91
|
-
public Node getNextSibling() {return null;}
|
92
|
-
public boolean getSpecified() {return false;}
|
93
|
-
public void normalize() {return;}
|
94
|
-
public NodeList getChildNodes() {return null;}
|
95
|
-
public NamedNodeMap getAttributes() {return null;}
|
96
|
-
public short getNodeType() {return Node.ATTRIBUTE_NODE;}
|
97
|
-
public void setNodeValue(String value) {throw new DTMException(NOT_SUPPORTED_ERR);}
|
98
|
-
public void setValue(String value) {throw new DTMException(NOT_SUPPORTED_ERR);}
|
99
|
-
public void setPrefix(String value) {throw new DTMException(NOT_SUPPORTED_ERR);}
|
100
|
-
public Node insertBefore(Node a, Node b) {throw new DTMException(NOT_SUPPORTED_ERR);}
|
101
|
-
public Node replaceChild(Node a, Node b) {throw new DTMException(NOT_SUPPORTED_ERR);}
|
102
|
-
public Node appendChild(Node a) {throw new DTMException(NOT_SUPPORTED_ERR);}
|
103
|
-
public Node removeChild(Node a) {throw new DTMException(NOT_SUPPORTED_ERR);}
|
104
|
-
public Document getOwnerDocument() {return pseudoparent.getOwnerDocument();}
|
105
|
-
public Node cloneNode(boolean deep) {throw new DTMException(NOT_SUPPORTED_ERR);}
|
106
|
-
|
107
|
-
/** Non-DOM method, part of the temporary kluge
|
108
|
-
* %REVIEW% This would be a pruning problem, but since it will always be
|
109
|
-
* added to the root element and we prune on elements, we shouldn't have
|
110
|
-
* to worry.
|
111
|
-
*/
|
112
|
-
public int getHandleOfNode()
|
113
|
-
{
|
114
|
-
return handle;
|
115
|
-
}
|
116
143
|
|
117
|
-
|
144
|
+
//RAMESH: PENDING=> Add proper implementation for the below DOM L3 additions
|
145
|
+
|
146
|
+
/**
|
147
|
+
* @see org.w3c.dom.TypeInfo#getTypeName()
|
148
|
+
*/
|
149
|
+
public String
|
150
|
+
getTypeName() {return null; }
|
151
|
+
|
152
|
+
/**
|
153
|
+
* @see org.w3c.dom.TypeInfo#getTypeNamespace()
|
154
|
+
*/
|
155
|
+
public String
|
156
|
+
getTypeNamespace() { return null;}
|
157
|
+
|
158
|
+
/**
|
159
|
+
* @see or.gw3c.dom.TypeInfo#isDerivedFrom(String,String,int)
|
160
|
+
*/
|
161
|
+
public boolean
|
162
|
+
isDerivedFrom(String ns, String localName, int derivationMethod)
|
163
|
+
{
|
164
|
+
return false;
|
165
|
+
}
|
118
166
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
167
|
+
public TypeInfo
|
168
|
+
getSchemaTypeInfo() { return this; }
|
169
|
+
|
170
|
+
public boolean
|
171
|
+
isId() { return false; }
|
172
|
+
|
173
|
+
/**
|
174
|
+
* Associate an object to a key on this node. The object can later be
|
175
|
+
* retrieved from this node by calling <code>getUserData</code> with the
|
176
|
+
* same key.
|
177
|
+
* @param key The key to associate the object to.
|
178
|
+
* @param data The object to associate to the given key, or
|
179
|
+
* <code>null</code> to remove any existing association to that key.
|
180
|
+
* @param handler The handler to associate to that key, or
|
181
|
+
* <code>null</code>.
|
182
|
+
* @return Returns the <code>DOMObject</code> previously associated to
|
183
|
+
* the given key on this node, or <code>null</code> if there was none.
|
184
|
+
* @since DOM Level 3
|
185
|
+
*/
|
186
|
+
public Object
|
187
|
+
setUserData(String key,
|
188
|
+
Object data,
|
189
|
+
UserDataHandler handler)
|
190
|
+
{
|
191
|
+
return getOwnerDocument().setUserData(key, data, handler);
|
192
|
+
}
|
123
193
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
194
|
+
/**
|
195
|
+
* Retrieves the object associated to a key on a this node. The object
|
196
|
+
* must first have been set to this node by calling
|
197
|
+
* <code>setUserData</code> with the same key.
|
198
|
+
* @param key The key the object is associated to.
|
199
|
+
* @return Returns the <code>DOMObject</code> associated to the given key
|
200
|
+
* on this node, or <code>null</code> if there was none.
|
201
|
+
* @since DOM Level 3
|
202
|
+
*/
|
203
|
+
public Object
|
204
|
+
getUserData(String key)
|
205
|
+
{
|
206
|
+
return getOwnerDocument().getUserData(key);
|
207
|
+
}
|
208
|
+
|
209
|
+
/**
|
210
|
+
* This method returns a specialized object which implements the
|
211
|
+
* specialized APIs of the specified feature and version. The
|
212
|
+
* specialized object may also be obtained by using binding-specific
|
213
|
+
* casting methods but is not necessarily expected to, as discussed in Mixed DOM implementations.
|
214
|
+
* @param feature The name of the feature requested (case-insensitive).
|
215
|
+
* @param version This is the version number of the feature to test. If
|
216
|
+
* the version is <code>null</code> or the empty string, supporting
|
217
|
+
* any version of the feature will cause the method to return an
|
218
|
+
* object that supports at least one version of the feature.
|
219
|
+
* @return Returns an object which implements the specialized APIs of
|
220
|
+
* the specified feature and version, if any, or <code>null</code> if
|
221
|
+
* there is no object which implements interfaces associated with that
|
222
|
+
* feature. If the <code>DOMObject</code> returned by this method
|
223
|
+
* implements the <code>Node</code> interface, it must delegate to the
|
224
|
+
* primary core <code>Node</code> and not return results inconsistent
|
225
|
+
* with the primary core <code>Node</code> such as attributes,
|
226
|
+
* childNodes, etc.
|
227
|
+
* @since DOM Level 3
|
228
|
+
*/
|
229
|
+
public Object
|
230
|
+
getFeature(String feature, String version)
|
231
|
+
{
|
232
|
+
// we don't have any alternate node, either this node does the job
|
233
|
+
// or we don't have anything that does
|
234
|
+
return isSupported(feature, version) ? this : null;
|
235
|
+
}
|
128
236
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
237
|
+
/**
|
238
|
+
* Tests whether two nodes are equal.
|
239
|
+
* <br>This method tests for equality of nodes, not sameness (i.e.,
|
240
|
+
* whether the two nodes are references to the same object) which can be
|
241
|
+
* tested with <code>Node.isSameNode</code>. All nodes that are the same
|
242
|
+
* will also be equal, though the reverse may not be true.
|
243
|
+
* <br>Two nodes are equal if and only if the following conditions are
|
244
|
+
* satisfied: The two nodes are of the same type.The following string
|
245
|
+
* attributes are equal: <code>nodeName</code>, <code>localName</code>,
|
246
|
+
* <code>namespaceURI</code>, <code>prefix</code>, <code>nodeValue</code>
|
247
|
+
* , <code>baseURI</code>. This is: they are both <code>null</code>, or
|
248
|
+
* they have the same length and are character for character identical.
|
249
|
+
* The <code>attributes</code> <code>NamedNodeMaps</code> are equal.
|
250
|
+
* This is: they are both <code>null</code>, or they have the same
|
251
|
+
* length and for each node that exists in one map there is a node that
|
252
|
+
* exists in the other map and is equal, although not necessarily at the
|
253
|
+
* same index.The <code>childNodes</code> <code>NodeLists</code> are
|
254
|
+
* equal. This is: they are both <code>null</code>, or they have the
|
255
|
+
* same length and contain equal nodes at the same index. This is true
|
256
|
+
* for <code>Attr</code> nodes as for any other type of node. Note that
|
257
|
+
* normalization can affect equality; to avoid this, nodes should be
|
258
|
+
* normalized before being compared.
|
259
|
+
* <br>For two <code>DocumentType</code> nodes to be equal, the following
|
260
|
+
* conditions must also be satisfied: The following string attributes
|
261
|
+
* are equal: <code>publicId</code>, <code>systemId</code>,
|
262
|
+
* <code>internalSubset</code>.The <code>entities</code>
|
263
|
+
* <code>NamedNodeMaps</code> are equal.The <code>notations</code>
|
264
|
+
* <code>NamedNodeMaps</code> are equal.
|
265
|
+
* <br>On the other hand, the following do not affect equality: the
|
266
|
+
* <code>ownerDocument</code> attribute, the <code>specified</code>
|
267
|
+
* attribute for <code>Attr</code> nodes, the
|
268
|
+
* <code>isWhitespaceInElementContent</code> attribute for
|
269
|
+
* <code>Text</code> nodes, as well as any user data or event listeners
|
270
|
+
* registered on the nodes.
|
271
|
+
* @param arg The node to compare equality with.
|
272
|
+
* @param deep If <code>true</code>, recursively compare the subtrees; if
|
273
|
+
* <code>false</code>, compare only the nodes themselves (and its
|
274
|
+
* attributes, if it is an <code>Element</code>).
|
275
|
+
* @return If the nodes, and possibly subtrees are equal,
|
276
|
+
* <code>true</code> otherwise <code>false</code>.
|
277
|
+
* @since DOM Level 3
|
278
|
+
*/
|
279
|
+
public boolean
|
280
|
+
isEqualNode(Node arg)
|
281
|
+
{
|
282
|
+
if (arg == this) {
|
283
|
+
return true;
|
284
|
+
}
|
285
|
+
if (arg.getNodeType() != getNodeType()) {
|
286
|
+
return false;
|
287
|
+
}
|
288
|
+
// in theory nodeName can't be null but better be careful
|
289
|
+
// who knows what other implementations may be doing?...
|
290
|
+
if (getNodeName() == null) {
|
291
|
+
if (arg.getNodeName() != null) {
|
133
292
|
return false;
|
293
|
+
}
|
294
|
+
} else if (!getNodeName().equals(arg.getNodeName())) {
|
295
|
+
return false;
|
134
296
|
}
|
135
297
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
* retrieved from this node by calling <code>getUserData</code> with the
|
143
|
-
* same key.
|
144
|
-
* @param key The key to associate the object to.
|
145
|
-
* @param data The object to associate to the given key, or
|
146
|
-
* <code>null</code> to remove any existing association to that key.
|
147
|
-
* @param handler The handler to associate to that key, or
|
148
|
-
* <code>null</code>.
|
149
|
-
* @return Returns the <code>DOMObject</code> previously associated to
|
150
|
-
* the given key on this node, or <code>null</code> if there was none.
|
151
|
-
* @since DOM Level 3
|
152
|
-
*/
|
153
|
-
public Object setUserData(String key,
|
154
|
-
Object data,
|
155
|
-
UserDataHandler handler) {
|
156
|
-
return getOwnerDocument().setUserData( key, data, handler);
|
298
|
+
if (getLocalName() == null) {
|
299
|
+
if (arg.getLocalName() != null) {
|
300
|
+
return false;
|
301
|
+
}
|
302
|
+
} else if (!getLocalName().equals(arg.getLocalName())) {
|
303
|
+
return false;
|
157
304
|
}
|
158
305
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
* on this node, or <code>null</code> if there was none.
|
166
|
-
* @since DOM Level 3
|
167
|
-
*/
|
168
|
-
public Object getUserData(String key) {
|
169
|
-
return getOwnerDocument().getUserData( key);
|
306
|
+
if (getNamespaceURI() == null) {
|
307
|
+
if (arg.getNamespaceURI() != null) {
|
308
|
+
return false;
|
309
|
+
}
|
310
|
+
} else if (!getNamespaceURI().equals(arg.getNamespaceURI())) {
|
311
|
+
return false;
|
170
312
|
}
|
171
313
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
* @param version This is the version number of the feature to test. If
|
179
|
-
* the version is <code>null</code> or the empty string, supporting
|
180
|
-
* any version of the feature will cause the method to return an
|
181
|
-
* object that supports at least one version of the feature.
|
182
|
-
* @return Returns an object which implements the specialized APIs of
|
183
|
-
* the specified feature and version, if any, or <code>null</code> if
|
184
|
-
* there is no object which implements interfaces associated with that
|
185
|
-
* feature. If the <code>DOMObject</code> returned by this method
|
186
|
-
* implements the <code>Node</code> interface, it must delegate to the
|
187
|
-
* primary core <code>Node</code> and not return results inconsistent
|
188
|
-
* with the primary core <code>Node</code> such as attributes,
|
189
|
-
* childNodes, etc.
|
190
|
-
* @since DOM Level 3
|
191
|
-
*/
|
192
|
-
public Object getFeature(String feature, String version) {
|
193
|
-
// we don't have any alternate node, either this node does the job
|
194
|
-
// or we don't have anything that does
|
195
|
-
return isSupported(feature, version) ? this : null;
|
314
|
+
if (getPrefix() == null) {
|
315
|
+
if (arg.getPrefix() != null) {
|
316
|
+
return false;
|
317
|
+
}
|
318
|
+
} else if (!getPrefix().equals(arg.getPrefix())) {
|
319
|
+
return false;
|
196
320
|
}
|
197
321
|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
* satisfied: The two nodes are of the same type.The following string
|
206
|
-
* attributes are equal: <code>nodeName</code>, <code>localName</code>,
|
207
|
-
* <code>namespaceURI</code>, <code>prefix</code>, <code>nodeValue</code>
|
208
|
-
* , <code>baseURI</code>. This is: they are both <code>null</code>, or
|
209
|
-
* they have the same length and are character for character identical.
|
210
|
-
* The <code>attributes</code> <code>NamedNodeMaps</code> are equal.
|
211
|
-
* This is: they are both <code>null</code>, or they have the same
|
212
|
-
* length and for each node that exists in one map there is a node that
|
213
|
-
* exists in the other map and is equal, although not necessarily at the
|
214
|
-
* same index.The <code>childNodes</code> <code>NodeLists</code> are
|
215
|
-
* equal. This is: they are both <code>null</code>, or they have the
|
216
|
-
* same length and contain equal nodes at the same index. This is true
|
217
|
-
* for <code>Attr</code> nodes as for any other type of node. Note that
|
218
|
-
* normalization can affect equality; to avoid this, nodes should be
|
219
|
-
* normalized before being compared.
|
220
|
-
* <br>For two <code>DocumentType</code> nodes to be equal, the following
|
221
|
-
* conditions must also be satisfied: The following string attributes
|
222
|
-
* are equal: <code>publicId</code>, <code>systemId</code>,
|
223
|
-
* <code>internalSubset</code>.The <code>entities</code>
|
224
|
-
* <code>NamedNodeMaps</code> are equal.The <code>notations</code>
|
225
|
-
* <code>NamedNodeMaps</code> are equal.
|
226
|
-
* <br>On the other hand, the following do not affect equality: the
|
227
|
-
* <code>ownerDocument</code> attribute, the <code>specified</code>
|
228
|
-
* attribute for <code>Attr</code> nodes, the
|
229
|
-
* <code>isWhitespaceInElementContent</code> attribute for
|
230
|
-
* <code>Text</code> nodes, as well as any user data or event listeners
|
231
|
-
* registered on the nodes.
|
232
|
-
* @param arg The node to compare equality with.
|
233
|
-
* @param deep If <code>true</code>, recursively compare the subtrees; if
|
234
|
-
* <code>false</code>, compare only the nodes themselves (and its
|
235
|
-
* attributes, if it is an <code>Element</code>).
|
236
|
-
* @return If the nodes, and possibly subtrees are equal,
|
237
|
-
* <code>true</code> otherwise <code>false</code>.
|
238
|
-
* @since DOM Level 3
|
239
|
-
*/
|
240
|
-
public boolean isEqualNode(Node arg) {
|
241
|
-
if (arg == this) {
|
242
|
-
return true;
|
243
|
-
}
|
244
|
-
if (arg.getNodeType() != getNodeType()) {
|
245
|
-
return false;
|
246
|
-
}
|
247
|
-
// in theory nodeName can't be null but better be careful
|
248
|
-
// who knows what other implementations may be doing?...
|
249
|
-
if (getNodeName() == null) {
|
250
|
-
if (arg.getNodeName() != null) {
|
251
|
-
return false;
|
252
|
-
}
|
253
|
-
}
|
254
|
-
else if (!getNodeName().equals(arg.getNodeName())) {
|
255
|
-
return false;
|
256
|
-
}
|
257
|
-
|
258
|
-
if (getLocalName() == null) {
|
259
|
-
if (arg.getLocalName() != null) {
|
260
|
-
return false;
|
261
|
-
}
|
262
|
-
}
|
263
|
-
else if (!getLocalName().equals(arg.getLocalName())) {
|
264
|
-
return false;
|
265
|
-
}
|
266
|
-
|
267
|
-
if (getNamespaceURI() == null) {
|
268
|
-
if (arg.getNamespaceURI() != null) {
|
269
|
-
return false;
|
270
|
-
}
|
271
|
-
}
|
272
|
-
else if (!getNamespaceURI().equals(arg.getNamespaceURI())) {
|
273
|
-
return false;
|
274
|
-
}
|
275
|
-
|
276
|
-
if (getPrefix() == null) {
|
277
|
-
if (arg.getPrefix() != null) {
|
278
|
-
return false;
|
279
|
-
}
|
280
|
-
}
|
281
|
-
else if (!getPrefix().equals(arg.getPrefix())) {
|
282
|
-
return false;
|
283
|
-
}
|
284
|
-
|
285
|
-
if (getNodeValue() == null) {
|
286
|
-
if (arg.getNodeValue() != null) {
|
287
|
-
return false;
|
288
|
-
}
|
289
|
-
}
|
290
|
-
else if (!getNodeValue().equals(arg.getNodeValue())) {
|
291
|
-
return false;
|
292
|
-
}
|
322
|
+
if (getNodeValue() == null) {
|
323
|
+
if (arg.getNodeValue() != null) {
|
324
|
+
return false;
|
325
|
+
}
|
326
|
+
} else if (!getNodeValue().equals(arg.getNodeValue())) {
|
327
|
+
return false;
|
328
|
+
}
|
293
329
|
/*
|
294
330
|
if (getBaseURI() == null) {
|
295
331
|
if (((NodeImpl) arg).getBaseURI() != null) {
|
@@ -299,387 +335,403 @@ public class DOM2DTMdefaultNamespaceDeclarationNode implements Attr,TypeInfo
|
|
299
335
|
else if (!getBaseURI().equals(((NodeImpl) arg).getBaseURI())) {
|
300
336
|
return false;
|
301
337
|
}
|
302
|
-
*/
|
303
|
-
|
304
|
-
return true;
|
305
|
-
}
|
306
|
-
|
307
|
-
/**
|
308
|
-
* DOM Level 3 - Experimental:
|
309
|
-
* Look up the namespace URI associated to the given prefix, starting from this node.
|
310
|
-
* Use lookupNamespaceURI(null) to lookup the default namespace
|
311
|
-
*
|
312
|
-
* @param namespaceURI
|
313
|
-
* @return th URI for the namespace
|
314
|
-
* @since DOM Level 3
|
315
|
-
*/
|
316
|
-
public String lookupNamespaceURI(String specifiedPrefix) {
|
317
|
-
short type = this.getNodeType();
|
318
|
-
switch (type) {
|
319
|
-
case Node.ELEMENT_NODE : {
|
320
|
-
|
321
|
-
String namespace = this.getNamespaceURI();
|
322
|
-
String prefix = this.getPrefix();
|
323
|
-
if (namespace !=null) {
|
324
|
-
// REVISIT: is it possible that prefix is empty string?
|
325
|
-
if (specifiedPrefix== null && prefix==specifiedPrefix) {
|
326
|
-
// looking for default namespace
|
327
|
-
return namespace;
|
328
|
-
} else if (prefix != null && prefix.equals(specifiedPrefix)) {
|
329
|
-
// non default namespace
|
330
|
-
return namespace;
|
331
|
-
}
|
332
|
-
}
|
333
|
-
if (this.hasAttributes()) {
|
334
|
-
NamedNodeMap map = this.getAttributes();
|
335
|
-
int length = map.getLength();
|
336
|
-
for (int i=0;i<length;i++) {
|
337
|
-
Node attr = map.item(i);
|
338
|
-
String attrPrefix = attr.getPrefix();
|
339
|
-
String value = attr.getNodeValue();
|
340
|
-
namespace = attr.getNamespaceURI();
|
341
|
-
if (namespace !=null && namespace.equals("http://www.w3.org/2000/xmlns/")) {
|
342
|
-
// at this point we are dealing with DOM Level 2 nodes only
|
343
|
-
if (specifiedPrefix == null &&
|
344
|
-
attr.getNodeName().equals("xmlns")) {
|
345
|
-
// default namespace
|
346
|
-
return value;
|
347
|
-
} else if (attrPrefix !=null &&
|
348
|
-
attrPrefix.equals("xmlns") &&
|
349
|
-
attr.getLocalName().equals(specifiedPrefix)) {
|
350
|
-
// non default namespace
|
351
|
-
return value;
|
352
|
-
}
|
353
|
-
}
|
354
|
-
}
|
355
|
-
}
|
356
|
-
/*
|
357
|
-
NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
|
358
|
-
if (ancestor != null) {
|
359
|
-
return ancestor.lookupNamespaceURI(specifiedPrefix);
|
360
|
-
}
|
361
|
-
*/
|
362
|
-
|
363
|
-
return null;
|
338
|
+
*/
|
364
339
|
|
340
|
+
return true;
|
341
|
+
}
|
365
342
|
|
343
|
+
/**
|
344
|
+
* DOM Level 3 - Experimental:
|
345
|
+
* Look up the namespace URI associated to the given prefix, starting from this node.
|
346
|
+
* Use lookupNamespaceURI(null) to lookup the default namespace
|
347
|
+
*
|
348
|
+
* @param namespaceURI
|
349
|
+
* @return th URI for the namespace
|
350
|
+
* @since DOM Level 3
|
351
|
+
*/
|
352
|
+
public String
|
353
|
+
lookupNamespaceURI(String specifiedPrefix)
|
354
|
+
{
|
355
|
+
short type = this.getNodeType();
|
356
|
+
switch (type) {
|
357
|
+
case Node.ELEMENT_NODE : {
|
358
|
+
|
359
|
+
String namespace = this.getNamespaceURI();
|
360
|
+
String prefix = this.getPrefix();
|
361
|
+
if (namespace != null) {
|
362
|
+
// REVISIT: is it possible that prefix is empty string?
|
363
|
+
if (specifiedPrefix == null && prefix == specifiedPrefix) {
|
364
|
+
// looking for default namespace
|
365
|
+
return namespace;
|
366
|
+
} else if (prefix != null && prefix.equals(specifiedPrefix)) {
|
367
|
+
// non default namespace
|
368
|
+
return namespace;
|
369
|
+
}
|
370
|
+
}
|
371
|
+
if (this.hasAttributes()) {
|
372
|
+
NamedNodeMap map = this.getAttributes();
|
373
|
+
int length = map.getLength();
|
374
|
+
for (int i = 0; i < length; i++) {
|
375
|
+
Node attr = map.item(i);
|
376
|
+
String attrPrefix = attr.getPrefix();
|
377
|
+
String value = attr.getNodeValue();
|
378
|
+
namespace = attr.getNamespaceURI();
|
379
|
+
if (namespace != null && namespace.equals("http://www.w3.org/2000/xmlns/")) {
|
380
|
+
// at this point we are dealing with DOM Level 2 nodes only
|
381
|
+
if (specifiedPrefix == null &&
|
382
|
+
attr.getNodeName().equals("xmlns")) {
|
383
|
+
// default namespace
|
384
|
+
return value;
|
385
|
+
} else if (attrPrefix != null &&
|
386
|
+
attrPrefix.equals("xmlns") &&
|
387
|
+
attr.getLocalName().equals(specifiedPrefix)) {
|
388
|
+
// non default namespace
|
389
|
+
return value;
|
366
390
|
}
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
// type is unknown
|
377
|
-
return null;
|
378
|
-
case Node.ATTRIBUTE_NODE:{
|
379
|
-
if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {
|
380
|
-
return getOwnerElement().lookupNamespaceURI(specifiedPrefix);
|
391
|
+
}
|
392
|
+
}
|
393
|
+
}
|
394
|
+
/*
|
395
|
+
NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
|
396
|
+
if (ancestor != null) {
|
397
|
+
return ancestor.lookupNamespaceURI(specifiedPrefix);
|
398
|
+
}
|
399
|
+
*/
|
381
400
|
|
382
|
-
|
383
|
-
return null;
|
384
|
-
}
|
385
|
-
default:{
|
386
|
-
/*
|
387
|
-
NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
|
388
|
-
if (ancestor != null) {
|
389
|
-
return ancestor.lookupNamespaceURI(specifiedPrefix);
|
390
|
-
}
|
391
|
-
*/
|
392
|
-
return null;
|
393
|
-
}
|
401
|
+
return null;
|
394
402
|
|
395
|
-
}
|
396
|
-
}
|
397
403
|
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
* @param namespaceURI The namespace URI to look for.
|
403
|
-
* @return <code>true</code> if the specified <code>namespaceURI</code>
|
404
|
-
* is the default namespace, <code>false</code> otherwise.
|
405
|
-
* @since DOM Level 3
|
406
|
-
*/
|
407
|
-
public boolean isDefaultNamespace(String namespaceURI){
|
408
|
-
/*
|
409
|
-
// REVISIT: remove casts when DOM L3 becomes REC.
|
410
|
-
short type = this.getNodeType();
|
411
|
-
switch (type) {
|
412
|
-
case Node.ELEMENT_NODE: {
|
413
|
-
String namespace = this.getNamespaceURI();
|
414
|
-
String prefix = this.getPrefix();
|
415
|
-
|
416
|
-
// REVISIT: is it possible that prefix is empty string?
|
417
|
-
if (prefix == null || prefix.length() == 0) {
|
418
|
-
if (namespaceURI == null) {
|
419
|
-
return (namespace == namespaceURI);
|
420
|
-
}
|
421
|
-
return namespaceURI.equals(namespace);
|
422
|
-
}
|
423
|
-
if (this.hasAttributes()) {
|
424
|
-
ElementImpl elem = (ElementImpl)this;
|
425
|
-
NodeImpl attr = (NodeImpl)elem.getAttributeNodeNS("http://www.w3.org/2000/xmlns/", "xmlns");
|
426
|
-
if (attr != null) {
|
427
|
-
String value = attr.getNodeValue();
|
428
|
-
if (namespaceURI == null) {
|
429
|
-
return (namespace == value);
|
430
|
-
}
|
431
|
-
return namespaceURI.equals(value);
|
404
|
+
}
|
405
|
+
/*
|
406
|
+
case Node.DOCUMENT_NODE : {
|
407
|
+
return((NodeImpl)((Document)this).getDocumentElement()).lookupNamespaceURI(specifiedPrefix) ;
|
432
408
|
}
|
433
|
-
|
409
|
+
*/
|
410
|
+
case Node.ENTITY_NODE :
|
411
|
+
case Node.NOTATION_NODE:
|
412
|
+
case Node.DOCUMENT_FRAGMENT_NODE:
|
413
|
+
case Node.DOCUMENT_TYPE_NODE:
|
414
|
+
// type is unknown
|
415
|
+
return null;
|
416
|
+
case Node.ATTRIBUTE_NODE: {
|
417
|
+
if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {
|
418
|
+
return getOwnerElement().lookupNamespaceURI(specifiedPrefix);
|
419
|
+
|
420
|
+
}
|
421
|
+
return null;
|
422
|
+
}
|
423
|
+
default: {
|
424
|
+
/*
|
425
|
+
NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
|
426
|
+
if (ancestor != null) {
|
427
|
+
return ancestor.lookupNamespaceURI(specifiedPrefix);
|
428
|
+
}
|
429
|
+
*/
|
430
|
+
return null;
|
431
|
+
}
|
434
432
|
|
435
|
-
|
436
|
-
|
437
|
-
return ancestor.isDefaultNamespace(namespaceURI);
|
438
|
-
}
|
439
|
-
return false;
|
440
|
-
}
|
441
|
-
case Node.DOCUMENT_NODE:{
|
442
|
-
return((NodeImpl)((Document)this).getDocumentElement()).isDefaultNamespace(namespaceURI);
|
443
|
-
}
|
433
|
+
}
|
434
|
+
}
|
444
435
|
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
436
|
+
/**
|
437
|
+
* DOM Level 3: Experimental
|
438
|
+
* This method checks if the specified <code>namespaceURI</code> is the
|
439
|
+
* default namespace or not.
|
440
|
+
* @param namespaceURI The namespace URI to look for.
|
441
|
+
* @return <code>true</code> if the specified <code>namespaceURI</code>
|
442
|
+
* is the default namespace, <code>false</code> otherwise.
|
443
|
+
* @since DOM Level 3
|
444
|
+
*/
|
445
|
+
public boolean
|
446
|
+
isDefaultNamespace(String namespaceURI)
|
447
|
+
{
|
448
|
+
/*
|
449
|
+
// REVISIT: remove casts when DOM L3 becomes REC.
|
450
|
+
short type = this.getNodeType();
|
451
|
+
switch (type) {
|
452
|
+
case Node.ELEMENT_NODE: {
|
453
|
+
String namespace = this.getNamespaceURI();
|
454
|
+
String prefix = this.getPrefix();
|
455
|
+
|
456
|
+
// REVISIT: is it possible that prefix is empty string?
|
457
|
+
if (prefix == null || prefix.length() == 0) {
|
458
|
+
if (namespaceURI == null) {
|
459
|
+
return (namespace == namespaceURI);
|
460
|
+
}
|
461
|
+
return namespaceURI.equals(namespace);
|
462
|
+
}
|
463
|
+
if (this.hasAttributes()) {
|
464
|
+
ElementImpl elem = (ElementImpl)this;
|
465
|
+
NodeImpl attr = (NodeImpl)elem.getAttributeNodeNS("http://www.w3.org/2000/xmlns/", "xmlns");
|
466
|
+
if (attr != null) {
|
467
|
+
String value = attr.getNodeValue();
|
468
|
+
if (namespaceURI == null) {
|
469
|
+
return (namespace == value);
|
470
|
+
}
|
471
|
+
return namespaceURI.equals(value);
|
472
|
+
}
|
473
|
+
}
|
454
474
|
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
}
|
475
|
+
NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
|
476
|
+
if (ancestor != null) {
|
477
|
+
return ancestor.isDefaultNamespace(namespaceURI);
|
478
|
+
}
|
479
|
+
return false;
|
480
|
+
}
|
481
|
+
case Node.DOCUMENT_NODE:{
|
482
|
+
return((NodeImpl)((Document)this).getDocumentElement()).isDefaultNamespace(namespaceURI);
|
483
|
+
}
|
465
484
|
|
466
|
-
|
467
|
-
|
468
|
-
|
485
|
+
case Node.ENTITY_NODE :
|
486
|
+
case Node.NOTATION_NODE:
|
487
|
+
case Node.DOCUMENT_FRAGMENT_NODE:
|
488
|
+
case Node.DOCUMENT_TYPE_NODE:
|
489
|
+
// type is unknown
|
490
|
+
return false;
|
491
|
+
case Node.ATTRIBUTE_NODE:{
|
492
|
+
if (this.ownerNode.getNodeType() == Node.ELEMENT_NODE) {
|
493
|
+
return ownerNode.isDefaultNamespace(namespaceURI);
|
494
|
+
|
495
|
+
}
|
496
|
+
return false;
|
497
|
+
}
|
498
|
+
default:{
|
499
|
+
NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
|
500
|
+
if (ancestor != null) {
|
501
|
+
return ancestor.isDefaultNamespace(namespaceURI);
|
502
|
+
}
|
503
|
+
return false;
|
504
|
+
}
|
469
505
|
|
506
|
+
}
|
507
|
+
*/
|
508
|
+
return false;
|
470
509
|
|
471
|
-
}
|
472
510
|
|
473
|
-
|
474
|
-
*
|
475
|
-
* DOM Level 3 - Experimental:
|
476
|
-
* Look up the prefix associated to the given namespace URI, starting from this node.
|
477
|
-
*
|
478
|
-
* @param namespaceURI
|
479
|
-
* @return the prefix for the namespace
|
480
|
-
*/
|
481
|
-
public String lookupPrefix(String namespaceURI){
|
482
|
-
|
483
|
-
// REVISIT: When Namespaces 1.1 comes out this may not be true
|
484
|
-
// Prefix can't be bound to null namespace
|
485
|
-
if (namespaceURI == null) {
|
486
|
-
return null;
|
487
|
-
}
|
511
|
+
}
|
488
512
|
|
489
|
-
|
513
|
+
/**
|
514
|
+
*
|
515
|
+
* DOM Level 3 - Experimental:
|
516
|
+
* Look up the prefix associated to the given namespace URI, starting from this node.
|
517
|
+
*
|
518
|
+
* @param namespaceURI
|
519
|
+
* @return the prefix for the namespace
|
520
|
+
*/
|
521
|
+
public String
|
522
|
+
lookupPrefix(String namespaceURI)
|
523
|
+
{
|
490
524
|
|
491
|
-
|
492
|
-
|
493
|
-
|
525
|
+
// REVISIT: When Namespaces 1.1 comes out this may not be true
|
526
|
+
// Prefix can't be bound to null namespace
|
527
|
+
if (namespaceURI == null) {
|
528
|
+
return null;
|
529
|
+
}
|
494
530
|
|
495
|
-
|
496
|
-
return lookupNamespacePrefix(namespaceURI, (ElementImpl)this);
|
497
|
-
}
|
531
|
+
short type = this.getNodeType();
|
498
532
|
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
*/
|
503
|
-
case Node.ENTITY_NODE :
|
504
|
-
case Node.NOTATION_NODE:
|
505
|
-
case Node.DOCUMENT_FRAGMENT_NODE:
|
506
|
-
case Node.DOCUMENT_TYPE_NODE:
|
507
|
-
// type is unknown
|
508
|
-
return null;
|
509
|
-
case Node.ATTRIBUTE_NODE:{
|
510
|
-
if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {
|
511
|
-
return getOwnerElement().lookupPrefix(namespaceURI);
|
533
|
+
switch (type) {
|
534
|
+
/*
|
535
|
+
case Node.ELEMENT_NODE: {
|
512
536
|
|
537
|
+
String namespace = this.getNamespaceURI(); // to flip out children
|
538
|
+
return lookupNamespacePrefix(namespaceURI, (ElementImpl)this);
|
513
539
|
}
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
/*
|
518
|
-
NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
|
519
|
-
if (ancestor != null) {
|
520
|
-
return ancestor.lookupPrefix(namespaceURI);
|
540
|
+
|
541
|
+
case Node.DOCUMENT_NODE:{
|
542
|
+
return((NodeImpl)((Document)this).getDocumentElement()).lookupPrefix(namespaceURI);
|
521
543
|
}
|
522
|
-
*/
|
523
|
-
|
524
|
-
|
525
|
-
|
544
|
+
*/
|
545
|
+
case Node.ENTITY_NODE :
|
546
|
+
case Node.NOTATION_NODE:
|
547
|
+
case Node.DOCUMENT_FRAGMENT_NODE:
|
548
|
+
case Node.DOCUMENT_TYPE_NODE:
|
549
|
+
// type is unknown
|
550
|
+
return null;
|
551
|
+
case Node.ATTRIBUTE_NODE: {
|
552
|
+
if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {
|
553
|
+
return getOwnerElement().lookupPrefix(namespaceURI);
|
554
|
+
|
555
|
+
}
|
556
|
+
return null;
|
526
557
|
}
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
* same values and calling the same DOM method on either reference
|
536
|
-
* always has exactly the same effect.
|
537
|
-
* @param other The node to test against.
|
538
|
-
* @return Returns <code>true</code> if the nodes are the same,
|
539
|
-
* <code>false</code> otherwise.
|
540
|
-
* @since DOM Level 3
|
541
|
-
*/
|
542
|
-
public boolean isSameNode(Node other) {
|
543
|
-
// we do not use any wrapper so the answer is obvious
|
544
|
-
return this == other;
|
558
|
+
default: {
|
559
|
+
/*
|
560
|
+
NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
|
561
|
+
if (ancestor != null) {
|
562
|
+
return ancestor.lookupPrefix(namespaceURI);
|
563
|
+
}
|
564
|
+
*/
|
565
|
+
return null;
|
545
566
|
}
|
546
|
-
|
547
|
-
/**
|
548
|
-
* This attribute returns the text content of this node and its
|
549
|
-
* descendants. When it is defined to be null, setting it has no effect.
|
550
|
-
* When set, any possible children this node may have are removed and
|
551
|
-
* replaced by a single <code>Text</code> node containing the string
|
552
|
-
* this attribute is set to. On getting, no serialization is performed,
|
553
|
-
* the returned string does not contain any markup. No whitespace
|
554
|
-
* normalization is performed, the returned string does not contain the
|
555
|
-
* element content whitespaces . Similarly, on setting, no parsing is
|
556
|
-
* performed either, the input string is taken as pure textual content.
|
557
|
-
* <br>The string returned is made of the text content of this node
|
558
|
-
* depending on its type, as defined below:
|
559
|
-
* <table border='1'>
|
560
|
-
* <tr>
|
561
|
-
* <th>Node type</th>
|
562
|
-
* <th>Content</th>
|
563
|
-
* </tr>
|
564
|
-
* <tr>
|
565
|
-
* <td valign='top' rowspan='1' colspan='1'>
|
566
|
-
* ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE,
|
567
|
-
* DOCUMENT_FRAGMENT_NODE</td>
|
568
|
-
* <td valign='top' rowspan='1' colspan='1'>concatenation of the <code>textContent</code>
|
569
|
-
* attribute value of every child node, excluding COMMENT_NODE and
|
570
|
-
* PROCESSING_INSTRUCTION_NODE nodes</td>
|
571
|
-
* </tr>
|
572
|
-
* <tr>
|
573
|
-
* <td valign='top' rowspan='1' colspan='1'>ATTRIBUTE_NODE, TEXT_NODE,
|
574
|
-
* CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE</td>
|
575
|
-
* <td valign='top' rowspan='1' colspan='1'>
|
576
|
-
* <code>nodeValue</code></td>
|
577
|
-
* </tr>
|
578
|
-
* <tr>
|
579
|
-
* <td valign='top' rowspan='1' colspan='1'>DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE</td>
|
580
|
-
* <td valign='top' rowspan='1' colspan='1'>
|
581
|
-
* null</td>
|
582
|
-
* </tr>
|
583
|
-
* </table>
|
584
|
-
* @exception DOMException
|
585
|
-
* NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
|
586
|
-
* @exception DOMException
|
587
|
-
* DOMSTRING_SIZE_ERR: Raised when it would return more characters than
|
588
|
-
* fit in a <code>DOMString</code> variable on the implementation
|
589
|
-
* platform.
|
590
|
-
* @since DOM Level 3
|
591
|
-
*/
|
592
|
-
public void setTextContent(String textContent)
|
593
|
-
throws DOMException {
|
594
|
-
setNodeValue(textContent);
|
595
567
|
}
|
568
|
+
}
|
596
569
|
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
* DOCUMENT_FRAGMENT_NODE</td>
|
618
|
-
* <td valign='top' rowspan='1' colspan='1'>concatenation of the <code>textContent</code>
|
619
|
-
* attribute value of every child node, excluding COMMENT_NODE and
|
620
|
-
* PROCESSING_INSTRUCTION_NODE nodes</td>
|
621
|
-
* </tr>
|
622
|
-
* <tr>
|
623
|
-
* <td valign='top' rowspan='1' colspan='1'>ATTRIBUTE_NODE, TEXT_NODE,
|
624
|
-
* CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE</td>
|
625
|
-
* <td valign='top' rowspan='1' colspan='1'>
|
626
|
-
* <code>nodeValue</code></td>
|
627
|
-
* </tr>
|
628
|
-
* <tr>
|
629
|
-
* <td valign='top' rowspan='1' colspan='1'>DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE</td>
|
630
|
-
* <td valign='top' rowspan='1' colspan='1'>
|
631
|
-
* null</td>
|
632
|
-
* </tr>
|
633
|
-
* </table>
|
634
|
-
* @exception DOMException
|
635
|
-
* NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
|
636
|
-
* @exception DOMException
|
637
|
-
* DOMSTRING_SIZE_ERR: Raised when it would return more characters than
|
638
|
-
* fit in a <code>DOMString</code> variable on the implementation
|
639
|
-
* platform.
|
640
|
-
* @since DOM Level 3
|
641
|
-
*/
|
642
|
-
public String getTextContent() throws DOMException {
|
643
|
-
return getNodeValue(); // overriden in some subclasses
|
644
|
-
}
|
570
|
+
/**
|
571
|
+
* Returns whether this node is the same node as the given one.
|
572
|
+
* <br>This method provides a way to determine whether two
|
573
|
+
* <code>Node</code> references returned by the implementation reference
|
574
|
+
* the same object. When two <code>Node</code> references are references
|
575
|
+
* to the same object, even if through a proxy, the references may be
|
576
|
+
* used completely interchangably, such that all attributes have the
|
577
|
+
* same values and calling the same DOM method on either reference
|
578
|
+
* always has exactly the same effect.
|
579
|
+
* @param other The node to test against.
|
580
|
+
* @return Returns <code>true</code> if the nodes are the same,
|
581
|
+
* <code>false</code> otherwise.
|
582
|
+
* @since DOM Level 3
|
583
|
+
*/
|
584
|
+
public boolean
|
585
|
+
isSameNode(Node other)
|
586
|
+
{
|
587
|
+
// we do not use any wrapper so the answer is obvious
|
588
|
+
return this == other;
|
589
|
+
}
|
645
590
|
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
591
|
+
/**
|
592
|
+
* This attribute returns the text content of this node and its
|
593
|
+
* descendants. When it is defined to be null, setting it has no effect.
|
594
|
+
* When set, any possible children this node may have are removed and
|
595
|
+
* replaced by a single <code>Text</code> node containing the string
|
596
|
+
* this attribute is set to. On getting, no serialization is performed,
|
597
|
+
* the returned string does not contain any markup. No whitespace
|
598
|
+
* normalization is performed, the returned string does not contain the
|
599
|
+
* element content whitespaces . Similarly, on setting, no parsing is
|
600
|
+
* performed either, the input string is taken as pure textual content.
|
601
|
+
* <br>The string returned is made of the text content of this node
|
602
|
+
* depending on its type, as defined below:
|
603
|
+
* <table border='1'>
|
604
|
+
* <tr>
|
605
|
+
* <th>Node type</th>
|
606
|
+
* <th>Content</th>
|
607
|
+
* </tr>
|
608
|
+
* <tr>
|
609
|
+
* <td valign='top' rowspan='1' colspan='1'>
|
610
|
+
* ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE,
|
611
|
+
* DOCUMENT_FRAGMENT_NODE</td>
|
612
|
+
* <td valign='top' rowspan='1' colspan='1'>concatenation of the <code>textContent</code>
|
613
|
+
* attribute value of every child node, excluding COMMENT_NODE and
|
614
|
+
* PROCESSING_INSTRUCTION_NODE nodes</td>
|
615
|
+
* </tr>
|
616
|
+
* <tr>
|
617
|
+
* <td valign='top' rowspan='1' colspan='1'>ATTRIBUTE_NODE, TEXT_NODE,
|
618
|
+
* CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE</td>
|
619
|
+
* <td valign='top' rowspan='1' colspan='1'>
|
620
|
+
* <code>nodeValue</code></td>
|
621
|
+
* </tr>
|
622
|
+
* <tr>
|
623
|
+
* <td valign='top' rowspan='1' colspan='1'>DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE</td>
|
624
|
+
* <td valign='top' rowspan='1' colspan='1'>
|
625
|
+
* null</td>
|
626
|
+
* </tr>
|
627
|
+
* </table>
|
628
|
+
* @exception DOMException
|
629
|
+
* NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
|
630
|
+
* @exception DOMException
|
631
|
+
* DOMSTRING_SIZE_ERR: Raised when it would return more characters than
|
632
|
+
* fit in a <code>DOMString</code> variable on the implementation
|
633
|
+
* platform.
|
634
|
+
* @since DOM Level 3
|
635
|
+
*/
|
636
|
+
public void
|
637
|
+
setTextContent(String textContent)
|
638
|
+
throws DOMException
|
639
|
+
{
|
640
|
+
setNodeValue(textContent);
|
641
|
+
}
|
657
642
|
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
643
|
+
/**
|
644
|
+
* This attribute returns the text content of this node and its
|
645
|
+
* descendants. When it is defined to be null, setting it has no effect.
|
646
|
+
* When set, any possible children this node may have are removed and
|
647
|
+
* replaced by a single <code>Text</code> node containing the string
|
648
|
+
* this attribute is set to. On getting, no serialization is performed,
|
649
|
+
* the returned string does not contain any markup. No whitespace
|
650
|
+
* normalization is performed, the returned string does not contain the
|
651
|
+
* element content whitespaces . Similarly, on setting, no parsing is
|
652
|
+
* performed either, the input string is taken as pure textual content.
|
653
|
+
* <br>The string returned is made of the text content of this node
|
654
|
+
* depending on its type, as defined below:
|
655
|
+
* <table border='1'>
|
656
|
+
* <tr>
|
657
|
+
* <th>Node type</th>
|
658
|
+
* <th>Content</th>
|
659
|
+
* </tr>
|
660
|
+
* <tr>
|
661
|
+
* <td valign='top' rowspan='1' colspan='1'>
|
662
|
+
* ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE,
|
663
|
+
* DOCUMENT_FRAGMENT_NODE</td>
|
664
|
+
* <td valign='top' rowspan='1' colspan='1'>concatenation of the <code>textContent</code>
|
665
|
+
* attribute value of every child node, excluding COMMENT_NODE and
|
666
|
+
* PROCESSING_INSTRUCTION_NODE nodes</td>
|
667
|
+
* </tr>
|
668
|
+
* <tr>
|
669
|
+
* <td valign='top' rowspan='1' colspan='1'>ATTRIBUTE_NODE, TEXT_NODE,
|
670
|
+
* CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE</td>
|
671
|
+
* <td valign='top' rowspan='1' colspan='1'>
|
672
|
+
* <code>nodeValue</code></td>
|
673
|
+
* </tr>
|
674
|
+
* <tr>
|
675
|
+
* <td valign='top' rowspan='1' colspan='1'>DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE</td>
|
676
|
+
* <td valign='top' rowspan='1' colspan='1'>
|
677
|
+
* null</td>
|
678
|
+
* </tr>
|
679
|
+
* </table>
|
680
|
+
* @exception DOMException
|
681
|
+
* NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
|
682
|
+
* @exception DOMException
|
683
|
+
* DOMSTRING_SIZE_ERR: Raised when it would return more characters than
|
684
|
+
* fit in a <code>DOMString</code> variable on the implementation
|
685
|
+
* platform.
|
686
|
+
* @since DOM Level 3
|
687
|
+
*/
|
688
|
+
public String
|
689
|
+
getTextContent() throws DOMException
|
690
|
+
{
|
691
|
+
return getNodeValue(); // overriden in some subclasses
|
692
|
+
}
|
693
|
+
|
694
|
+
/**
|
695
|
+
* Compares a node with this node with regard to their position in the
|
696
|
+
* document.
|
697
|
+
* @param other The node to compare against this node.
|
698
|
+
* @return Returns how the given node is positioned relatively to this
|
699
|
+
* node.
|
700
|
+
* @since DOM Level 3
|
701
|
+
*/
|
702
|
+
public short
|
703
|
+
compareDocumentPosition(Node other) throws DOMException
|
704
|
+
{
|
705
|
+
return 0;
|
706
|
+
}
|
707
|
+
|
708
|
+
/**
|
709
|
+
* The absolute base URI of this node or <code>null</code> if undefined.
|
710
|
+
* This value is computed according to . However, when the
|
711
|
+
* <code>Document</code> supports the feature "HTML" , the base URI is
|
712
|
+
* computed using first the value of the href attribute of the HTML BASE
|
713
|
+
* element if any, and the value of the <code>documentURI</code>
|
714
|
+
* attribute from the <code>Document</code> interface otherwise.
|
715
|
+
* <br> When the node is an <code>Element</code>, a <code>Document</code>
|
716
|
+
* or a a <code>ProcessingInstruction</code>, this attribute represents
|
717
|
+
* the properties [base URI] defined in . When the node is a
|
718
|
+
* <code>Notation</code>, an <code>Entity</code>, or an
|
719
|
+
* <code>EntityReference</code>, this attribute represents the
|
720
|
+
* properties [declaration base URI] in the . How will this be affected
|
721
|
+
* by resolution of relative namespace URIs issue?It's not.Should this
|
722
|
+
* only be on Document, Element, ProcessingInstruction, Entity, and
|
723
|
+
* Notation nodes, according to the infoset? If not, what is it equal to
|
724
|
+
* on other nodes? Null? An empty string? I think it should be the
|
725
|
+
* parent's.No.Should this be read-only and computed or and actual
|
726
|
+
* read-write attribute?Read-only and computed (F2F 19 Jun 2000 and
|
727
|
+
* teleconference 30 May 2001).If the base HTML element is not yet
|
728
|
+
* attached to a document, does the insert change the Document.baseURI?
|
729
|
+
* Yes. (F2F 26 Sep 2001)
|
730
|
+
* @since DOM Level 3
|
731
|
+
*/
|
732
|
+
public String
|
733
|
+
getBaseURI()
|
734
|
+
{
|
735
|
+
return null;
|
736
|
+
}
|
685
737
|
}
|