nokogiri 1.11.7-java → 1.12.0.rc1-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/LICENSE-DEPENDENCIES.md +243 -22
- data/LICENSE.md +1 -1
- data/README.md +6 -5
- data/ext/java/nokogiri/{HtmlDocument.java → Html4Document.java} +8 -22
- data/ext/java/nokogiri/{HtmlElementDescription.java → Html4ElementDescription.java} +6 -6
- data/ext/java/nokogiri/{HtmlEntityLookup.java → Html4EntityLookup.java} +5 -5
- data/ext/java/nokogiri/{HtmlSaxParserContext.java → Html4SaxParserContext.java} +13 -13
- data/ext/java/nokogiri/{HtmlSaxPushParser.java → Html4SaxPushParser.java} +14 -14
- data/ext/java/nokogiri/NokogiriService.java +20 -20
- data/ext/java/nokogiri/XmlAttr.java +2 -2
- data/ext/java/nokogiri/XmlDocument.java +14 -14
- data/ext/java/nokogiri/XmlElementContent.java +5 -5
- data/ext/java/nokogiri/XmlNode.java +74 -74
- data/ext/java/nokogiri/XmlSaxPushParser.java +2 -2
- data/ext/java/nokogiri/XmlSyntaxError.java +1 -1
- data/ext/java/nokogiri/XmlXpathContext.java +9 -9
- data/ext/java/nokogiri/XsltStylesheet.java +8 -8
- data/ext/java/nokogiri/internals/HtmlDomParserContext.java +4 -4
- data/ext/java/nokogiri/internals/NokogiriHandler.java +1 -1
- data/ext/java/nokogiri/internals/NokogiriHelpers.java +57 -57
- data/ext/java/nokogiri/internals/SaveContextVisitor.java +24 -24
- data/ext/java/nokogiri/internals/c14n/CanonicalizerBase.java +105 -105
- data/ext/java/nokogiri/internals/c14n/XMLUtils.java +30 -30
- data/ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java +87 -87
- data/ext/java/nokogiri/internals/dom2dtm/DOM2DTMdefaultNamespaceDeclarationNode.java +95 -95
- data/ext/nokogiri/depend +35 -34
- data/ext/nokogiri/extconf.rb +181 -103
- data/ext/nokogiri/gumbo.c +611 -0
- data/ext/nokogiri/{html_document.c → html4_document.c} +8 -8
- data/ext/nokogiri/{html_element_description.c → html4_element_description.c} +20 -18
- data/ext/nokogiri/{html_entity_lookup.c → html4_entity_lookup.c} +7 -7
- data/ext/nokogiri/{html_sax_parser_context.c → html4_sax_parser_context.c} +5 -5
- data/ext/nokogiri/{html_sax_push_parser.c → html4_sax_push_parser.c} +4 -4
- data/ext/nokogiri/libxml2_backwards_compat.c +30 -30
- data/ext/nokogiri/nokogiri.c +51 -38
- data/ext/nokogiri/xml_document.c +13 -13
- data/ext/nokogiri/xml_element_content.c +2 -0
- data/ext/nokogiri/xml_encoding_handler.c +11 -6
- data/ext/nokogiri/xml_namespace.c +2 -0
- data/ext/nokogiri/xml_node.c +102 -102
- data/ext/nokogiri/xml_node_set.c +20 -20
- data/ext/nokogiri/xml_reader.c +2 -0
- data/ext/nokogiri/xml_sax_parser.c +6 -6
- data/ext/nokogiri/xml_sax_parser_context.c +2 -0
- data/ext/nokogiri/xml_schema.c +2 -0
- data/ext/nokogiri/xml_xpath_context.c +67 -65
- data/ext/nokogiri/xslt_stylesheet.c +2 -1
- data/gumbo-parser/CHANGES.md +63 -0
- data/gumbo-parser/Makefile +101 -0
- data/gumbo-parser/THANKS +27 -0
- data/lib/nokogiri.rb +31 -29
- data/lib/nokogiri/css.rb +14 -14
- data/lib/nokogiri/css/parser.rb +1 -1
- data/lib/nokogiri/css/parser.y +1 -1
- data/lib/nokogiri/css/syntax_error.rb +1 -1
- data/lib/nokogiri/extension.rb +2 -2
- data/lib/nokogiri/gumbo.rb +14 -0
- data/lib/nokogiri/html.rb +31 -27
- data/lib/nokogiri/html4.rb +40 -0
- data/lib/nokogiri/{html → html4}/builder.rb +2 -2
- data/lib/nokogiri/{html → html4}/document.rb +4 -4
- data/lib/nokogiri/{html → html4}/document_fragment.rb +3 -3
- data/lib/nokogiri/{html → html4}/element_description.rb +1 -1
- data/lib/nokogiri/{html → html4}/element_description_defaults.rb +1 -1
- data/lib/nokogiri/{html → html4}/entity_lookup.rb +1 -1
- data/lib/nokogiri/{html → html4}/sax/parser.rb +11 -14
- data/lib/nokogiri/html4/sax/parser_context.rb +19 -0
- data/lib/nokogiri/{html → html4}/sax/push_parser.rb +5 -5
- data/lib/nokogiri/html5.rb +473 -0
- data/lib/nokogiri/html5/document.rb +74 -0
- data/lib/nokogiri/html5/document_fragment.rb +80 -0
- data/lib/nokogiri/html5/node.rb +93 -0
- data/lib/nokogiri/nokogiri.jar +0 -0
- data/lib/nokogiri/version/constant.rb +1 -1
- data/lib/nokogiri/version/info.rb +11 -2
- data/lib/nokogiri/xml.rb +35 -36
- data/lib/nokogiri/xml/node.rb +6 -5
- data/lib/nokogiri/xml/parse_options.rb +2 -0
- data/lib/nokogiri/xml/pp.rb +2 -2
- data/lib/nokogiri/xml/sax.rb +4 -4
- data/lib/nokogiri/xml/sax/document.rb +24 -30
- data/lib/nokogiri/xml/xpath.rb +2 -2
- data/lib/nokogiri/xslt.rb +16 -16
- data/lib/nokogiri/xslt/stylesheet.rb +1 -1
- metadata +42 -42
- data/lib/nokogiri/html/sax/parser_context.rb +0 -17
@@ -211,7 +211,7 @@ public class XmlSaxPushParser extends RubyObject
|
|
211
211
|
futureTask = null;
|
212
212
|
}
|
213
213
|
|
214
|
-
// SHARED for
|
214
|
+
// SHARED for Html4SaxPushParser
|
215
215
|
static void
|
216
216
|
terminateExecution(final ExecutorService executor, final NokogiriBlockingQueueInputStream stream,
|
217
217
|
final FutureTask<?> futureTask)
|
@@ -248,7 +248,7 @@ public class XmlSaxPushParser extends RubyObject
|
|
248
248
|
this(context, handler, parse(context.runtime, stream), stream);
|
249
249
|
}
|
250
250
|
|
251
|
-
// IMPL with
|
251
|
+
// IMPL with Html4SaxPushParser
|
252
252
|
protected
|
253
253
|
ParserTask(ThreadContext context, IRubyObject handler, XmlSaxParserContext parser, InputStream stream)
|
254
254
|
{
|
@@ -63,7 +63,7 @@ public class XmlSyntaxError extends RubyException
|
|
63
63
|
public static XmlSyntaxError
|
64
64
|
createHTMLSyntaxError(final Ruby runtime)
|
65
65
|
{
|
66
|
-
RubyClass klazz = (RubyClass) runtime.getClassFromPath("Nokogiri::
|
66
|
+
RubyClass klazz = (RubyClass) runtime.getClassFromPath("Nokogiri::HTML4::SyntaxError");
|
67
67
|
return new XmlSyntaxError(runtime, klazz);
|
68
68
|
}
|
69
69
|
|
@@ -203,15 +203,15 @@ public class XmlXpathContext extends RubyObject
|
|
203
203
|
}
|
204
204
|
|
205
205
|
switch (xobj.getType()) {
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
206
|
+
case XObject.CLASS_BOOLEAN :
|
207
|
+
return context.runtime.newBoolean(xobj.bool());
|
208
|
+
case XObject.CLASS_NUMBER :
|
209
|
+
return context.runtime.newFloat(xobj.num());
|
210
|
+
case XObject.CLASS_NODESET :
|
211
|
+
IRubyObject[] nodes = nodeListToRubyArray(context.runtime, xobj.nodelist());
|
212
|
+
return XmlNodeSet.newNodeSet(context.runtime, nodes, this.context);
|
213
|
+
default :
|
214
|
+
return context.runtime.newString(xobj.str());
|
215
215
|
}
|
216
216
|
}
|
217
217
|
|
@@ -213,12 +213,12 @@ public class XsltStylesheet extends RubyObject
|
|
213
213
|
}
|
214
214
|
|
215
215
|
switch (elistener.getErrorType()) {
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
216
|
+
case ERROR:
|
217
|
+
case FATAL:
|
218
|
+
throw runtime.newRuntimeError(elistener.getErrorMessage());
|
219
|
+
case WARNING:
|
220
|
+
default:
|
221
|
+
// no-op
|
222
222
|
}
|
223
223
|
|
224
224
|
if (stringResult == null) {
|
@@ -286,7 +286,7 @@ public class XsltStylesheet extends RubyObject
|
|
286
286
|
createDocumentFromDomResult(ThreadContext context, Ruby runtime, DOMResult domResult)
|
287
287
|
{
|
288
288
|
if ("html".equals(domResult.getNode().getFirstChild().getNodeName())) {
|
289
|
-
return new
|
289
|
+
return new Html4Document(context.runtime, (Document) domResult.getNode());
|
290
290
|
} else {
|
291
291
|
return new XmlDocument(context.runtime, (Document) domResult.getNode());
|
292
292
|
}
|
@@ -322,7 +322,7 @@ public class XsltStylesheet extends RubyObject
|
|
322
322
|
RubyClass parse_options = (RubyClass)runtime.getClassFromPath("Nokogiri::XML::ParseOptions");
|
323
323
|
if (htmlish) {
|
324
324
|
args[3] = parse_options.getConstant("DEFAULT_HTML");
|
325
|
-
RubyClass htmlDocumentClass = getNokogiriClass(runtime, "Nokogiri::
|
325
|
+
RubyClass htmlDocumentClass = getNokogiriClass(runtime, "Nokogiri::HTML4::Document");
|
326
326
|
return Helpers.invoke(context, htmlDocumentClass, "parse", args);
|
327
327
|
} else {
|
328
328
|
args[3] = parse_options.getConstant("DEFAULT_XML");
|
@@ -4,7 +4,7 @@ import static nokogiri.internals.NokogiriHelpers.getNokogiriClass;
|
|
4
4
|
import static nokogiri.internals.NokogiriHelpers.isNamespace;
|
5
5
|
import static nokogiri.internals.NokogiriHelpers.stringOrNil;
|
6
6
|
|
7
|
-
import nokogiri.
|
7
|
+
import nokogiri.Html4Document;
|
8
8
|
import nokogiri.NokogiriService;
|
9
9
|
import nokogiri.XmlDocument;
|
10
10
|
import nokogiri.XmlSyntaxError;
|
@@ -28,7 +28,7 @@ import org.w3c.dom.Node;
|
|
28
28
|
import org.w3c.dom.NodeList;
|
29
29
|
|
30
30
|
/**
|
31
|
-
* Parser for
|
31
|
+
* Parser for Html4Document. This class actually parses Html4Document using NekoHtml.
|
32
32
|
*
|
33
33
|
* @author sergio
|
34
34
|
* @author Patrick Mahoney <pat@polycrystal.org>
|
@@ -115,12 +115,12 @@ public class HtmlDomParserContext extends XmlDomParserContext
|
|
115
115
|
protected XmlDocument
|
116
116
|
wrapDocument(ThreadContext context, RubyClass klass, Document document)
|
117
117
|
{
|
118
|
-
|
118
|
+
Html4Document htmlDocument = new Html4Document(context.runtime, klass, document);
|
119
119
|
htmlDocument.setDocumentNode(context.runtime, document);
|
120
120
|
Helpers.invoke(context, htmlDocument, "initialize");
|
121
121
|
|
122
122
|
if (ruby_encoding.isNil()) {
|
123
|
-
// ruby_encoding might have detected by
|
123
|
+
// ruby_encoding might have detected by Html4Document::EncodingReader
|
124
124
|
if (detected_encoding != null && !detected_encoding.isNil()) {
|
125
125
|
ruby_encoding = detected_encoding;
|
126
126
|
} else {
|
@@ -59,7 +59,7 @@ public class NokogiriHandler extends DefaultHandler2 implements XmlDeclHandler
|
|
59
59
|
this.object = object;
|
60
60
|
charactersBuilder = new StringBuilder();
|
61
61
|
String objectName = object.getMetaClass().getName();
|
62
|
-
if ("Nokogiri::
|
62
|
+
if ("Nokogiri::HTML4::SAX::Parser".equals(objectName)) { needEmptyAttrCheck = true; }
|
63
63
|
}
|
64
64
|
|
65
65
|
@Override
|
@@ -25,7 +25,7 @@ import org.w3c.dom.Document;
|
|
25
25
|
import org.w3c.dom.Node;
|
26
26
|
import org.w3c.dom.NodeList;
|
27
27
|
|
28
|
-
import nokogiri.
|
28
|
+
import nokogiri.Html4Document;
|
29
29
|
import nokogiri.NokogiriService;
|
30
30
|
import nokogiri.XmlAttr;
|
31
31
|
import nokogiri.XmlCdata;
|
@@ -89,7 +89,7 @@ public class NokogiriHelpers
|
|
89
89
|
if (node == null) { return runtime.getNil(); }
|
90
90
|
if (node.getNodeType() == Node.ATTRIBUTE_NODE && isNamespace(node.getNodeName())) {
|
91
91
|
XmlDocument xmlDocument = (XmlDocument) node.getOwnerDocument().getUserData(CACHED_NODE);
|
92
|
-
if (!(xmlDocument instanceof
|
92
|
+
if (!(xmlDocument instanceof Html4Document)) {
|
93
93
|
String prefix = getLocalNameForNamespace(((Attr) node).getName(), null);
|
94
94
|
String href = ((Attr) node).getValue();
|
95
95
|
XmlNamespace xmlNamespace = xmlDocument.getNamespaceCache().get(prefix, href);
|
@@ -116,59 +116,59 @@ public class NokogiriHelpers
|
|
116
116
|
if (node == null) { return runtime.getNil(); }
|
117
117
|
// this is slow; need a way to cache nokogiri classes/modules somewhere
|
118
118
|
switch (node.getNodeType()) {
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
119
|
+
case Node.ELEMENT_NODE:
|
120
|
+
XmlElement xmlElement = (XmlElement) NokogiriService.XML_ELEMENT_ALLOCATOR.allocate(runtime, getNokogiriClass(runtime,
|
121
|
+
"Nokogiri::XML::Element"));
|
122
|
+
xmlElement.setNode(runtime, node);
|
123
|
+
return xmlElement;
|
124
|
+
case Node.ATTRIBUTE_NODE:
|
125
|
+
XmlAttr xmlAttr = (XmlAttr) NokogiriService.XML_ATTR_ALLOCATOR.allocate(runtime, getNokogiriClass(runtime,
|
126
|
+
"Nokogiri::XML::Attr"));
|
127
|
+
xmlAttr.setNode(runtime, node);
|
128
|
+
return xmlAttr;
|
129
|
+
case Node.TEXT_NODE:
|
130
|
+
XmlText xmlText = (XmlText) NokogiriService.XML_TEXT_ALLOCATOR.allocate(runtime, getNokogiriClass(runtime,
|
131
|
+
"Nokogiri::XML::Text"));
|
132
|
+
xmlText.setNode(runtime, node);
|
133
|
+
return xmlText;
|
134
|
+
case Node.COMMENT_NODE:
|
135
|
+
XmlComment xmlComment = (XmlComment) NokogiriService.XML_COMMENT_ALLOCATOR.allocate(runtime, getNokogiriClass(runtime,
|
136
|
+
"Nokogiri::XML::Comment"));
|
137
|
+
xmlComment.setNode(runtime, node);
|
138
|
+
return xmlComment;
|
139
|
+
case Node.ENTITY_NODE:
|
140
|
+
return new XmlNode(runtime, getNokogiriClass(runtime, "Nokogiri::XML::EntityDecl"), node);
|
141
|
+
case Node.ENTITY_REFERENCE_NODE:
|
142
|
+
XmlEntityReference xmlEntityRef = (XmlEntityReference) NokogiriService.XML_ENTITY_REFERENCE_ALLOCATOR.allocate(runtime,
|
143
|
+
getNokogiriClass(runtime, "Nokogiri::XML::EntityReference"));
|
144
|
+
xmlEntityRef.setNode(runtime, node);
|
145
|
+
return xmlEntityRef;
|
146
|
+
case Node.PROCESSING_INSTRUCTION_NODE:
|
147
|
+
XmlProcessingInstruction xmlProcessingInstruction = (XmlProcessingInstruction)
|
148
|
+
NokogiriService.XML_PROCESSING_INSTRUCTION_ALLOCATOR.allocate(runtime, getNokogiriClass(runtime,
|
149
|
+
"Nokogiri::XML::ProcessingInstruction"));
|
150
|
+
xmlProcessingInstruction.setNode(runtime, node);
|
151
|
+
return xmlProcessingInstruction;
|
152
|
+
case Node.CDATA_SECTION_NODE:
|
153
|
+
XmlCdata xmlCdata = (XmlCdata) NokogiriService.XML_CDATA_ALLOCATOR.allocate(runtime, getNokogiriClass(runtime,
|
154
|
+
"Nokogiri::XML::CDATA"));
|
155
|
+
xmlCdata.setNode(runtime, node);
|
156
|
+
return xmlCdata;
|
157
|
+
case Node.DOCUMENT_NODE:
|
158
|
+
XmlDocument xmlDocument = (XmlDocument) NokogiriService.XML_DOCUMENT_ALLOCATOR.allocate(runtime,
|
159
|
+
getNokogiriClass(runtime, "Nokogiri::XML::Document"));
|
160
|
+
xmlDocument.setDocumentNode(runtime, (Document) node);
|
161
|
+
return xmlDocument;
|
162
|
+
case Node.DOCUMENT_TYPE_NODE:
|
163
|
+
XmlDtd xmlDtd = (XmlDtd) NokogiriService.XML_DTD_ALLOCATOR.allocate(runtime, getNokogiriClass(runtime,
|
164
|
+
"Nokogiri::XML::DTD"));
|
165
|
+
xmlDtd.setNode(runtime, node);
|
166
|
+
return xmlDtd;
|
167
|
+
default:
|
168
|
+
XmlNode xmlNode = (XmlNode) NokogiriService.XML_NODE_ALLOCATOR.allocate(runtime, getNokogiriClass(runtime,
|
169
|
+
"Nokogiri::XML::Node"));
|
170
|
+
xmlNode.setNode(runtime, node);
|
171
|
+
return xmlNode;
|
172
172
|
}
|
173
173
|
}
|
174
174
|
|
@@ -723,8 +723,8 @@ public class NokogiriHelpers
|
|
723
723
|
public static CharSequence
|
724
724
|
convertEncodingByNKFIfNecessary(ThreadContext context, XmlDocument doc, CharSequence str)
|
725
725
|
{
|
726
|
-
if (!(doc instanceof
|
727
|
-
String parsed_encoding = ((
|
726
|
+
if (!(doc instanceof Html4Document)) { return str; }
|
727
|
+
String parsed_encoding = ((Html4Document)doc).getPraedEncoding();
|
728
728
|
if (parsed_encoding == null) { return str; }
|
729
729
|
String ruby_encoding = rubyStringToString(doc.getEncoding());
|
730
730
|
if (ruby_encoding == null) { return str; }
|
@@ -296,30 +296,30 @@ public class SaveContextVisitor
|
|
296
296
|
for (int i = 0; i < str.length(); i++) {
|
297
297
|
char c;
|
298
298
|
switch (c = str.charAt(i)) {
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
299
|
+
case '\n':
|
300
|
+
buffer.append(" ");
|
301
|
+
break;
|
302
|
+
case '\r':
|
303
|
+
buffer.append(" ");
|
304
|
+
break;
|
305
|
+
case '\t':
|
306
|
+
buffer.append("	");
|
307
|
+
break;
|
308
|
+
case '"':
|
309
|
+
if (htmlDoc) { buffer.append("%22"); }
|
310
|
+
else { buffer.append("""); }
|
311
|
+
break;
|
312
|
+
case '<':
|
313
|
+
buffer.append("<");
|
314
|
+
break;
|
315
|
+
case '>':
|
316
|
+
buffer.append(">");
|
317
|
+
break;
|
318
|
+
case '&':
|
319
|
+
buffer.append("&");
|
320
|
+
break;
|
321
|
+
default:
|
322
|
+
buffer.append(c);
|
323
323
|
}
|
324
324
|
}
|
325
325
|
|
@@ -202,75 +202,75 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi
|
|
202
202
|
do {
|
203
203
|
switch (currentNode.getNodeType()) {
|
204
204
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
case Node.COMMENT_NODE :
|
218
|
-
if (includeComments) {
|
219
|
-
outputCommentToWriter((Comment) currentNode, writer, documentLevel);
|
220
|
-
}
|
221
|
-
break;
|
222
|
-
|
223
|
-
case Node.PROCESSING_INSTRUCTION_NODE :
|
224
|
-
outputPItoWriter((ProcessingInstruction) currentNode, writer, documentLevel);
|
225
|
-
break;
|
205
|
+
case Node.ENTITY_NODE :
|
206
|
+
case Node.NOTATION_NODE :
|
207
|
+
case Node.ATTRIBUTE_NODE :
|
208
|
+
// illegal node type during traversal
|
209
|
+
throw new CanonicalizationException("empty");
|
210
|
+
|
211
|
+
case Node.DOCUMENT_FRAGMENT_NODE :
|
212
|
+
case Node.DOCUMENT_NODE :
|
213
|
+
ns.outputNodePush();
|
214
|
+
sibling = currentNode.getFirstChild();
|
215
|
+
break;
|
226
216
|
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
217
|
+
case Node.COMMENT_NODE :
|
218
|
+
if (includeComments) {
|
219
|
+
outputCommentToWriter((Comment) currentNode, writer, documentLevel);
|
220
|
+
}
|
221
|
+
break;
|
231
222
|
|
232
|
-
|
233
|
-
|
234
|
-
if (currentNode == excludeNode) {
|
223
|
+
case Node.PROCESSING_INSTRUCTION_NODE :
|
224
|
+
outputPItoWriter((ProcessingInstruction) currentNode, writer, documentLevel);
|
235
225
|
break;
|
236
|
-
|
237
|
-
|
226
|
+
|
227
|
+
case Node.TEXT_NODE :
|
228
|
+
case Node.CDATA_SECTION_NODE :
|
229
|
+
outputTextToWriter(currentNode.getNodeValue(), writer);
|
238
230
|
break;
|
239
|
-
}
|
240
231
|
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
232
|
+
case Node.ELEMENT_NODE :
|
233
|
+
documentLevel = NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
|
234
|
+
if (currentNode == excludeNode) {
|
235
|
+
break;
|
236
|
+
}
|
237
|
+
if (filter != null && !filter.includeNodes(currentNode, parentNode)) {
|
238
|
+
break;
|
239
|
+
}
|
240
|
+
|
241
|
+
Element currentElement = (Element)currentNode;
|
242
|
+
//Add a level to the nssymbtable. So latter can be pop-back.
|
243
|
+
ns.outputNodePush();
|
244
|
+
writer.write('<');
|
245
|
+
String name = currentElement.getTagName();
|
246
|
+
UtfHelpper.writeByte(name, writer, cache);
|
247
|
+
|
248
|
+
Iterator<Attr> attrs = this.handleAttributesSubtree(currentElement, ns);
|
249
|
+
if (attrs != null) {
|
250
|
+
//we output all Attrs which are available
|
251
|
+
while (attrs.hasNext()) {
|
252
|
+
Attr attr = attrs.next();
|
253
|
+
outputAttrToWriter(attr.getNodeName(), attr.getNodeValue(), writer, cache);
|
254
|
+
}
|
254
255
|
}
|
255
|
-
}
|
256
|
-
writer.write('>');
|
257
|
-
sibling = currentNode.getFirstChild();
|
258
|
-
if (sibling == null) {
|
259
|
-
writer.write(END_TAG);
|
260
|
-
UtfHelpper.writeStringToUtf8(name, writer);
|
261
256
|
writer.write('>');
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
257
|
+
sibling = currentNode.getFirstChild();
|
258
|
+
if (sibling == null) {
|
259
|
+
writer.write(END_TAG);
|
260
|
+
UtfHelpper.writeStringToUtf8(name, writer);
|
261
|
+
writer.write('>');
|
262
|
+
//We finished with this level, pop to the previous definitions.
|
263
|
+
ns.outputNodePop();
|
264
|
+
if (parentNode != null) {
|
265
|
+
sibling = currentNode.getNextSibling();
|
266
|
+
}
|
267
|
+
} else {
|
268
|
+
parentNode = currentElement;
|
266
269
|
}
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
case Node.DOCUMENT_TYPE_NODE :
|
272
|
-
default :
|
273
|
-
break;
|
270
|
+
break;
|
271
|
+
case Node.DOCUMENT_TYPE_NODE :
|
272
|
+
default :
|
273
|
+
break;
|
274
274
|
}
|
275
275
|
while (sibling == null && parentNode != null) {
|
276
276
|
writer.write(END_TAG);
|
@@ -477,37 +477,37 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi
|
|
477
477
|
|
478
478
|
switch (c) {
|
479
479
|
|
480
|
-
|
481
|
-
|
482
|
-
|
480
|
+
case '&' :
|
481
|
+
toWrite = AMP;
|
482
|
+
break;
|
483
483
|
|
484
|
-
|
485
|
-
|
486
|
-
|
484
|
+
case '<' :
|
485
|
+
toWrite = LT;
|
486
|
+
break;
|
487
487
|
|
488
|
-
|
489
|
-
|
490
|
-
|
488
|
+
case '"' :
|
489
|
+
toWrite = QUOT;
|
490
|
+
break;
|
491
491
|
|
492
|
-
|
493
|
-
|
494
|
-
|
492
|
+
case 0x09 : // '\t'
|
493
|
+
toWrite = X9;
|
494
|
+
break;
|
495
495
|
|
496
|
-
|
497
|
-
|
498
|
-
|
496
|
+
case 0x0A : // '\n'
|
497
|
+
toWrite = XA;
|
498
|
+
break;
|
499
499
|
|
500
|
-
|
501
|
-
|
502
|
-
|
500
|
+
case 0x0D : // '\r'
|
501
|
+
toWrite = XD;
|
502
|
+
break;
|
503
503
|
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
504
|
+
default :
|
505
|
+
if (c < 0x80) {
|
506
|
+
writer.write(c);
|
507
|
+
} else {
|
508
|
+
UtfHelpper.writeCharToUtf8(c, writer);
|
509
|
+
}
|
510
|
+
continue;
|
511
511
|
}
|
512
512
|
writer.write(toWrite);
|
513
513
|
}
|
@@ -629,29 +629,29 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi
|
|
629
629
|
|
630
630
|
switch (c) {
|
631
631
|
|
632
|
-
|
633
|
-
|
634
|
-
|
632
|
+
case '&' :
|
633
|
+
toWrite = AMP;
|
634
|
+
break;
|
635
635
|
|
636
|
-
|
637
|
-
|
638
|
-
|
636
|
+
case '<' :
|
637
|
+
toWrite = LT;
|
638
|
+
break;
|
639
639
|
|
640
|
-
|
641
|
-
|
642
|
-
|
640
|
+
case '>' :
|
641
|
+
toWrite = GT;
|
642
|
+
break;
|
643
643
|
|
644
|
-
|
645
|
-
|
646
|
-
|
644
|
+
case 0xD :
|
645
|
+
toWrite = XD;
|
646
|
+
break;
|
647
647
|
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
648
|
+
default :
|
649
|
+
if (c < 0x80) {
|
650
|
+
writer.write(c);
|
651
|
+
} else {
|
652
|
+
UtfHelpper.writeCharToUtf8(c, writer);
|
653
|
+
}
|
654
|
+
continue;
|
655
655
|
}
|
656
656
|
writer.write(toWrite);
|
657
657
|
}
|