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,238 +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.internals;
|
34
|
-
|
35
|
-
import static nokogiri.internals.NokogiriHelpers.getNokogiriClass;
|
36
|
-
import static nokogiri.internals.NokogiriHelpers.rubyStringToString;
|
37
|
-
|
38
|
-
import java.io.ByteArrayInputStream;
|
39
|
-
import java.io.IOException;
|
40
|
-
import java.util.ArrayList;
|
41
|
-
import java.util.List;
|
42
|
-
|
43
|
-
import nokogiri.NokogiriService;
|
44
|
-
import nokogiri.XmlDocument;
|
45
|
-
import nokogiri.XmlSyntaxError;
|
46
|
-
|
47
|
-
import org.apache.xerces.parsers.DOMParser;
|
48
|
-
import org.jruby.Ruby;
|
49
|
-
import org.jruby.RubyArray;
|
50
|
-
import org.jruby.RubyClass;
|
51
|
-
import org.jruby.exceptions.RaiseException;
|
52
|
-
import org.jruby.runtime.ThreadContext;
|
53
|
-
import org.jruby.runtime.builtin.IRubyObject;
|
54
|
-
import org.w3c.dom.Document;
|
55
|
-
import org.w3c.dom.Node;
|
56
|
-
import org.w3c.dom.NodeList;
|
57
|
-
import org.xml.sax.EntityResolver;
|
58
|
-
import org.xml.sax.InputSource;
|
59
|
-
import org.xml.sax.SAXException;
|
60
|
-
|
61
|
-
/**
|
62
|
-
* Parser class for XML DOM processing. This class actually parses XML document
|
63
|
-
* and creates DOM tree in Java side. However, DOM tree in Ruby side is not since
|
64
|
-
* we delay creating objects for performance.
|
65
|
-
*
|
66
|
-
* @author sergio
|
67
|
-
* @author Yoko Harada <yokolet@gmail.com>
|
68
|
-
*/
|
69
|
-
public class XmlDomParserContext extends ParserContext {
|
70
|
-
protected static final String FEATURE_LOAD_EXTERNAL_DTD =
|
71
|
-
"http://apache.org/xml/features/nonvalidating/load-external-dtd";
|
72
|
-
protected static final String FEATURE_INCLUDE_IGNORABLE_WHITESPACE =
|
73
|
-
"http://apache.org/xml/features/dom/include-ignorable-whitespace";
|
74
|
-
protected static final String FEATURE_VALIDATION = "http://xml.org/sax/features/validation";
|
75
|
-
|
76
|
-
protected ParserContext.Options options;
|
77
|
-
protected DOMParser parser;
|
78
|
-
protected NokogiriErrorHandler errorHandler;
|
79
|
-
protected String java_encoding;
|
80
|
-
protected IRubyObject ruby_encoding;
|
81
|
-
|
82
|
-
public XmlDomParserContext(Ruby runtime, IRubyObject options) {
|
83
|
-
this(runtime, runtime.getNil(), options);
|
84
|
-
}
|
85
|
-
|
86
|
-
public XmlDomParserContext(Ruby runtime, IRubyObject encoding, IRubyObject options) {
|
87
|
-
super(runtime);
|
88
|
-
this.options = new ParserContext.Options((Long)options.toJava(Long.class));
|
89
|
-
this.java_encoding = encoding.isNil() ? NokogiriHelpers.guessEncoding(runtime) : rubyStringToString(encoding);
|
90
|
-
ruby_encoding = encoding;
|
91
|
-
initErrorHandler();
|
92
|
-
initParser(runtime);
|
93
|
-
}
|
94
|
-
|
95
|
-
protected void initErrorHandler() {
|
96
|
-
if (options.recover) {
|
97
|
-
errorHandler = new NokogiriNonStrictErrorHandler(options.noError, options.noWarning);
|
98
|
-
} else {
|
99
|
-
errorHandler = new NokogiriStrictErrorHandler(options.noError, options.noWarning);
|
100
|
-
}
|
101
|
-
}
|
102
|
-
|
103
|
-
protected void initParser(Ruby runtime) {
|
104
|
-
parser = new XmlDomParser();
|
105
|
-
parser.setErrorHandler(errorHandler);
|
106
|
-
|
107
|
-
if (options.noBlanks) {
|
108
|
-
setFeature(FEATURE_INCLUDE_IGNORABLE_WHITESPACE, false);
|
109
|
-
}
|
110
|
-
|
111
|
-
if (options.dtdValid) {
|
112
|
-
setFeature(FEATURE_VALIDATION, true);
|
113
|
-
}
|
114
|
-
// If we turn off loading of external DTDs complete, we don't
|
115
|
-
// getthe publicID. Instead of turning off completely, we use
|
116
|
-
// an entity resolver that returns empty documents.
|
117
|
-
if (options.dtdLoad) {
|
118
|
-
setFeature(FEATURE_LOAD_EXTERNAL_DTD, true);
|
119
|
-
parser.setEntityResolver(new ChdirEntityResolver(runtime));
|
120
|
-
} else {
|
121
|
-
parser.setEntityResolver(new EntityResolver() {
|
122
|
-
public InputSource resolveEntity(String arg0, String arg1)
|
123
|
-
throws SAXException, IOException {
|
124
|
-
ByteArrayInputStream empty =
|
125
|
-
new ByteArrayInputStream(new byte[0]);
|
126
|
-
return new InputSource(empty);
|
127
|
-
}
|
128
|
-
});
|
129
|
-
}
|
130
|
-
}
|
131
|
-
|
132
|
-
/**
|
133
|
-
* Convenience method that catches and ignores SAXException
|
134
|
-
* (unrecognized and unsupported exceptions).
|
135
|
-
*/
|
136
|
-
protected void setFeature(String feature, boolean value) {
|
137
|
-
try {
|
138
|
-
parser.setFeature(feature, value);
|
139
|
-
} catch (SAXException e) {
|
140
|
-
// ignore
|
141
|
-
}
|
142
|
-
}
|
143
|
-
|
144
|
-
/**
|
145
|
-
* Convenience method that catches and ignores SAXException
|
146
|
-
* (unrecognized and unsupported exceptions).
|
147
|
-
*/
|
148
|
-
protected void setProperty(String property, Object value) {
|
149
|
-
try {
|
150
|
-
parser.setProperty(property, value);
|
151
|
-
} catch (SAXException e) {
|
152
|
-
// ignore
|
153
|
-
}
|
154
|
-
}
|
155
|
-
|
156
|
-
public void addErrorsIfNecessary(ThreadContext context, XmlDocument doc) {
|
157
|
-
Ruby ruby = context.getRuntime();
|
158
|
-
RubyArray errors = ruby.newArray(errorHandler.getErrorsReadyForRuby(context));
|
159
|
-
doc.setInstanceVariable("@errors", errors);
|
160
|
-
}
|
161
|
-
|
162
|
-
public XmlDocument getDocumentWithErrorsOrRaiseException(ThreadContext context, Exception ex) {
|
163
|
-
if (options.recover) {
|
164
|
-
XmlDocument doc = this.getNewEmptyDocument(context);
|
165
|
-
this.addErrorsIfNecessary(context, doc);
|
166
|
-
XmlSyntaxError xmlSyntaxError = (XmlSyntaxError) NokogiriService.XML_SYNTAXERROR_ALLOCATOR.allocate(context.getRuntime(), getNokogiriClass(context.getRuntime(), "Nokogiri::XML::SyntaxError"));
|
167
|
-
xmlSyntaxError.setException(ex);
|
168
|
-
((RubyArray) doc.getInstanceVariable("@errors")).append(xmlSyntaxError);
|
169
|
-
return doc;
|
170
|
-
} else {
|
171
|
-
XmlSyntaxError xmlSyntaxError = (XmlSyntaxError) NokogiriService.XML_SYNTAXERROR_ALLOCATOR.allocate(context.getRuntime(), getNokogiriClass(context.getRuntime(), "Nokogiri::XML::SyntaxError"));
|
172
|
-
xmlSyntaxError.setException(ex);
|
173
|
-
throw new RaiseException(xmlSyntaxError);
|
174
|
-
}
|
175
|
-
}
|
176
|
-
|
177
|
-
protected XmlDocument getNewEmptyDocument(ThreadContext context) {
|
178
|
-
IRubyObject[] args = new IRubyObject[0];
|
179
|
-
return (XmlDocument) XmlDocument.rbNew(context, getNokogiriClass(context.getRuntime(), "Nokogiri::XML::Document"), args);
|
180
|
-
}
|
181
|
-
|
182
|
-
/**
|
183
|
-
* This method is broken out so that HtmlDomParserContext can
|
184
|
-
* override it.
|
185
|
-
*/
|
186
|
-
protected XmlDocument wrapDocument(ThreadContext context,
|
187
|
-
RubyClass klazz,
|
188
|
-
Document doc) {
|
189
|
-
XmlDocument xmlDocument = (XmlDocument) NokogiriService.XML_DOCUMENT_ALLOCATOR.allocate(context.getRuntime(), klazz);
|
190
|
-
xmlDocument.setNode(context, doc);
|
191
|
-
xmlDocument.setEncoding(ruby_encoding);
|
192
|
-
return xmlDocument;
|
193
|
-
}
|
194
|
-
|
195
|
-
/**
|
196
|
-
* Must call setInputSource() before this method.
|
197
|
-
*/
|
198
|
-
public XmlDocument parse(ThreadContext context,
|
199
|
-
IRubyObject klass,
|
200
|
-
IRubyObject url) {
|
201
|
-
try {
|
202
|
-
Document doc = do_parse();
|
203
|
-
XmlDocument xmlDoc = wrapDocument(context, (RubyClass)klass, doc);
|
204
|
-
xmlDoc.setUrl(url);
|
205
|
-
addErrorsIfNecessary(context, xmlDoc);
|
206
|
-
return xmlDoc;
|
207
|
-
} catch (SAXException e) {
|
208
|
-
return getDocumentWithErrorsOrRaiseException(context, e);
|
209
|
-
} catch (IOException e) {
|
210
|
-
return getDocumentWithErrorsOrRaiseException(context, e);
|
211
|
-
}
|
212
|
-
}
|
213
|
-
|
214
|
-
protected Document do_parse() throws SAXException, IOException {
|
215
|
-
parser.parse(getInputSource());
|
216
|
-
if (options.noBlanks) {
|
217
|
-
List<Node> emptyNodes = new ArrayList<Node>();
|
218
|
-
findEmptyTexts(parser.getDocument(), emptyNodes);
|
219
|
-
if (emptyNodes.size() > 0) {
|
220
|
-
for (Node node : emptyNodes) {
|
221
|
-
node.getParentNode().removeChild(node);
|
222
|
-
}
|
223
|
-
}
|
224
|
-
}
|
225
|
-
return parser.getDocument();
|
226
|
-
}
|
227
|
-
|
228
|
-
private void findEmptyTexts(Node node, List<Node> emptyNodes) {
|
229
|
-
if (node.getNodeType() == Node.TEXT_NODE && "".equals(node.getTextContent().trim())) {
|
230
|
-
emptyNodes.add(node);
|
231
|
-
} else {
|
232
|
-
NodeList children = node.getChildNodes();
|
233
|
-
for (int i=0; i < children.getLength(); i++) {
|
234
|
-
findEmptyTexts(children.item(i), emptyNodes);
|
235
|
-
}
|
236
|
-
}
|
237
|
-
}
|
238
|
-
}
|
@@ -1,65 +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.internals;
|
34
|
-
|
35
|
-
import org.apache.xerces.parsers.SAXParser;
|
36
|
-
import org.apache.xerces.xni.Augmentations;
|
37
|
-
import org.apache.xerces.xni.XNIException;
|
38
|
-
|
39
|
-
/**
|
40
|
-
* Extends SAXParser in order to receive xmlDecl events and pass them
|
41
|
-
* on to a handler.
|
42
|
-
*
|
43
|
-
* @author Patrick Mahoney <pat@polycrystal.org>
|
44
|
-
*/
|
45
|
-
public class XmlSaxParser extends SAXParser {
|
46
|
-
|
47
|
-
protected XmlDeclHandler xmlDeclHandler = null;
|
48
|
-
|
49
|
-
public XmlSaxParser() {
|
50
|
-
super();
|
51
|
-
}
|
52
|
-
|
53
|
-
public void setXmlDeclHandler(XmlDeclHandler xmlDeclHandler) {
|
54
|
-
this.xmlDeclHandler = xmlDeclHandler;
|
55
|
-
}
|
56
|
-
|
57
|
-
@Override
|
58
|
-
public void xmlDecl(String version, String encoding, String standalone,
|
59
|
-
Augmentations augs) throws XNIException {
|
60
|
-
super.xmlDecl(version, encoding, standalone, augs);
|
61
|
-
if (xmlDeclHandler != null) {
|
62
|
-
xmlDeclHandler.xmlDecl(version, encoding, standalone);
|
63
|
-
}
|
64
|
-
}
|
65
|
-
}
|
@@ -1,72 +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.internals;
|
34
|
-
|
35
|
-
import org.jruby.javasupport.JavaUtil;
|
36
|
-
import org.jruby.javasupport.util.RuntimeHelpers;
|
37
|
-
import org.jruby.runtime.ThreadContext;
|
38
|
-
import org.jruby.runtime.builtin.IRubyObject;
|
39
|
-
|
40
|
-
import nokogiri.XsltStylesheet;
|
41
|
-
|
42
|
-
/**
|
43
|
-
* XSLT extension function caller. Currently, this class is not used because
|
44
|
-
* parsing XSL file with extension function (written in Java) fails. The reason of
|
45
|
-
* the failure is a conflict of Java APIs. When xercesImpl.jar or jing.jar, or both
|
46
|
-
* are on a classpath, parsing fails. Assuming parsing passes, this class will be
|
47
|
-
* used as in below:
|
48
|
-
*
|
49
|
-
* <xsl:stylesheet
|
50
|
-
* xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
51
|
-
* xmlns:f="xalan://nokogiri.internals.XsltExtensionFunction"
|
52
|
-
* extension-element-prefixes="f"
|
53
|
-
* version="1.0">
|
54
|
-
* <xsl:template match="text()">
|
55
|
-
* <xsl:copy-of select="f:call('capitalize', string(.))"/>
|
56
|
-
* </xsl:template>
|
57
|
-
* ...
|
58
|
-
* </xsl:stylesheet>
|
59
|
-
*
|
60
|
-
* @author Yoko Harada <yokolet@gmail.com>
|
61
|
-
*/
|
62
|
-
public class XsltExtensionFunction {
|
63
|
-
public static Object call(String method, Object arg) {
|
64
|
-
if (XsltStylesheet.getRegistry() == null) return null;
|
65
|
-
ThreadContext context = (ThreadContext) XsltStylesheet.getRegistry().get("context");
|
66
|
-
IRubyObject receiver = (IRubyObject)XsltStylesheet.getRegistry().get("receiver");
|
67
|
-
if (context == null || receiver == null) return null;
|
68
|
-
IRubyObject arg0 = JavaUtil.convertJavaToUsableRubyObject(context.getRuntime(), arg);
|
69
|
-
IRubyObject result = RuntimeHelpers.invoke(context, receiver, method, arg0);
|
70
|
-
return result.toJava(Object.class);
|
71
|
-
}
|
72
|
-
}
|
data/lib/isorelax.jar
DELETED
Binary file
|
data/lib/jing.jar
DELETED
Binary file
|
data/lib/nekodtd.jar
DELETED
Binary file
|
data/lib/nekohtml.jar
DELETED
Binary file
|
data/lib/xercesImpl.jar
DELETED
Binary file
|