nokogiri 1.5.0.beta.4 → 1.5.0
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.
- data/.gemtest +0 -0
- data/CHANGELOG.ja.rdoc +34 -0
- data/CHANGELOG.rdoc +40 -1
- data/Manifest.txt +11 -2
- data/README.rdoc +1 -1
- data/Rakefile +100 -104
- data/bin/nokogiri +1 -2
- data/ext/nokogiri/nokogiri.c +24 -1
- data/ext/nokogiri/xml_io.c +32 -7
- data/ext/nokogiri/xml_node.c +14 -13
- data/ext/nokogiri/xml_sax_parser.c +9 -4
- data/ext/nokogiri/xslt_stylesheet.c +7 -1
- data/lib/nokogiri.rb +3 -22
- data/lib/nokogiri/css.rb +4 -0
- data/lib/nokogiri/html/document.rb +10 -14
- data/lib/nokogiri/version.rb +76 -23
- data/lib/nokogiri/xml/builder.rb +7 -0
- data/lib/nokogiri/xml/document.rb +17 -1
- data/lib/nokogiri/xml/document_fragment.rb +14 -0
- data/lib/nokogiri/xml/node.rb +36 -28
- data/lib/nokogiri/xml/node/save_options.rb +17 -1
- data/lib/nokogiri/xml/node_set.rb +7 -0
- data/lib/nokogiri/xml/parse_options.rb +8 -0
- data/lib/nokogiri/xml/reader.rb +6 -6
- data/lib/nokogiri/xml/schema.rb +7 -1
- data/nokogiri_help_responses.md +40 -0
- data/tasks/cross_compile.rb +134 -159
- data/tasks/nokogiri.org.rb +18 -0
- data/tasks/test.rb +1 -1
- data/test/files/encoding.html +82 -0
- data/test/files/encoding.xhtml +84 -0
- data/test/files/metacharset.html +10 -0
- data/test/files/noencoding.html +47 -0
- data/test/helper.rb +2 -0
- data/test/html/test_document.rb +15 -0
- data/test/html/test_document_encoding.rb +13 -0
- data/test/test_memory_leak.rb +20 -0
- data/test/test_reader.rb +22 -0
- data/test/test_xslt_transforms.rb +6 -2
- data/test/xml/node/test_save_options.rb +10 -2
- data/test/xml/test_builder.rb +17 -0
- data/test/xml/test_document.rb +22 -0
- data/test/xml/test_node.rb +19 -1
- data/test/xml/test_node_reparenting.rb +16 -3
- data/test/xml/test_node_set.rb +34 -0
- data/test/xml/test_schema.rb +5 -0
- data/test/xslt/test_exception_handling.rb +37 -0
- metadata +185 -157
- data/deps.rip +0 -5
- data/ext/java/nokogiri/EncodingHandler.java +0 -124
- data/ext/java/nokogiri/HtmlDocument.java +0 -149
- data/ext/java/nokogiri/HtmlElementDescription.java +0 -145
- data/ext/java/nokogiri/HtmlEntityLookup.java +0 -79
- data/ext/java/nokogiri/HtmlSaxParserContext.java +0 -259
- data/ext/java/nokogiri/NokogiriService.java +0 -535
- data/ext/java/nokogiri/XmlAttr.java +0 -191
- data/ext/java/nokogiri/XmlAttributeDecl.java +0 -130
- data/ext/java/nokogiri/XmlCdata.java +0 -91
- data/ext/java/nokogiri/XmlComment.java +0 -86
- data/ext/java/nokogiri/XmlDocument.java +0 -529
- data/ext/java/nokogiri/XmlDocumentFragment.java +0 -217
- data/ext/java/nokogiri/XmlDtd.java +0 -467
- data/ext/java/nokogiri/XmlElement.java +0 -222
- data/ext/java/nokogiri/XmlElementContent.java +0 -382
- data/ext/java/nokogiri/XmlElementDecl.java +0 -148
- data/ext/java/nokogiri/XmlEntityDecl.java +0 -162
- data/ext/java/nokogiri/XmlEntityReference.java +0 -75
- data/ext/java/nokogiri/XmlNamespace.java +0 -128
- data/ext/java/nokogiri/XmlNode.java +0 -1399
- data/ext/java/nokogiri/XmlNodeSet.java +0 -311
- data/ext/java/nokogiri/XmlProcessingInstruction.java +0 -103
- data/ext/java/nokogiri/XmlReader.java +0 -411
- data/ext/java/nokogiri/XmlRelaxng.java +0 -144
- data/ext/java/nokogiri/XmlSaxParserContext.java +0 -367
- data/ext/java/nokogiri/XmlSaxPushParser.java +0 -184
- data/ext/java/nokogiri/XmlSchema.java +0 -319
- data/ext/java/nokogiri/XmlSyntaxError.java +0 -119
- data/ext/java/nokogiri/XmlText.java +0 -136
- data/ext/java/nokogiri/XmlXpathContext.java +0 -179
- data/ext/java/nokogiri/XsltStylesheet.java +0 -183
- data/ext/java/nokogiri/internals/HtmlDomParserContext.java +0 -206
- data/ext/java/nokogiri/internals/NokogiriDocumentCache.java +0 -73
- data/ext/java/nokogiri/internals/NokogiriErrorHandler.java +0 -86
- data/ext/java/nokogiri/internals/NokogiriHandler.java +0 -327
- data/ext/java/nokogiri/internals/NokogiriHelpers.java +0 -582
- data/ext/java/nokogiri/internals/NokogiriNamespaceCache.java +0 -171
- data/ext/java/nokogiri/internals/NokogiriNamespaceContext.java +0 -118
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java +0 -74
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java +0 -121
- data/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java +0 -79
- data/ext/java/nokogiri/internals/NokogiriXPathFunction.java +0 -126
- data/ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java +0 -56
- data/ext/java/nokogiri/internals/ParserContext.java +0 -278
- data/ext/java/nokogiri/internals/PushInputStream.java +0 -411
- data/ext/java/nokogiri/internals/ReaderNode.java +0 -474
- data/ext/java/nokogiri/internals/SaveContext.java +0 -288
- data/ext/java/nokogiri/internals/SchemaErrorHandler.java +0 -76
- data/ext/java/nokogiri/internals/XmlDeclHandler.java +0 -42
- data/ext/java/nokogiri/internals/XmlDomParser.java +0 -77
- data/ext/java/nokogiri/internals/XmlDomParserContext.java +0 -238
- data/ext/java/nokogiri/internals/XmlSaxParser.java +0 -65
- data/ext/java/nokogiri/internals/XsltExtensionFunction.java +0 -72
- data/lib/isorelax.jar +0 -0
- data/lib/jing.jar +0 -0
- data/lib/nekodtd.jar +0 -0
- data/lib/nekohtml.jar +0 -0
- data/lib/xercesImpl.jar +0 -0
@@ -1,148 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* (The MIT License)
|
3
|
-
*
|
4
|
-
* Copyright (c) 2008 - 2011:
|
5
|
-
*
|
6
|
-
* * {Aaron Patterson}[http://tenderlovemaking.com]
|
7
|
-
* * {Mike Dalessio}[http://mike.daless.io]
|
8
|
-
* * {Charles Nutter}[http://blog.headius.com]
|
9
|
-
* * {Sergio Arbeo}[http://www.serabe.com]
|
10
|
-
* * {Patrick Mahoney}[http://polycrystal.org]
|
11
|
-
* * {Yoko Harada}[http://yokolet.blogspot.com]
|
12
|
-
*
|
13
|
-
* Permission is hereby granted, free of charge, to any person obtaining
|
14
|
-
* a copy of this software and associated documentation files (the
|
15
|
-
* 'Software'), to deal in the Software without restriction, including
|
16
|
-
* without limitation the rights to use, copy, modify, merge, publish,
|
17
|
-
* distribute, sublicense, and/or sell copies of the Software, and to
|
18
|
-
* permit persons to whom the Software is furnished to do so, subject to
|
19
|
-
* the following conditions:
|
20
|
-
*
|
21
|
-
* The above copyright notice and this permission notice shall be
|
22
|
-
* included in all copies or substantial portions of the Software.
|
23
|
-
*
|
24
|
-
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
25
|
-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
26
|
-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
27
|
-
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
28
|
-
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
29
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
30
|
-
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
31
|
-
*/
|
32
|
-
|
33
|
-
package nokogiri;
|
34
|
-
|
35
|
-
import static nokogiri.internals.NokogiriHelpers.getLocalPart;
|
36
|
-
import static nokogiri.internals.NokogiriHelpers.getNokogiriClass;
|
37
|
-
import static nokogiri.internals.NokogiriHelpers.getPrefix;
|
38
|
-
|
39
|
-
import org.jruby.Ruby;
|
40
|
-
import org.jruby.RubyArray;
|
41
|
-
import org.jruby.RubyClass;
|
42
|
-
import org.jruby.anno.JRubyClass;
|
43
|
-
import org.jruby.anno.JRubyMethod;
|
44
|
-
import org.jruby.runtime.ThreadContext;
|
45
|
-
import org.jruby.runtime.builtin.IRubyObject;
|
46
|
-
import org.w3c.dom.Node;
|
47
|
-
|
48
|
-
/**
|
49
|
-
* DTD element declaration.
|
50
|
-
*
|
51
|
-
* @author Patrick Mahoney <pat@polycrystal.org>
|
52
|
-
* @author Yoko Harada <yokolet@gmail.com>
|
53
|
-
*/
|
54
|
-
@JRubyClass(name="Nokogiri::XML::ElementDecl", parent="Nokogiri::XML::Node")
|
55
|
-
public class XmlElementDecl extends XmlNode {
|
56
|
-
RubyArray attrDecls;
|
57
|
-
|
58
|
-
IRubyObject contentModel;
|
59
|
-
|
60
|
-
public XmlElementDecl(Ruby ruby, RubyClass klass) {
|
61
|
-
super(ruby, klass);
|
62
|
-
throw ruby.newRuntimeError("node required");
|
63
|
-
}
|
64
|
-
|
65
|
-
/**
|
66
|
-
* Initialize based on an elementDecl node from a NekoDTD parsed
|
67
|
-
* DTD.
|
68
|
-
*/
|
69
|
-
public XmlElementDecl(Ruby ruby, RubyClass klass, Node elemDeclNode) {
|
70
|
-
super(ruby, klass, elemDeclNode);
|
71
|
-
attrDecls = RubyArray.newArray(ruby);
|
72
|
-
contentModel = ruby.getNil();
|
73
|
-
}
|
74
|
-
|
75
|
-
public static IRubyObject create(ThreadContext context, Node elemDeclNode) {
|
76
|
-
XmlElementDecl self =
|
77
|
-
new XmlElementDecl(context.getRuntime(),
|
78
|
-
getNokogiriClass(context.getRuntime(), "Nokogiri::XML::ElementDecl"),
|
79
|
-
elemDeclNode);
|
80
|
-
return self;
|
81
|
-
}
|
82
|
-
|
83
|
-
public IRubyObject element_name(ThreadContext context) {
|
84
|
-
return getAttribute(context, "ename");
|
85
|
-
}
|
86
|
-
|
87
|
-
public void setContentModel(IRubyObject cm) {
|
88
|
-
contentModel = cm;
|
89
|
-
}
|
90
|
-
|
91
|
-
@Override
|
92
|
-
@JRubyMethod
|
93
|
-
public IRubyObject content(ThreadContext context) {
|
94
|
-
return contentModel;
|
95
|
-
}
|
96
|
-
|
97
|
-
public boolean isEmpty() {
|
98
|
-
return "EMPTY".equals(getAttribute("model"));
|
99
|
-
}
|
100
|
-
|
101
|
-
@JRubyMethod
|
102
|
-
public IRubyObject prefix(ThreadContext context) {
|
103
|
-
String enamePrefix = getPrefix(getAttribute("ename"));
|
104
|
-
if (enamePrefix == null)
|
105
|
-
return context.getRuntime().getNil();
|
106
|
-
else
|
107
|
-
return context.getRuntime().newString(enamePrefix);
|
108
|
-
}
|
109
|
-
|
110
|
-
/**
|
111
|
-
* Returns the local part of the element name.
|
112
|
-
*/
|
113
|
-
@Override
|
114
|
-
@JRubyMethod
|
115
|
-
public IRubyObject node_name(ThreadContext context) {
|
116
|
-
String ename = getLocalPart(getAttribute("ename"));
|
117
|
-
return context.getRuntime().newString(ename);
|
118
|
-
}
|
119
|
-
|
120
|
-
@Override
|
121
|
-
@JRubyMethod(name = "node_name=")
|
122
|
-
public IRubyObject node_name_set(ThreadContext context, IRubyObject name) {
|
123
|
-
throw context.getRuntime()
|
124
|
-
.newRuntimeError("cannot change name of DTD decl");
|
125
|
-
}
|
126
|
-
|
127
|
-
@Override
|
128
|
-
@JRubyMethod
|
129
|
-
public IRubyObject attribute_nodes(ThreadContext context) {
|
130
|
-
return attrDecls;
|
131
|
-
}
|
132
|
-
|
133
|
-
@Override
|
134
|
-
@JRubyMethod
|
135
|
-
public IRubyObject attribute(ThreadContext context, IRubyObject name) {
|
136
|
-
throw context.getRuntime()
|
137
|
-
.newRuntimeError("attribute by name not implemented");
|
138
|
-
}
|
139
|
-
|
140
|
-
public void appendAttrDecl(XmlAttributeDecl decl) {
|
141
|
-
attrDecls.append(decl);
|
142
|
-
}
|
143
|
-
|
144
|
-
@JRubyMethod
|
145
|
-
public IRubyObject element_type(ThreadContext context) {
|
146
|
-
return context.getRuntime().newFixnum(node.getNodeType());
|
147
|
-
}
|
148
|
-
}
|
@@ -1,162 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* (The MIT License)
|
3
|
-
*
|
4
|
-
* Copyright (c) 2008 - 2011:
|
5
|
-
*
|
6
|
-
* * {Aaron Patterson}[http://tenderlovemaking.com]
|
7
|
-
* * {Mike Dalessio}[http://mike.daless.io]
|
8
|
-
* * {Charles Nutter}[http://blog.headius.com]
|
9
|
-
* * {Sergio Arbeo}[http://www.serabe.com]
|
10
|
-
* * {Patrick Mahoney}[http://polycrystal.org]
|
11
|
-
* * {Yoko Harada}[http://yokolet.blogspot.com]
|
12
|
-
*
|
13
|
-
* Permission is hereby granted, free of charge, to any person obtaining
|
14
|
-
* a copy of this software and associated documentation files (the
|
15
|
-
* 'Software'), to deal in the Software without restriction, including
|
16
|
-
* without limitation the rights to use, copy, modify, merge, publish,
|
17
|
-
* distribute, sublicense, and/or sell copies of the Software, and to
|
18
|
-
* permit persons to whom the Software is furnished to do so, subject to
|
19
|
-
* the following conditions:
|
20
|
-
*
|
21
|
-
* The above copyright notice and this permission notice shall be
|
22
|
-
* included in all copies or substantial portions of the Software.
|
23
|
-
*
|
24
|
-
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
25
|
-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
26
|
-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
27
|
-
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
28
|
-
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
29
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
30
|
-
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
31
|
-
*/
|
32
|
-
|
33
|
-
package nokogiri;
|
34
|
-
|
35
|
-
import static nokogiri.internals.NokogiriHelpers.getNokogiriClass;
|
36
|
-
|
37
|
-
import org.jruby.Ruby;
|
38
|
-
import org.jruby.RubyClass;
|
39
|
-
import org.jruby.RubyFixnum;
|
40
|
-
import org.jruby.RubyNil;
|
41
|
-
import org.jruby.anno.JRubyClass;
|
42
|
-
import org.jruby.anno.JRubyMethod;
|
43
|
-
import org.jruby.runtime.ThreadContext;
|
44
|
-
import org.jruby.runtime.builtin.IRubyObject;
|
45
|
-
import org.w3c.dom.Node;
|
46
|
-
|
47
|
-
/**
|
48
|
-
* DTD entity declaration.
|
49
|
-
*
|
50
|
-
* @author Patrick Mahoney <pat@polycrystal.org>
|
51
|
-
* @author Yoko Harada <yokolet@gmail.com>
|
52
|
-
*/
|
53
|
-
@JRubyClass(name="Nokogiri::XML::EntityDecl", parent="Nokogiri::XML::Node")
|
54
|
-
public class XmlEntityDecl extends XmlNode {
|
55
|
-
public static final int INTERNAL_GENERAL = 1;
|
56
|
-
public static final int EXTERNAL_GENERAL_PARSED = 2;
|
57
|
-
public static final int EXTERNAL_GENERAL_UNPARSED = 3;
|
58
|
-
public static final int INTERNAL_PARAMETER = 4;
|
59
|
-
public static final int EXTERNAL_PARAMETER = 5;
|
60
|
-
public static final int INTERNAL_PREDEFINED = 6;
|
61
|
-
|
62
|
-
private IRubyObject entityType;
|
63
|
-
private IRubyObject name;
|
64
|
-
private IRubyObject external_id;
|
65
|
-
private IRubyObject system_id;
|
66
|
-
private IRubyObject content;
|
67
|
-
|
68
|
-
public XmlEntityDecl(Ruby ruby, RubyClass klass) {
|
69
|
-
super(ruby, klass);
|
70
|
-
throw ruby.newRuntimeError("node required");
|
71
|
-
}
|
72
|
-
|
73
|
-
/**
|
74
|
-
* Initialize based on an entityDecl node from a NekoDTD parsed
|
75
|
-
* DTD.
|
76
|
-
*/
|
77
|
-
public XmlEntityDecl(Ruby ruby, RubyClass klass, Node entDeclNode) {
|
78
|
-
super(ruby, klass, entDeclNode);
|
79
|
-
entityType = RubyFixnum.newFixnum(ruby, XmlEntityDecl.INTERNAL_GENERAL);
|
80
|
-
name = external_id = system_id = content = ruby.getNil();
|
81
|
-
}
|
82
|
-
|
83
|
-
public XmlEntityDecl(Ruby ruby, RubyClass klass, Node entDeclNode, IRubyObject[] argv) {
|
84
|
-
super(ruby, klass, entDeclNode);
|
85
|
-
name = argv[0];
|
86
|
-
entityType = RubyFixnum.newFixnum(ruby, XmlEntityDecl.INTERNAL_GENERAL);
|
87
|
-
external_id = system_id = content = ruby.getNil();
|
88
|
-
if (argv.length > 1) entityType = argv[1];
|
89
|
-
if (argv.length > 4) {
|
90
|
-
external_id = argv[2];
|
91
|
-
system_id = argv[3];
|
92
|
-
content = argv[4];
|
93
|
-
}
|
94
|
-
}
|
95
|
-
|
96
|
-
public static IRubyObject create(ThreadContext context, Node entDeclNode) {
|
97
|
-
XmlEntityDecl self =
|
98
|
-
new XmlEntityDecl(context.getRuntime(),
|
99
|
-
getNokogiriClass(context.getRuntime(), "Nokogiri::XML::EntityDecl"),
|
100
|
-
entDeclNode);
|
101
|
-
return self;
|
102
|
-
}
|
103
|
-
|
104
|
-
// when entity is created by create_entity method
|
105
|
-
public static IRubyObject create(ThreadContext context, Node entDeclNode, IRubyObject[] argv) {
|
106
|
-
XmlEntityDecl self =
|
107
|
-
new XmlEntityDecl(context.getRuntime(),
|
108
|
-
getNokogiriClass(context.getRuntime(), "Nokogiri::XML::EntityDecl"),
|
109
|
-
entDeclNode, argv);
|
110
|
-
return self;
|
111
|
-
}
|
112
|
-
|
113
|
-
/**
|
114
|
-
* Returns the local part of the element name.
|
115
|
-
*/
|
116
|
-
@Override
|
117
|
-
@JRubyMethod
|
118
|
-
public IRubyObject node_name(ThreadContext context) {
|
119
|
-
IRubyObject value = getAttribute(context, "name");
|
120
|
-
if (value instanceof RubyNil) value = name;
|
121
|
-
return value;
|
122
|
-
}
|
123
|
-
|
124
|
-
@Override
|
125
|
-
@JRubyMethod(name = "node_name=")
|
126
|
-
public IRubyObject node_name_set(ThreadContext context, IRubyObject name) {
|
127
|
-
throw context.getRuntime()
|
128
|
-
.newRuntimeError("cannot change name of DTD decl");
|
129
|
-
}
|
130
|
-
|
131
|
-
@JRubyMethod
|
132
|
-
public IRubyObject content(ThreadContext context) {
|
133
|
-
IRubyObject value = getAttribute(context, "value");
|
134
|
-
if (value instanceof RubyNil) value = content;
|
135
|
-
return value;
|
136
|
-
}
|
137
|
-
|
138
|
-
// TODO: what is content vs. original_content?
|
139
|
-
@JRubyMethod
|
140
|
-
public IRubyObject original_content(ThreadContext context) {
|
141
|
-
return getAttribute(context, "value");
|
142
|
-
}
|
143
|
-
|
144
|
-
@JRubyMethod
|
145
|
-
public IRubyObject system_id(ThreadContext context) {
|
146
|
-
IRubyObject value = getAttribute(context, "sysid");
|
147
|
-
if (value instanceof RubyNil) value = system_id;
|
148
|
-
return value;
|
149
|
-
}
|
150
|
-
|
151
|
-
@JRubyMethod
|
152
|
-
public IRubyObject external_id(ThreadContext context) {
|
153
|
-
IRubyObject value = getAttribute(context, "pubid");
|
154
|
-
if (value instanceof RubyNil) value = external_id;
|
155
|
-
return value;
|
156
|
-
}
|
157
|
-
|
158
|
-
@JRubyMethod
|
159
|
-
public IRubyObject entity_type(ThreadContext context) {
|
160
|
-
return entityType;
|
161
|
-
}
|
162
|
-
}
|
@@ -1,75 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* (The MIT License)
|
3
|
-
*
|
4
|
-
* Copyright (c) 2008 - 2011:
|
5
|
-
*
|
6
|
-
* * {Aaron Patterson}[http://tenderlovemaking.com]
|
7
|
-
* * {Mike Dalessio}[http://mike.daless.io]
|
8
|
-
* * {Charles Nutter}[http://blog.headius.com]
|
9
|
-
* * {Sergio Arbeo}[http://www.serabe.com]
|
10
|
-
* * {Patrick Mahoney}[http://polycrystal.org]
|
11
|
-
* * {Yoko Harada}[http://yokolet.blogspot.com]
|
12
|
-
*
|
13
|
-
* Permission is hereby granted, free of charge, to any person obtaining
|
14
|
-
* a copy of this software and associated documentation files (the
|
15
|
-
* 'Software'), to deal in the Software without restriction, including
|
16
|
-
* without limitation the rights to use, copy, modify, merge, publish,
|
17
|
-
* distribute, sublicense, and/or sell copies of the Software, and to
|
18
|
-
* permit persons to whom the Software is furnished to do so, subject to
|
19
|
-
* the following conditions:
|
20
|
-
*
|
21
|
-
* The above copyright notice and this permission notice shall be
|
22
|
-
* included in all copies or substantial portions of the Software.
|
23
|
-
*
|
24
|
-
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
25
|
-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
26
|
-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
27
|
-
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
28
|
-
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
29
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
30
|
-
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
31
|
-
*/
|
32
|
-
|
33
|
-
package nokogiri;
|
34
|
-
|
35
|
-
import static nokogiri.internals.NokogiriHelpers.rubyStringToString;
|
36
|
-
|
37
|
-
import org.jruby.Ruby;
|
38
|
-
import org.jruby.RubyClass;
|
39
|
-
import org.jruby.anno.JRubyClass;
|
40
|
-
import org.jruby.runtime.ThreadContext;
|
41
|
-
import org.jruby.runtime.builtin.IRubyObject;
|
42
|
-
import org.w3c.dom.Document;
|
43
|
-
import org.w3c.dom.Node;
|
44
|
-
|
45
|
-
/**
|
46
|
-
* Class for Nokogiri::XML::EntityReference
|
47
|
-
*
|
48
|
-
* @author sergio
|
49
|
-
* @author Patrick Mahoney <pat@polycrystal.org>
|
50
|
-
*/
|
51
|
-
@JRubyClass(name="Nokogiri::XML::EntityReference", parent="Nokogiri::XML::Node")
|
52
|
-
public class XmlEntityReference extends XmlNode{
|
53
|
-
|
54
|
-
public XmlEntityReference(Ruby ruby, RubyClass klazz) {
|
55
|
-
super(ruby, klazz);
|
56
|
-
}
|
57
|
-
|
58
|
-
public XmlEntityReference(Ruby ruby, RubyClass klass, Node node) {
|
59
|
-
super(ruby, klass, node);
|
60
|
-
}
|
61
|
-
|
62
|
-
protected void init(ThreadContext context, IRubyObject[] args) {
|
63
|
-
if (args.length < 2) {
|
64
|
-
throw getRuntime().newArgumentError(args.length, 2);
|
65
|
-
}
|
66
|
-
|
67
|
-
IRubyObject doc = args[0];
|
68
|
-
IRubyObject name = args[1];
|
69
|
-
|
70
|
-
Document document = ((XmlNode) doc).getOwnerDocument();
|
71
|
-
Node node = document.createEntityReference(rubyStringToString(name));
|
72
|
-
setNode(context, node);
|
73
|
-
}
|
74
|
-
|
75
|
-
}
|
@@ -1,128 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* (The MIT License)
|
3
|
-
*
|
4
|
-
* Copyright (c) 2008 - 2011:
|
5
|
-
*
|
6
|
-
* * {Aaron Patterson}[http://tenderlovemaking.com]
|
7
|
-
* * {Mike Dalessio}[http://mike.daless.io]
|
8
|
-
* * {Charles Nutter}[http://blog.headius.com]
|
9
|
-
* * {Sergio Arbeo}[http://www.serabe.com]
|
10
|
-
* * {Patrick Mahoney}[http://polycrystal.org]
|
11
|
-
* * {Yoko Harada}[http://yokolet.blogspot.com]
|
12
|
-
*
|
13
|
-
* Permission is hereby granted, free of charge, to any person obtaining
|
14
|
-
* a copy of this software and associated documentation files (the
|
15
|
-
* 'Software'), to deal in the Software without restriction, including
|
16
|
-
* without limitation the rights to use, copy, modify, merge, publish,
|
17
|
-
* distribute, sublicense, and/or sell copies of the Software, and to
|
18
|
-
* permit persons to whom the Software is furnished to do so, subject to
|
19
|
-
* the following conditions:
|
20
|
-
*
|
21
|
-
* The above copyright notice and this permission notice shall be
|
22
|
-
* included in all copies or substantial portions of the Software.
|
23
|
-
*
|
24
|
-
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
25
|
-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
26
|
-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
27
|
-
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
28
|
-
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
29
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
30
|
-
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
31
|
-
*/
|
32
|
-
|
33
|
-
package nokogiri;
|
34
|
-
|
35
|
-
import static nokogiri.internals.NokogiriHelpers.getLocalNameForNamespace;
|
36
|
-
import static nokogiri.internals.NokogiriHelpers.getNokogiriClass;
|
37
|
-
import nokogiri.internals.SaveContext;
|
38
|
-
|
39
|
-
import org.jruby.Ruby;
|
40
|
-
import org.jruby.RubyClass;
|
41
|
-
import org.jruby.RubyObject;
|
42
|
-
import org.jruby.RubyString;
|
43
|
-
import org.jruby.anno.JRubyClass;
|
44
|
-
import org.jruby.anno.JRubyMethod;
|
45
|
-
import org.jruby.runtime.ThreadContext;
|
46
|
-
import org.jruby.runtime.builtin.IRubyObject;
|
47
|
-
import org.w3c.dom.Node;
|
48
|
-
|
49
|
-
/**
|
50
|
-
* Class for Nokogiri::XML::Namespace
|
51
|
-
*
|
52
|
-
* @author serabe
|
53
|
-
* @author Yoko Harada <yokolet@gmail.com>
|
54
|
-
*/
|
55
|
-
@JRubyClass(name="Nokogiri::XML::Namespace")
|
56
|
-
public class XmlNamespace extends RubyObject {
|
57
|
-
|
58
|
-
private IRubyObject prefix;
|
59
|
-
private IRubyObject href;
|
60
|
-
|
61
|
-
public XmlNamespace(Ruby ruby, RubyClass klazz) {
|
62
|
-
super(ruby, klazz);
|
63
|
-
}
|
64
|
-
|
65
|
-
public XmlNamespace(Ruby ruby, String prefix, String href) {
|
66
|
-
this(ruby, getNokogiriClass(ruby, "Nokogiri::XML::Namespace"), prefix, href);
|
67
|
-
}
|
68
|
-
|
69
|
-
public XmlNamespace(Ruby ruby, RubyClass klazz, String prefix, String href) {
|
70
|
-
super(ruby, klazz);
|
71
|
-
this.prefix = (prefix == null) ? ruby.getNil() : RubyString.newString(ruby, prefix);
|
72
|
-
this.href = (href == null) ? ruby.getNil() : RubyString.newString(ruby, href);
|
73
|
-
}
|
74
|
-
|
75
|
-
public XmlNamespace(Ruby ruby, IRubyObject prefix, IRubyObject href) {
|
76
|
-
this(ruby, getNokogiriClass(ruby, "Nokogiri::XML::Namespace"), prefix, href);
|
77
|
-
}
|
78
|
-
|
79
|
-
public XmlNamespace(Ruby ruby, RubyClass klazz, IRubyObject prefix, IRubyObject href) {
|
80
|
-
super(ruby, klazz);
|
81
|
-
this.prefix = prefix;
|
82
|
-
this.href = href;
|
83
|
-
}
|
84
|
-
|
85
|
-
public void setDefinition(Ruby runtime, String prefix, String href) {
|
86
|
-
this.prefix = (prefix == null) ? runtime.getNil() : RubyString.newString(runtime, prefix);
|
87
|
-
this.href = (href == null) ? runtime.getNil() : RubyString.newString(runtime, href);
|
88
|
-
}
|
89
|
-
|
90
|
-
/**
|
91
|
-
* Create and return a copy of this object.
|
92
|
-
*
|
93
|
-
* @return a clone of this object
|
94
|
-
*/
|
95
|
-
@Override
|
96
|
-
public Object clone() throws CloneNotSupportedException {
|
97
|
-
return super.clone();
|
98
|
-
}
|
99
|
-
|
100
|
-
public static XmlNamespace fromNode(Ruby ruby, Node node) {
|
101
|
-
String localName = getLocalNameForNamespace(node.getNodeName());
|
102
|
-
XmlNamespace namespace = (XmlNamespace) NokogiriService.XML_NAMESPACE_ALLOCATOR.allocate(ruby, getNokogiriClass(ruby, "Nokogiri::XML::Namespace"));
|
103
|
-
namespace.setDefinition(ruby, localName, node.getNodeValue());
|
104
|
-
return namespace;
|
105
|
-
}
|
106
|
-
|
107
|
-
public boolean isEmpty() {
|
108
|
-
return this.prefix.isNil() && this.href.isNil();
|
109
|
-
}
|
110
|
-
|
111
|
-
public void setDocument(IRubyObject doc) {
|
112
|
-
this.setInstanceVariable("@document", doc);
|
113
|
-
}
|
114
|
-
|
115
|
-
@JRubyMethod
|
116
|
-
public IRubyObject href(ThreadContext context) {
|
117
|
-
return this.href;
|
118
|
-
}
|
119
|
-
|
120
|
-
@JRubyMethod
|
121
|
-
public IRubyObject prefix(ThreadContext context) {
|
122
|
-
return this.prefix;
|
123
|
-
}
|
124
|
-
|
125
|
-
public void saveContent(ThreadContext context, SaveContext ctx) {
|
126
|
-
ctx.append(" " + prefix + "=\"" + href + "\"");
|
127
|
-
}
|
128
|
-
}
|