nokogiri-backport 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (239) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +3 -0
  3. data/LICENSE-DEPENDENCIES.md +1682 -0
  4. data/LICENSE.md +9 -0
  5. data/README.md +272 -0
  6. data/bin/nokogiri +118 -0
  7. data/dependencies.yml +74 -0
  8. data/ext/java/nokogiri/EncodingHandler.java +124 -0
  9. data/ext/java/nokogiri/HtmlDocument.java +178 -0
  10. data/ext/java/nokogiri/HtmlElementDescription.java +148 -0
  11. data/ext/java/nokogiri/HtmlEntityLookup.java +79 -0
  12. data/ext/java/nokogiri/HtmlSaxParserContext.java +282 -0
  13. data/ext/java/nokogiri/HtmlSaxPushParser.java +222 -0
  14. data/ext/java/nokogiri/NokogiriService.java +597 -0
  15. data/ext/java/nokogiri/XmlAttr.java +162 -0
  16. data/ext/java/nokogiri/XmlAttributeDecl.java +129 -0
  17. data/ext/java/nokogiri/XmlCdata.java +82 -0
  18. data/ext/java/nokogiri/XmlComment.java +97 -0
  19. data/ext/java/nokogiri/XmlDocument.java +633 -0
  20. data/ext/java/nokogiri/XmlDocumentFragment.java +185 -0
  21. data/ext/java/nokogiri/XmlDtd.java +481 -0
  22. data/ext/java/nokogiri/XmlElement.java +68 -0
  23. data/ext/java/nokogiri/XmlElementContent.java +382 -0
  24. data/ext/java/nokogiri/XmlElementDecl.java +147 -0
  25. data/ext/java/nokogiri/XmlEntityDecl.java +157 -0
  26. data/ext/java/nokogiri/XmlEntityReference.java +101 -0
  27. data/ext/java/nokogiri/XmlNamespace.java +199 -0
  28. data/ext/java/nokogiri/XmlNode.java +1684 -0
  29. data/ext/java/nokogiri/XmlNodeSet.java +434 -0
  30. data/ext/java/nokogiri/XmlProcessingInstruction.java +100 -0
  31. data/ext/java/nokogiri/XmlReader.java +531 -0
  32. data/ext/java/nokogiri/XmlRelaxng.java +151 -0
  33. data/ext/java/nokogiri/XmlSaxParserContext.java +374 -0
  34. data/ext/java/nokogiri/XmlSaxPushParser.java +286 -0
  35. data/ext/java/nokogiri/XmlSchema.java +388 -0
  36. data/ext/java/nokogiri/XmlSyntaxError.java +138 -0
  37. data/ext/java/nokogiri/XmlText.java +110 -0
  38. data/ext/java/nokogiri/XmlXpathContext.java +301 -0
  39. data/ext/java/nokogiri/XsltStylesheet.java +347 -0
  40. data/ext/java/nokogiri/internals/ClosedStreamException.java +10 -0
  41. data/ext/java/nokogiri/internals/HtmlDomParserContext.java +252 -0
  42. data/ext/java/nokogiri/internals/IgnoreSchemaErrorsErrorHandler.java +20 -0
  43. data/ext/java/nokogiri/internals/NokogiriBlockingQueueInputStream.java +151 -0
  44. data/ext/java/nokogiri/internals/NokogiriDomParser.java +116 -0
  45. data/ext/java/nokogiri/internals/NokogiriEntityResolver.java +121 -0
  46. data/ext/java/nokogiri/internals/NokogiriErrorHandler.java +69 -0
  47. data/ext/java/nokogiri/internals/NokogiriHandler.java +327 -0
  48. data/ext/java/nokogiri/internals/NokogiriHelpers.java +734 -0
  49. data/ext/java/nokogiri/internals/NokogiriNamespaceCache.java +217 -0
  50. data/ext/java/nokogiri/internals/NokogiriNamespaceContext.java +127 -0
  51. data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java +100 -0
  52. data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java +121 -0
  53. data/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java +78 -0
  54. data/ext/java/nokogiri/internals/NokogiriXPathFunction.java +180 -0
  55. data/ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java +72 -0
  56. data/ext/java/nokogiri/internals/NokogiriXPathVariableResolver.java +60 -0
  57. data/ext/java/nokogiri/internals/NokogiriXsltErrorListener.java +87 -0
  58. data/ext/java/nokogiri/internals/ParserContext.java +259 -0
  59. data/ext/java/nokogiri/internals/ReaderNode.java +488 -0
  60. data/ext/java/nokogiri/internals/SaveContextVisitor.java +778 -0
  61. data/ext/java/nokogiri/internals/SchemaErrorHandler.java +73 -0
  62. data/ext/java/nokogiri/internals/XalanDTMManagerPatch.java +168 -0
  63. data/ext/java/nokogiri/internals/XmlDeclHandler.java +42 -0
  64. data/ext/java/nokogiri/internals/XmlDomParserContext.java +274 -0
  65. data/ext/java/nokogiri/internals/XmlSaxParser.java +65 -0
  66. data/ext/java/nokogiri/internals/c14n/AttrCompare.java +119 -0
  67. data/ext/java/nokogiri/internals/c14n/C14nHelper.java +159 -0
  68. data/ext/java/nokogiri/internals/c14n/CanonicalFilter.java +37 -0
  69. data/ext/java/nokogiri/internals/c14n/CanonicalizationException.java +93 -0
  70. data/ext/java/nokogiri/internals/c14n/Canonicalizer.java +252 -0
  71. data/ext/java/nokogiri/internals/c14n/Canonicalizer11.java +639 -0
  72. data/ext/java/nokogiri/internals/c14n/Canonicalizer11_OmitComments.java +38 -0
  73. data/ext/java/nokogiri/internals/c14n/Canonicalizer11_WithComments.java +38 -0
  74. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315.java +367 -0
  75. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315Excl.java +295 -0
  76. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclOmitComments.java +40 -0
  77. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclWithComments.java +44 -0
  78. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315OmitComments.java +44 -0
  79. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315WithComments.java +43 -0
  80. data/ext/java/nokogiri/internals/c14n/CanonicalizerBase.java +630 -0
  81. data/ext/java/nokogiri/internals/c14n/CanonicalizerPhysical.java +173 -0
  82. data/ext/java/nokogiri/internals/c14n/CanonicalizerSpi.java +76 -0
  83. data/ext/java/nokogiri/internals/c14n/Constants.java +42 -0
  84. data/ext/java/nokogiri/internals/c14n/ElementProxy.java +293 -0
  85. data/ext/java/nokogiri/internals/c14n/HelperNodeList.java +93 -0
  86. data/ext/java/nokogiri/internals/c14n/IgnoreAllErrorHandler.java +79 -0
  87. data/ext/java/nokogiri/internals/c14n/InclusiveNamespaces.java +166 -0
  88. data/ext/java/nokogiri/internals/c14n/InvalidCanonicalizerException.java +76 -0
  89. data/ext/java/nokogiri/internals/c14n/NameSpaceSymbTable.java +402 -0
  90. data/ext/java/nokogiri/internals/c14n/NodeFilter.java +51 -0
  91. data/ext/java/nokogiri/internals/c14n/UtfHelpper.java +179 -0
  92. data/ext/java/nokogiri/internals/c14n/XMLUtils.java +507 -0
  93. data/ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java +1745 -0
  94. data/ext/java/nokogiri/internals/dom2dtm/DOM2DTMdefaultNamespaceDeclarationNode.java +685 -0
  95. data/ext/nokogiri/depend +477 -0
  96. data/ext/nokogiri/extconf.rb +836 -0
  97. data/ext/nokogiri/html_document.c +171 -0
  98. data/ext/nokogiri/html_document.h +10 -0
  99. data/ext/nokogiri/html_element_description.c +279 -0
  100. data/ext/nokogiri/html_element_description.h +10 -0
  101. data/ext/nokogiri/html_entity_lookup.c +32 -0
  102. data/ext/nokogiri/html_entity_lookup.h +8 -0
  103. data/ext/nokogiri/html_sax_parser_context.c +116 -0
  104. data/ext/nokogiri/html_sax_parser_context.h +11 -0
  105. data/ext/nokogiri/html_sax_push_parser.c +87 -0
  106. data/ext/nokogiri/html_sax_push_parser.h +9 -0
  107. data/ext/nokogiri/nokogiri.c +135 -0
  108. data/ext/nokogiri/nokogiri.h +130 -0
  109. data/ext/nokogiri/xml_attr.c +103 -0
  110. data/ext/nokogiri/xml_attr.h +9 -0
  111. data/ext/nokogiri/xml_attribute_decl.c +70 -0
  112. data/ext/nokogiri/xml_attribute_decl.h +9 -0
  113. data/ext/nokogiri/xml_cdata.c +62 -0
  114. data/ext/nokogiri/xml_cdata.h +9 -0
  115. data/ext/nokogiri/xml_comment.c +69 -0
  116. data/ext/nokogiri/xml_comment.h +9 -0
  117. data/ext/nokogiri/xml_document.c +622 -0
  118. data/ext/nokogiri/xml_document.h +23 -0
  119. data/ext/nokogiri/xml_document_fragment.c +48 -0
  120. data/ext/nokogiri/xml_document_fragment.h +10 -0
  121. data/ext/nokogiri/xml_dtd.c +202 -0
  122. data/ext/nokogiri/xml_dtd.h +10 -0
  123. data/ext/nokogiri/xml_element_content.c +123 -0
  124. data/ext/nokogiri/xml_element_content.h +10 -0
  125. data/ext/nokogiri/xml_element_decl.c +69 -0
  126. data/ext/nokogiri/xml_element_decl.h +9 -0
  127. data/ext/nokogiri/xml_encoding_handler.c +79 -0
  128. data/ext/nokogiri/xml_encoding_handler.h +8 -0
  129. data/ext/nokogiri/xml_entity_decl.c +110 -0
  130. data/ext/nokogiri/xml_entity_decl.h +10 -0
  131. data/ext/nokogiri/xml_entity_reference.c +52 -0
  132. data/ext/nokogiri/xml_entity_reference.h +9 -0
  133. data/ext/nokogiri/xml_io.c +63 -0
  134. data/ext/nokogiri/xml_io.h +11 -0
  135. data/ext/nokogiri/xml_libxml2_hacks.c +112 -0
  136. data/ext/nokogiri/xml_libxml2_hacks.h +12 -0
  137. data/ext/nokogiri/xml_namespace.c +111 -0
  138. data/ext/nokogiri/xml_namespace.h +14 -0
  139. data/ext/nokogiri/xml_node.c +1773 -0
  140. data/ext/nokogiri/xml_node.h +13 -0
  141. data/ext/nokogiri/xml_node_set.c +486 -0
  142. data/ext/nokogiri/xml_node_set.h +12 -0
  143. data/ext/nokogiri/xml_processing_instruction.c +56 -0
  144. data/ext/nokogiri/xml_processing_instruction.h +9 -0
  145. data/ext/nokogiri/xml_reader.c +657 -0
  146. data/ext/nokogiri/xml_reader.h +10 -0
  147. data/ext/nokogiri/xml_relax_ng.c +179 -0
  148. data/ext/nokogiri/xml_relax_ng.h +9 -0
  149. data/ext/nokogiri/xml_sax_parser.c +305 -0
  150. data/ext/nokogiri/xml_sax_parser.h +39 -0
  151. data/ext/nokogiri/xml_sax_parser_context.c +262 -0
  152. data/ext/nokogiri/xml_sax_parser_context.h +10 -0
  153. data/ext/nokogiri/xml_sax_push_parser.c +159 -0
  154. data/ext/nokogiri/xml_sax_push_parser.h +9 -0
  155. data/ext/nokogiri/xml_schema.c +276 -0
  156. data/ext/nokogiri/xml_schema.h +9 -0
  157. data/ext/nokogiri/xml_syntax_error.c +64 -0
  158. data/ext/nokogiri/xml_syntax_error.h +13 -0
  159. data/ext/nokogiri/xml_text.c +52 -0
  160. data/ext/nokogiri/xml_text.h +9 -0
  161. data/ext/nokogiri/xml_xpath_context.c +374 -0
  162. data/ext/nokogiri/xml_xpath_context.h +10 -0
  163. data/ext/nokogiri/xslt_stylesheet.c +263 -0
  164. data/ext/nokogiri/xslt_stylesheet.h +14 -0
  165. data/lib/isorelax.jar +0 -0
  166. data/lib/jing.jar +0 -0
  167. data/lib/nekodtd.jar +0 -0
  168. data/lib/nekohtml.jar +0 -0
  169. data/lib/nokogiri/css/node.rb +53 -0
  170. data/lib/nokogiri/css/parser.rb +751 -0
  171. data/lib/nokogiri/css/parser.y +272 -0
  172. data/lib/nokogiri/css/parser_extras.rb +94 -0
  173. data/lib/nokogiri/css/syntax_error.rb +8 -0
  174. data/lib/nokogiri/css/tokenizer.rb +154 -0
  175. data/lib/nokogiri/css/tokenizer.rex +55 -0
  176. data/lib/nokogiri/css/xpath_visitor.rb +260 -0
  177. data/lib/nokogiri/css.rb +28 -0
  178. data/lib/nokogiri/decorators/slop.rb +43 -0
  179. data/lib/nokogiri/html/builder.rb +36 -0
  180. data/lib/nokogiri/html/document.rb +322 -0
  181. data/lib/nokogiri/html/document_fragment.rb +50 -0
  182. data/lib/nokogiri/html/element_description.rb +24 -0
  183. data/lib/nokogiri/html/element_description_defaults.rb +672 -0
  184. data/lib/nokogiri/html/entity_lookup.rb +14 -0
  185. data/lib/nokogiri/html/sax/parser.rb +63 -0
  186. data/lib/nokogiri/html/sax/parser_context.rb +17 -0
  187. data/lib/nokogiri/html/sax/push_parser.rb +37 -0
  188. data/lib/nokogiri/html.rb +38 -0
  189. data/lib/nokogiri/jruby/dependencies.rb +20 -0
  190. data/lib/nokogiri/syntax_error.rb +5 -0
  191. data/lib/nokogiri/version/constant.rb +5 -0
  192. data/lib/nokogiri/version/info.rb +182 -0
  193. data/lib/nokogiri/version.rb +3 -0
  194. data/lib/nokogiri/xml/attr.rb +15 -0
  195. data/lib/nokogiri/xml/attribute_decl.rb +19 -0
  196. data/lib/nokogiri/xml/builder.rb +447 -0
  197. data/lib/nokogiri/xml/cdata.rb +12 -0
  198. data/lib/nokogiri/xml/character_data.rb +8 -0
  199. data/lib/nokogiri/xml/document.rb +290 -0
  200. data/lib/nokogiri/xml/document_fragment.rb +159 -0
  201. data/lib/nokogiri/xml/dtd.rb +33 -0
  202. data/lib/nokogiri/xml/element_content.rb +37 -0
  203. data/lib/nokogiri/xml/element_decl.rb +14 -0
  204. data/lib/nokogiri/xml/entity_decl.rb +20 -0
  205. data/lib/nokogiri/xml/entity_reference.rb +19 -0
  206. data/lib/nokogiri/xml/namespace.rb +14 -0
  207. data/lib/nokogiri/xml/node/save_options.rb +62 -0
  208. data/lib/nokogiri/xml/node.rb +1240 -0
  209. data/lib/nokogiri/xml/node_set.rb +372 -0
  210. data/lib/nokogiri/xml/notation.rb +7 -0
  211. data/lib/nokogiri/xml/parse_options.rb +127 -0
  212. data/lib/nokogiri/xml/pp/character_data.rb +19 -0
  213. data/lib/nokogiri/xml/pp/node.rb +57 -0
  214. data/lib/nokogiri/xml/pp.rb +3 -0
  215. data/lib/nokogiri/xml/processing_instruction.rb +9 -0
  216. data/lib/nokogiri/xml/reader.rb +116 -0
  217. data/lib/nokogiri/xml/relax_ng.rb +37 -0
  218. data/lib/nokogiri/xml/sax/document.rb +172 -0
  219. data/lib/nokogiri/xml/sax/parser.rb +123 -0
  220. data/lib/nokogiri/xml/sax/parser_context.rb +17 -0
  221. data/lib/nokogiri/xml/sax/push_parser.rb +61 -0
  222. data/lib/nokogiri/xml/sax.rb +5 -0
  223. data/lib/nokogiri/xml/schema.rb +72 -0
  224. data/lib/nokogiri/xml/searchable.rb +239 -0
  225. data/lib/nokogiri/xml/syntax_error.rb +71 -0
  226. data/lib/nokogiri/xml/text.rb +10 -0
  227. data/lib/nokogiri/xml/xpath/syntax_error.rb +12 -0
  228. data/lib/nokogiri/xml/xpath.rb +11 -0
  229. data/lib/nokogiri/xml/xpath_context.rb +17 -0
  230. data/lib/nokogiri/xml.rb +76 -0
  231. data/lib/nokogiri/xslt/stylesheet.rb +26 -0
  232. data/lib/nokogiri/xslt.rb +57 -0
  233. data/lib/nokogiri.rb +144 -0
  234. data/lib/serializer.jar +0 -0
  235. data/lib/xalan.jar +0 -0
  236. data/lib/xercesImpl.jar +0 -0
  237. data/lib/xml-apis.jar +0 -0
  238. data/lib/xsd/xmlparser/nokogiri.rb +103 -0
  239. metadata +531 -0
@@ -0,0 +1,685 @@
1
+ /*
2
+ * reserved comment block
3
+ * DO NOT REMOVE OR ALTER!
4
+ */
5
+ /*
6
+ * Copyright 1999-2004 The Apache Software Foundation.
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ */
20
+ /*
21
+ * $Id: DOM2DTMdefaultNamespaceDeclarationNode.java,v 1.2.4.1 2005/09/15 08:15:11 suresh_emailid Exp $
22
+ */
23
+
24
+ // This is copied directly out of the original
25
+ // com.sun.org.apache.xml.internal.dtm.ref.dom2dtm path to allow modifying
26
+ // DOM2DTM and working around package private constructors. Other than the
27
+ // package declaration, this class is unmodified
28
+
29
+ package nokogiri.internals.dom2dtm;
30
+
31
+ import org.apache.xml.dtm.DTMException;
32
+
33
+ import org.w3c.dom.Attr;
34
+ import org.w3c.dom.Document;
35
+ import org.w3c.dom.Element;
36
+ import org.w3c.dom.NamedNodeMap;
37
+ import org.w3c.dom.Node;
38
+ import org.w3c.dom.NodeList;
39
+ import org.w3c.dom.TypeInfo;
40
+ import org.w3c.dom.UserDataHandler;
41
+ import org.w3c.dom.DOMException;
42
+
43
+ /** This is a kluge to let us shove a declaration for xml: into the
44
+ * DOM2DTM model. Basically, it creates a proxy node in DOM space to
45
+ * carry the additional information. This is _NOT_ a full DOM
46
+ * implementation, and shouldn't be one since it sits alongside the
47
+ * DOM rather than becoming part of the DOM model.
48
+ *
49
+ * (This used to be an internal class within DOM2DTM. Moved out because
50
+ * I need to perform an instanceof operation on it to support a temporary
51
+ * workaround in DTMManagerDefault.)
52
+ *
53
+ * %REVIEW% What if the DOM2DTM was built around a DocumentFragment and
54
+ * there isn't a single root element? I think this fails that case...
55
+ *
56
+ * %REVIEW% An alternative solution would be to create the node _only_
57
+ * in DTM space, but given how DOM2DTM is currently written I think
58
+ * this is simplest.
59
+ * */
60
+ public class DOM2DTMdefaultNamespaceDeclarationNode implements Attr,TypeInfo
61
+ {
62
+ final String NOT_SUPPORTED_ERR="Unsupported operation on pseudonode";
63
+
64
+ Element pseudoparent;
65
+ String prefix,uri,nodename;
66
+ int handle;
67
+ DOM2DTMdefaultNamespaceDeclarationNode(Element pseudoparent,String prefix,String uri,int handle)
68
+ {
69
+ this.pseudoparent=pseudoparent;
70
+ this.prefix=prefix;
71
+ this.uri=uri;
72
+ this.handle=handle;
73
+ this.nodename="xmlns:"+prefix;
74
+ }
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
+
117
+ //RAMESH: PENDING=> Add proper implementation for the below DOM L3 additions
118
+
119
+ /**
120
+ * @see org.w3c.dom.TypeInfo#getTypeName()
121
+ */
122
+ public String getTypeName() {return null; }
123
+
124
+ /**
125
+ * @see org.w3c.dom.TypeInfo#getTypeNamespace()
126
+ */
127
+ public String getTypeNamespace() { return null;}
128
+
129
+ /**
130
+ * @see or.gw3c.dom.TypeInfo#isDerivedFrom(String,String,int)
131
+ */
132
+ public boolean isDerivedFrom( String ns, String localName, int derivationMethod ) {
133
+ return false;
134
+ }
135
+
136
+ public TypeInfo getSchemaTypeInfo() { return this; }
137
+
138
+ public boolean isId( ) { return false; }
139
+
140
+ /**
141
+ * Associate an object to a key on this node. The object can later be
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);
157
+ }
158
+
159
+ /**
160
+ * Retrieves the object associated to a key on a this node. The object
161
+ * must first have been set to this node by calling
162
+ * <code>setUserData</code> with the same key.
163
+ * @param key The key the object is associated to.
164
+ * @return Returns the <code>DOMObject</code> associated to the given key
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);
170
+ }
171
+
172
+ /**
173
+ * This method returns a specialized object which implements the
174
+ * specialized APIs of the specified feature and version. The
175
+ * specialized object may also be obtained by using binding-specific
176
+ * casting methods but is not necessarily expected to, as discussed in Mixed DOM implementations.
177
+ * @param feature The name of the feature requested (case-insensitive).
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;
196
+ }
197
+
198
+ /**
199
+ * Tests whether two nodes are equal.
200
+ * <br>This method tests for equality of nodes, not sameness (i.e.,
201
+ * whether the two nodes are references to the same object) which can be
202
+ * tested with <code>Node.isSameNode</code>. All nodes that are the same
203
+ * will also be equal, though the reverse may not be true.
204
+ * <br>Two nodes are equal if and only if the following conditions are
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
+ }
293
+ /*
294
+ if (getBaseURI() == null) {
295
+ if (((NodeImpl) arg).getBaseURI() != null) {
296
+ return false;
297
+ }
298
+ }
299
+ else if (!getBaseURI().equals(((NodeImpl) arg).getBaseURI())) {
300
+ return false;
301
+ }
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;
364
+
365
+
366
+ }
367
+ /*
368
+ case Node.DOCUMENT_NODE : {
369
+ return((NodeImpl)((Document)this).getDocumentElement()).lookupNamespaceURI(specifiedPrefix) ;
370
+ }
371
+ */
372
+ case Node.ENTITY_NODE :
373
+ case Node.NOTATION_NODE:
374
+ case Node.DOCUMENT_FRAGMENT_NODE:
375
+ case Node.DOCUMENT_TYPE_NODE:
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);
381
+
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
+ }
394
+
395
+ }
396
+ }
397
+
398
+ /**
399
+ * DOM Level 3: Experimental
400
+ * This method checks if the specified <code>namespaceURI</code> is the
401
+ * default namespace or not.
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);
432
+ }
433
+ }
434
+
435
+ NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
436
+ if (ancestor != null) {
437
+ return ancestor.isDefaultNamespace(namespaceURI);
438
+ }
439
+ return false;
440
+ }
441
+ case Node.DOCUMENT_NODE:{
442
+ return((NodeImpl)((Document)this).getDocumentElement()).isDefaultNamespace(namespaceURI);
443
+ }
444
+
445
+ case Node.ENTITY_NODE :
446
+ case Node.NOTATION_NODE:
447
+ case Node.DOCUMENT_FRAGMENT_NODE:
448
+ case Node.DOCUMENT_TYPE_NODE:
449
+ // type is unknown
450
+ return false;
451
+ case Node.ATTRIBUTE_NODE:{
452
+ if (this.ownerNode.getNodeType() == Node.ELEMENT_NODE) {
453
+ return ownerNode.isDefaultNamespace(namespaceURI);
454
+
455
+ }
456
+ return false;
457
+ }
458
+ default:{
459
+ NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
460
+ if (ancestor != null) {
461
+ return ancestor.isDefaultNamespace(namespaceURI);
462
+ }
463
+ return false;
464
+ }
465
+
466
+ }
467
+ */
468
+ return false;
469
+
470
+
471
+ }
472
+
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
+ }
488
+
489
+ short type = this.getNodeType();
490
+
491
+ switch (type) {
492
+ /*
493
+ case Node.ELEMENT_NODE: {
494
+
495
+ String namespace = this.getNamespaceURI(); // to flip out children
496
+ return lookupNamespacePrefix(namespaceURI, (ElementImpl)this);
497
+ }
498
+
499
+ case Node.DOCUMENT_NODE:{
500
+ return((NodeImpl)((Document)this).getDocumentElement()).lookupPrefix(namespaceURI);
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);
512
+
513
+ }
514
+ return null;
515
+ }
516
+ default:{
517
+ /*
518
+ NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
519
+ if (ancestor != null) {
520
+ return ancestor.lookupPrefix(namespaceURI);
521
+ }
522
+ */
523
+ return null;
524
+ }
525
+ }
526
+ }
527
+
528
+ /**
529
+ * Returns whether this node is the same node as the given one.
530
+ * <br>This method provides a way to determine whether two
531
+ * <code>Node</code> references returned by the implementation reference
532
+ * the same object. When two <code>Node</code> references are references
533
+ * to the same object, even if through a proxy, the references may be
534
+ * used completely interchangably, such that all attributes have the
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;
545
+ }
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
+ }
596
+
597
+ /**
598
+ * This attribute returns the text content of this node and its
599
+ * descendants. When it is defined to be null, setting it has no effect.
600
+ * When set, any possible children this node may have are removed and
601
+ * replaced by a single <code>Text</code> node containing the string
602
+ * this attribute is set to. On getting, no serialization is performed,
603
+ * the returned string does not contain any markup. No whitespace
604
+ * normalization is performed, the returned string does not contain the
605
+ * element content whitespaces . Similarly, on setting, no parsing is
606
+ * performed either, the input string is taken as pure textual content.
607
+ * <br>The string returned is made of the text content of this node
608
+ * depending on its type, as defined below:
609
+ * <table border='1'>
610
+ * <tr>
611
+ * <th>Node type</th>
612
+ * <th>Content</th>
613
+ * </tr>
614
+ * <tr>
615
+ * <td valign='top' rowspan='1' colspan='1'>
616
+ * ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE,
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
+ }
645
+
646
+ /**
647
+ * Compares a node with this node with regard to their position in the
648
+ * document.
649
+ * @param other The node to compare against this node.
650
+ * @return Returns how the given node is positioned relatively to this
651
+ * node.
652
+ * @since DOM Level 3
653
+ */
654
+ public short compareDocumentPosition(Node other) throws DOMException {
655
+ return 0;
656
+ }
657
+
658
+ /**
659
+ * The absolute base URI of this node or <code>null</code> if undefined.
660
+ * This value is computed according to . However, when the
661
+ * <code>Document</code> supports the feature "HTML" , the base URI is
662
+ * computed using first the value of the href attribute of the HTML BASE
663
+ * element if any, and the value of the <code>documentURI</code>
664
+ * attribute from the <code>Document</code> interface otherwise.
665
+ * <br> When the node is an <code>Element</code>, a <code>Document</code>
666
+ * or a a <code>ProcessingInstruction</code>, this attribute represents
667
+ * the properties [base URI] defined in . When the node is a
668
+ * <code>Notation</code>, an <code>Entity</code>, or an
669
+ * <code>EntityReference</code>, this attribute represents the
670
+ * properties [declaration base URI] in the . How will this be affected
671
+ * by resolution of relative namespace URIs issue?It's not.Should this
672
+ * only be on Document, Element, ProcessingInstruction, Entity, and
673
+ * Notation nodes, according to the infoset? If not, what is it equal to
674
+ * on other nodes? Null? An empty string? I think it should be the
675
+ * parent's.No.Should this be read-only and computed or and actual
676
+ * read-write attribute?Read-only and computed (F2F 19 Jun 2000 and
677
+ * teleconference 30 May 2001).If the base HTML element is not yet
678
+ * attached to a document, does the insert change the Document.baseURI?
679
+ * Yes. (F2F 26 Sep 2001)
680
+ * @since DOM Level 3
681
+ */
682
+ public String getBaseURI() {
683
+ return null;
684
+ }
685
+ }