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
@@ -19,58 +19,69 @@
|
|
19
19
|
package nokogiri.internals.c14n;
|
20
20
|
|
21
21
|
|
22
|
-
public class InvalidCanonicalizerException extends Exception
|
22
|
+
public class InvalidCanonicalizerException extends Exception
|
23
|
+
{
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
/**
|
26
|
+
*
|
27
|
+
*/
|
28
|
+
private static final long serialVersionUID = 1L;
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
30
|
+
/**
|
31
|
+
* Constructor InvalidCanonicalizerException
|
32
|
+
*
|
33
|
+
*/
|
34
|
+
public
|
35
|
+
InvalidCanonicalizerException()
|
36
|
+
{
|
37
|
+
super();
|
38
|
+
}
|
36
39
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
/**
|
41
|
+
* Constructor InvalidCanonicalizerException
|
42
|
+
*
|
43
|
+
* @param message
|
44
|
+
*/
|
45
|
+
public
|
46
|
+
InvalidCanonicalizerException(String message)
|
47
|
+
{
|
48
|
+
super(message);
|
49
|
+
}
|
45
50
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
/**
|
52
|
+
* Constructor InvalidCanonicalizerException
|
53
|
+
*
|
54
|
+
* @param message
|
55
|
+
* @param exArgs
|
56
|
+
*/
|
57
|
+
public
|
58
|
+
InvalidCanonicalizerException(String message, Object... exArgs)
|
59
|
+
{
|
60
|
+
super(C14nHelper.getErrorMessage(message, exArgs));
|
61
|
+
}
|
55
62
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
63
|
+
/**
|
64
|
+
* Constructor InvalidCanonicalizerException
|
65
|
+
*
|
66
|
+
* @param msgID
|
67
|
+
* @param originalException
|
68
|
+
*/
|
69
|
+
public
|
70
|
+
InvalidCanonicalizerException(String message, Exception rootCause)
|
71
|
+
{
|
72
|
+
super(message, rootCause);
|
73
|
+
}
|
65
74
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
75
|
+
/**
|
76
|
+
* Constructor InvalidCanonicalizerException
|
77
|
+
*
|
78
|
+
* @param msgID
|
79
|
+
* @param exArgs
|
80
|
+
* @param originalException
|
81
|
+
*/
|
82
|
+
public
|
83
|
+
InvalidCanonicalizerException(String message, Exception rootCause, Object... exArgs)
|
84
|
+
{
|
85
|
+
super(C14nHelper.getErrorMessage(message, exArgs), rootCause);
|
86
|
+
}
|
76
87
|
}
|
@@ -31,372 +31,422 @@ import org.w3c.dom.Node;
|
|
31
31
|
* and at the same time in a list so it can be removed when the frame is pop back.
|
32
32
|
* @author Raul Benito
|
33
33
|
*/
|
34
|
-
public class NameSpaceSymbTable
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
34
|
+
public class NameSpaceSymbTable
|
35
|
+
{
|
36
|
+
|
37
|
+
private static final String XMLNS = "xmlns";
|
38
|
+
private static final SymbMap initialMap = new SymbMap();
|
39
|
+
|
40
|
+
static
|
41
|
+
{
|
42
|
+
NameSpaceSymbEntry ne = new NameSpaceSymbEntry("", null, true, XMLNS);
|
43
|
+
ne.lastrendered = "";
|
44
|
+
initialMap.put(XMLNS, ne);
|
45
|
+
}
|
46
|
+
|
47
|
+
/**The map betwen prefix-> entry table. */
|
48
|
+
private SymbMap symb;
|
49
|
+
|
50
|
+
/**The stacks for removing the definitions when doing pop.*/
|
51
|
+
private List<SymbMap> level;
|
52
|
+
private boolean cloned = true;
|
53
|
+
|
54
|
+
/**
|
55
|
+
* Default constractor
|
56
|
+
**/
|
57
|
+
public
|
58
|
+
NameSpaceSymbTable()
|
59
|
+
{
|
60
|
+
level = new ArrayList<SymbMap>();
|
61
|
+
//Insert the default binding for xmlns.
|
62
|
+
symb = (SymbMap) initialMap.clone();
|
63
|
+
}
|
64
|
+
|
65
|
+
/**
|
66
|
+
* Get all the unrendered nodes in the name space.
|
67
|
+
* For Inclusive rendering
|
68
|
+
* @param result the list where to fill the unrendered xmlns definitions.
|
69
|
+
**/
|
70
|
+
public void
|
71
|
+
getUnrenderedNodes(Collection<Attr> result)
|
72
|
+
{
|
73
|
+
Iterator<NameSpaceSymbEntry> it = symb.entrySet().iterator();
|
74
|
+
while (it.hasNext()) {
|
75
|
+
NameSpaceSymbEntry n = it.next();
|
76
|
+
//put them rendered?
|
77
|
+
if ((!n.rendered) && (n.n != null)) {
|
78
|
+
n = (NameSpaceSymbEntry) n.clone();
|
79
|
+
needsClone();
|
80
|
+
symb.put(n.prefix, n);
|
81
|
+
n.lastrendered = n.uri;
|
82
|
+
n.rendered = true;
|
60
83
|
|
61
|
-
|
62
|
-
|
63
|
-
* For Inclusive rendering
|
64
|
-
* @param result the list where to fill the unrendered xmlns definitions.
|
65
|
-
**/
|
66
|
-
public void getUnrenderedNodes(Collection<Attr> result) {
|
67
|
-
Iterator<NameSpaceSymbEntry> it = symb.entrySet().iterator();
|
68
|
-
while (it.hasNext()) {
|
69
|
-
NameSpaceSymbEntry n = it.next();
|
70
|
-
//put them rendered?
|
71
|
-
if ((!n.rendered) && (n.n != null)) {
|
72
|
-
n = (NameSpaceSymbEntry) n.clone();
|
73
|
-
needsClone();
|
74
|
-
symb.put(n.prefix, n);
|
75
|
-
n.lastrendered = n.uri;
|
76
|
-
n.rendered = true;
|
77
|
-
|
78
|
-
result.add(n.n);
|
79
|
-
}
|
80
|
-
}
|
84
|
+
result.add(n.n);
|
85
|
+
}
|
81
86
|
}
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
87
|
+
}
|
88
|
+
|
89
|
+
/**
|
90
|
+
* Push a frame for visible namespace.
|
91
|
+
* For Inclusive rendering.
|
92
|
+
**/
|
93
|
+
public void
|
94
|
+
outputNodePush()
|
95
|
+
{
|
96
|
+
push();
|
97
|
+
}
|
98
|
+
|
99
|
+
/**
|
100
|
+
* Pop a frame for visible namespace.
|
101
|
+
**/
|
102
|
+
public void
|
103
|
+
outputNodePop()
|
104
|
+
{
|
105
|
+
pop();
|
106
|
+
}
|
107
|
+
|
108
|
+
/**
|
109
|
+
* Push a frame for a node.
|
110
|
+
* Inclusive or Exclusive.
|
111
|
+
**/
|
112
|
+
public void
|
113
|
+
push()
|
114
|
+
{
|
115
|
+
//Put the number of namespace definitions in the stack.
|
116
|
+
level.add(null);
|
117
|
+
cloned = false;
|
118
|
+
}
|
119
|
+
|
120
|
+
/**
|
121
|
+
* Pop a frame.
|
122
|
+
* Inclusive or Exclusive.
|
123
|
+
**/
|
124
|
+
public void
|
125
|
+
pop()
|
126
|
+
{
|
127
|
+
int size = level.size() - 1;
|
128
|
+
Object ob = level.remove(size);
|
129
|
+
if (ob != null) {
|
130
|
+
symb = (SymbMap)ob;
|
131
|
+
if (size == 0) {
|
132
|
+
cloned = false;
|
133
|
+
} else {
|
134
|
+
cloned = (level.get(size - 1) != symb);
|
135
|
+
}
|
136
|
+
} else {
|
137
|
+
cloned = false;
|
89
138
|
}
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
139
|
+
}
|
140
|
+
|
141
|
+
final void
|
142
|
+
needsClone()
|
143
|
+
{
|
144
|
+
if (!cloned) {
|
145
|
+
level.set(level.size() - 1, symb);
|
146
|
+
symb = (SymbMap) symb.clone();
|
147
|
+
cloned = true;
|
96
148
|
}
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
149
|
+
}
|
150
|
+
|
151
|
+
|
152
|
+
/**
|
153
|
+
* Gets the attribute node that defines the binding for the prefix.
|
154
|
+
* @param prefix the prefix to obtain the attribute.
|
155
|
+
* @return null if there is no need to render the prefix. Otherwise the node of
|
156
|
+
* definition.
|
157
|
+
**/
|
158
|
+
public Attr
|
159
|
+
getMapping(String prefix)
|
160
|
+
{
|
161
|
+
NameSpaceSymbEntry entry = symb.get(prefix);
|
162
|
+
if (entry == null) {
|
163
|
+
//There is no definition for the prefix(a bug?).
|
164
|
+
return null;
|
106
165
|
}
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
* Inclusive or Exclusive.
|
111
|
-
**/
|
112
|
-
public void pop() {
|
113
|
-
int size = level.size() - 1;
|
114
|
-
Object ob = level.remove(size);
|
115
|
-
if (ob != null) {
|
116
|
-
symb = (SymbMap)ob;
|
117
|
-
if (size == 0) {
|
118
|
-
cloned = false;
|
119
|
-
} else {
|
120
|
-
cloned = (level.get(size - 1) != symb);
|
121
|
-
}
|
122
|
-
} else {
|
123
|
-
cloned = false;
|
124
|
-
}
|
166
|
+
if (entry.rendered) {
|
167
|
+
//No need to render an entry already rendered.
|
168
|
+
return null;
|
125
169
|
}
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
170
|
+
// Mark this entry as render.
|
171
|
+
entry = (NameSpaceSymbEntry) entry.clone();
|
172
|
+
needsClone();
|
173
|
+
symb.put(prefix, entry);
|
174
|
+
entry.rendered = true;
|
175
|
+
entry.lastrendered = entry.uri;
|
176
|
+
// Return the node for outputing.
|
177
|
+
return entry.n;
|
178
|
+
}
|
179
|
+
|
180
|
+
/**
|
181
|
+
* Gets a definition without mark it as render.
|
182
|
+
* For render in exclusive c14n the namespaces in the include prefixes.
|
183
|
+
* @param prefix The prefix whose definition is neaded.
|
184
|
+
* @return the attr to render, null if there is no need to render
|
185
|
+
**/
|
186
|
+
public Attr
|
187
|
+
getMappingWithoutRendered(String prefix)
|
188
|
+
{
|
189
|
+
NameSpaceSymbEntry entry = symb.get(prefix);
|
190
|
+
if (entry == null) {
|
191
|
+
return null;
|
133
192
|
}
|
134
|
-
|
135
|
-
|
136
|
-
/**
|
137
|
-
* Gets the attribute node that defines the binding for the prefix.
|
138
|
-
* @param prefix the prefix to obtain the attribute.
|
139
|
-
* @return null if there is no need to render the prefix. Otherwise the node of
|
140
|
-
* definition.
|
141
|
-
**/
|
142
|
-
public Attr getMapping(String prefix) {
|
143
|
-
NameSpaceSymbEntry entry = symb.get(prefix);
|
144
|
-
if (entry == null) {
|
145
|
-
//There is no definition for the prefix(a bug?).
|
146
|
-
return null;
|
147
|
-
}
|
148
|
-
if (entry.rendered) {
|
149
|
-
//No need to render an entry already rendered.
|
150
|
-
return null;
|
151
|
-
}
|
152
|
-
// Mark this entry as render.
|
153
|
-
entry = (NameSpaceSymbEntry) entry.clone();
|
154
|
-
needsClone();
|
155
|
-
symb.put(prefix, entry);
|
156
|
-
entry.rendered = true;
|
157
|
-
entry.lastrendered = entry.uri;
|
158
|
-
// Return the node for outputing.
|
159
|
-
return entry.n;
|
193
|
+
if (entry.rendered) {
|
194
|
+
return null;
|
160
195
|
}
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
196
|
+
return entry.n;
|
197
|
+
}
|
198
|
+
|
199
|
+
/**
|
200
|
+
* Adds the mapping for a prefix.
|
201
|
+
* @param prefix the prefix of definition
|
202
|
+
* @param uri the Uri of the definition
|
203
|
+
* @param n the attribute that have the definition
|
204
|
+
* @return true if there is already defined.
|
205
|
+
**/
|
206
|
+
public boolean
|
207
|
+
addMapping(String prefix, String uri, Attr n)
|
208
|
+
{
|
209
|
+
NameSpaceSymbEntry ob = symb.get(prefix);
|
210
|
+
if ((ob != null) && uri.equals(ob.uri)) {
|
211
|
+
//If we have it previously defined. Don't keep working.
|
212
|
+
return false;
|
177
213
|
}
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
return false;
|
191
|
-
}
|
192
|
-
//Creates and entry in the table for this new definition.
|
193
|
-
NameSpaceSymbEntry ne = new NameSpaceSymbEntry(uri, n, false, prefix);
|
194
|
-
needsClone();
|
195
|
-
symb.put(prefix, ne);
|
196
|
-
if (ob != null) {
|
197
|
-
//We have a previous definition store it for the pop.
|
198
|
-
//Check if a previous definition(not the inmidiatly one) has been rendered.
|
199
|
-
ne.lastrendered = ob.lastrendered;
|
200
|
-
if ((ob.lastrendered != null) && (ob.lastrendered.equals(uri))) {
|
201
|
-
//Yes it is. Mark as rendered.
|
202
|
-
ne.rendered = true;
|
203
|
-
}
|
204
|
-
}
|
205
|
-
return true;
|
214
|
+
//Creates and entry in the table for this new definition.
|
215
|
+
NameSpaceSymbEntry ne = new NameSpaceSymbEntry(uri, n, false, prefix);
|
216
|
+
needsClone();
|
217
|
+
symb.put(prefix, ne);
|
218
|
+
if (ob != null) {
|
219
|
+
//We have a previous definition store it for the pop.
|
220
|
+
//Check if a previous definition(not the inmidiatly one) has been rendered.
|
221
|
+
ne.lastrendered = ob.lastrendered;
|
222
|
+
if ((ob.lastrendered != null) && (ob.lastrendered.equals(uri))) {
|
223
|
+
//Yes it is. Mark as rendered.
|
224
|
+
ne.rendered = true;
|
225
|
+
}
|
206
226
|
}
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
return ob.n;
|
227
|
-
}
|
228
|
-
return null;
|
229
|
-
}
|
230
|
-
|
231
|
-
NameSpaceSymbEntry ne = new NameSpaceSymbEntry(uri,n,true,prefix);
|
232
|
-
ne.lastrendered = uri;
|
227
|
+
return true;
|
228
|
+
}
|
229
|
+
|
230
|
+
/**
|
231
|
+
* Adds a definition and mark it as render.
|
232
|
+
* For inclusive c14n.
|
233
|
+
* @param prefix the prefix of definition
|
234
|
+
* @param uri the Uri of the definition
|
235
|
+
* @param n the attribute that have the definition
|
236
|
+
* @return the attr to render, null if there is no need to render
|
237
|
+
**/
|
238
|
+
public Node
|
239
|
+
addMappingAndRender(String prefix, String uri, Attr n)
|
240
|
+
{
|
241
|
+
NameSpaceSymbEntry ob = symb.get(prefix);
|
242
|
+
|
243
|
+
if ((ob != null) && uri.equals(ob.uri)) {
|
244
|
+
if (!ob.rendered) {
|
245
|
+
ob = (NameSpaceSymbEntry) ob.clone();
|
233
246
|
needsClone();
|
234
|
-
symb.put(prefix,
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
247
|
+
symb.put(prefix, ob);
|
248
|
+
ob.lastrendered = uri;
|
249
|
+
ob.rendered = true;
|
250
|
+
return ob.n;
|
251
|
+
}
|
252
|
+
return null;
|
240
253
|
}
|
241
254
|
|
242
|
-
|
243
|
-
|
255
|
+
NameSpaceSymbEntry ne = new NameSpaceSymbEntry(uri, n, true, prefix);
|
256
|
+
ne.lastrendered = uri;
|
257
|
+
needsClone();
|
258
|
+
symb.put(prefix, ne);
|
259
|
+
if ((ob != null) && (ob.lastrendered != null) && (ob.lastrendered.equals(uri))) {
|
260
|
+
ne.rendered = true;
|
261
|
+
return null;
|
244
262
|
}
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
263
|
+
return ne.n;
|
264
|
+
}
|
265
|
+
|
266
|
+
public int
|
267
|
+
getLevel()
|
268
|
+
{
|
269
|
+
return level.size();
|
270
|
+
}
|
271
|
+
|
272
|
+
public void
|
273
|
+
removeMapping(String prefix)
|
274
|
+
{
|
275
|
+
NameSpaceSymbEntry ob = symb.get(prefix);
|
276
|
+
|
277
|
+
if (ob != null) {
|
278
|
+
needsClone();
|
279
|
+
symb.put(prefix, null);
|
253
280
|
}
|
281
|
+
}
|
254
282
|
|
255
|
-
|
256
|
-
|
283
|
+
public void
|
284
|
+
removeMappingIfNotRender(String prefix)
|
285
|
+
{
|
286
|
+
NameSpaceSymbEntry ob = symb.get(prefix);
|
257
287
|
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
}
|
288
|
+
if (ob != null && !ob.rendered) {
|
289
|
+
needsClone();
|
290
|
+
symb.put(prefix, null);
|
262
291
|
}
|
292
|
+
}
|
263
293
|
|
264
|
-
|
265
|
-
|
294
|
+
public boolean
|
295
|
+
removeMappingIfRender(String prefix)
|
296
|
+
{
|
297
|
+
NameSpaceSymbEntry ob = symb.get(prefix);
|
266
298
|
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
}
|
271
|
-
return false;
|
299
|
+
if (ob != null && ob.rendered) {
|
300
|
+
needsClone();
|
301
|
+
symb.put(prefix, null);
|
272
302
|
}
|
303
|
+
return false;
|
304
|
+
}
|
273
305
|
}
|
274
306
|
|
275
307
|
/**
|
276
308
|
* The internal structure of NameSpaceSymbTable.
|
277
309
|
**/
|
278
|
-
class NameSpaceSymbEntry implements Cloneable
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
310
|
+
class NameSpaceSymbEntry implements Cloneable
|
311
|
+
{
|
312
|
+
|
313
|
+
String prefix;
|
314
|
+
|
315
|
+
/**The URI that the prefix defines */
|
316
|
+
String uri;
|
317
|
+
|
318
|
+
/**The last output in the URI for this prefix (This for speed reason).*/
|
319
|
+
String lastrendered = null;
|
320
|
+
|
321
|
+
/**This prefix-URI has been already render or not.*/
|
322
|
+
boolean rendered = false;
|
323
|
+
|
324
|
+
/**The attribute to include.*/
|
325
|
+
Attr n;
|
326
|
+
|
327
|
+
NameSpaceSymbEntry(String name, Attr n, boolean rendered, String prefix)
|
328
|
+
{
|
329
|
+
this.uri = name;
|
330
|
+
this.rendered = rendered;
|
331
|
+
this.n = n;
|
332
|
+
this.prefix = prefix;
|
333
|
+
}
|
334
|
+
|
335
|
+
/** @inheritDoc */
|
336
|
+
public Object
|
337
|
+
clone()
|
338
|
+
{
|
339
|
+
try {
|
340
|
+
return super.clone();
|
341
|
+
} catch (CloneNotSupportedException e) {
|
342
|
+
return null;
|
308
343
|
}
|
344
|
+
}
|
309
345
|
}
|
310
346
|
|
311
|
-
class SymbMap implements Cloneable
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
347
|
+
class SymbMap implements Cloneable
|
348
|
+
{
|
349
|
+
int free = 23;
|
350
|
+
NameSpaceSymbEntry[] entries;
|
351
|
+
String[] keys;
|
352
|
+
|
353
|
+
SymbMap()
|
354
|
+
{
|
355
|
+
entries = new NameSpaceSymbEntry[free];
|
356
|
+
keys = new String[free];
|
357
|
+
}
|
358
|
+
|
359
|
+
void
|
360
|
+
put(String key, NameSpaceSymbEntry value)
|
361
|
+
{
|
362
|
+
int index = index(key);
|
363
|
+
Object oldKey = keys[index];
|
364
|
+
keys[index] = key;
|
365
|
+
entries[index] = value;
|
366
|
+
if ((oldKey == null || !oldKey.equals(key)) && (--free == 0)) {
|
367
|
+
free = entries.length;
|
368
|
+
int newCapacity = free << 2;
|
369
|
+
rehash(newCapacity);
|
319
370
|
}
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
}
|
371
|
+
}
|
372
|
+
|
373
|
+
List<NameSpaceSymbEntry>
|
374
|
+
entrySet()
|
375
|
+
{
|
376
|
+
List<NameSpaceSymbEntry> a = new ArrayList<NameSpaceSymbEntry>();
|
377
|
+
for (int i = 0; i < entries.length; i++) {
|
378
|
+
if ((entries[i] != null) && !("".equals(entries[i].uri))) {
|
379
|
+
a.add(entries[i]);
|
380
|
+
}
|
331
381
|
}
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
382
|
+
return a;
|
383
|
+
}
|
384
|
+
|
385
|
+
protected int
|
386
|
+
index(Object obj)
|
387
|
+
{
|
388
|
+
Object[] set = keys;
|
389
|
+
int length = set.length;
|
390
|
+
//abs of index
|
391
|
+
int index = (obj.hashCode() & 0x7fffffff) % length;
|
392
|
+
Object cur = set[index];
|
393
|
+
|
394
|
+
if (cur == null || (cur.equals(obj))) {
|
395
|
+
return index;
|
341
396
|
}
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
entries = new NameSpaceSymbEntry[newCapacity];
|
373
|
-
|
374
|
-
for (int i = oldCapacity; i-- > 0;) {
|
375
|
-
if (oldKeys[i] != null) {
|
376
|
-
String o = oldKeys[i];
|
377
|
-
int index = index(o);
|
378
|
-
keys[index] = o;
|
379
|
-
entries[index] = oldVals[i];
|
380
|
-
}
|
381
|
-
}
|
397
|
+
length--;
|
398
|
+
do {
|
399
|
+
index = index == length ? 0 : ++index;
|
400
|
+
cur = set[index];
|
401
|
+
} while (cur != null && (!cur.equals(obj)));
|
402
|
+
return index;
|
403
|
+
}
|
404
|
+
|
405
|
+
/**
|
406
|
+
* rehashes the map to the new capacity.
|
407
|
+
*
|
408
|
+
* @param newCapacity an <code>int</code> value
|
409
|
+
*/
|
410
|
+
protected void
|
411
|
+
rehash(int newCapacity)
|
412
|
+
{
|
413
|
+
int oldCapacity = keys.length;
|
414
|
+
String oldKeys[] = keys;
|
415
|
+
NameSpaceSymbEntry oldVals[] = entries;
|
416
|
+
|
417
|
+
keys = new String[newCapacity];
|
418
|
+
entries = new NameSpaceSymbEntry[newCapacity];
|
419
|
+
|
420
|
+
for (int i = oldCapacity; i-- > 0;) {
|
421
|
+
if (oldKeys[i] != null) {
|
422
|
+
String o = oldKeys[i];
|
423
|
+
int index = index(o);
|
424
|
+
keys[index] = o;
|
425
|
+
entries[index] = oldVals[i];
|
426
|
+
}
|
382
427
|
}
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
428
|
+
}
|
429
|
+
|
430
|
+
NameSpaceSymbEntry
|
431
|
+
get(String key)
|
432
|
+
{
|
433
|
+
return entries[index(key)];
|
434
|
+
}
|
435
|
+
|
436
|
+
protected Object
|
437
|
+
clone()
|
438
|
+
{
|
439
|
+
try {
|
440
|
+
SymbMap copy = (SymbMap) super.clone();
|
441
|
+
copy.entries = new NameSpaceSymbEntry[entries.length];
|
442
|
+
System.arraycopy(entries, 0, copy.entries, 0, entries.length);
|
443
|
+
copy.keys = new String[keys.length];
|
444
|
+
System.arraycopy(keys, 0, copy.keys, 0, keys.length);
|
445
|
+
|
446
|
+
return copy;
|
447
|
+
} catch (CloneNotSupportedException e) {
|
448
|
+
e.printStackTrace();
|
401
449
|
}
|
450
|
+
return null;
|
451
|
+
}
|
402
452
|
}
|