nokogiri 1.5.0.beta.1 → 1.5.0.beta.2
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/CHANGELOG.ja.rdoc +28 -8
- data/CHANGELOG.rdoc +23 -0
- data/Manifest.txt +63 -1
- data/README.ja.rdoc +1 -1
- data/README.rdoc +22 -4
- data/Rakefile +6 -2
- data/ext/java/nokogiri/EncodingHandler.java +92 -0
- data/ext/java/nokogiri/HtmlDocument.java +116 -0
- data/ext/java/nokogiri/HtmlElementDescription.java +111 -0
- data/ext/java/nokogiri/HtmlEntityLookup.java +45 -0
- data/ext/java/nokogiri/HtmlSaxParserContext.java +218 -0
- data/ext/java/nokogiri/NokogiriService.java +370 -0
- data/ext/java/nokogiri/XmlAttr.java +147 -0
- data/ext/java/nokogiri/XmlAttributeDecl.java +98 -0
- data/ext/java/nokogiri/XmlCdata.java +50 -0
- data/ext/java/nokogiri/XmlComment.java +47 -0
- data/ext/java/nokogiri/XmlDocument.java +463 -0
- data/ext/java/nokogiri/XmlDocumentFragment.java +207 -0
- data/ext/java/nokogiri/XmlDtd.java +427 -0
- data/ext/java/nokogiri/XmlElement.java +172 -0
- data/ext/java/nokogiri/XmlElementContent.java +350 -0
- data/ext/java/nokogiri/XmlElementDecl.java +115 -0
- data/ext/java/nokogiri/XmlEntityDecl.java +129 -0
- data/ext/java/nokogiri/XmlEntityReference.java +42 -0
- data/ext/java/nokogiri/XmlNamespace.java +77 -0
- data/ext/java/nokogiri/XmlNode.java +1399 -0
- data/ext/java/nokogiri/XmlNodeSet.java +248 -0
- data/ext/java/nokogiri/XmlProcessingInstruction.java +70 -0
- data/ext/java/nokogiri/XmlReader.java +373 -0
- data/ext/java/nokogiri/XmlRelaxng.java +166 -0
- data/ext/java/nokogiri/XmlSaxParserContext.java +308 -0
- data/ext/java/nokogiri/XmlSaxPushParser.java +146 -0
- data/ext/java/nokogiri/XmlSchema.java +142 -0
- data/ext/java/nokogiri/XmlSyntaxError.java +84 -0
- data/ext/java/nokogiri/XmlText.java +96 -0
- data/ext/java/nokogiri/XmlXpathContext.java +130 -0
- data/ext/java/nokogiri/XsltStylesheet.java +126 -0
- data/ext/java/nokogiri/internals/HtmlDomParserContext.java +181 -0
- data/ext/java/nokogiri/internals/NokogiriDocumentCache.java +39 -0
- data/ext/java/nokogiri/internals/NokogiriErrorHandler.java +42 -0
- data/ext/java/nokogiri/internals/NokogiriHandler.java +251 -0
- data/ext/java/nokogiri/internals/NokogiriHelpers.java +526 -0
- data/ext/java/nokogiri/internals/NokogiriNamespaceCache.java +136 -0
- data/ext/java/nokogiri/internals/NokogiriNamespaceContext.java +80 -0
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java +37 -0
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java +54 -0
- data/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java +49 -0
- data/ext/java/nokogiri/internals/NokogiriXPathFunction.java +88 -0
- data/ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java +23 -0
- data/ext/java/nokogiri/internals/ParserContext.java +235 -0
- data/ext/java/nokogiri/internals/PushInputStream.java +381 -0
- data/ext/java/nokogiri/internals/ReaderNode.java +431 -0
- data/ext/java/nokogiri/internals/SaveContext.java +249 -0
- data/ext/java/nokogiri/internals/SchemaErrorHandler.java +35 -0
- data/ext/java/nokogiri/internals/XmlDeclHandler.java +10 -0
- data/ext/java/nokogiri/internals/XmlDomParser.java +45 -0
- data/ext/java/nokogiri/internals/XmlDomParserContext.java +201 -0
- data/ext/java/nokogiri/internals/XmlSaxParser.java +33 -0
- data/ext/nokogiri/depend +32 -0
- data/ext/nokogiri/extconf.rb +61 -32
- data/ext/nokogiri/nokogiri.c +0 -5
- data/ext/nokogiri/nokogiri.h +2 -2
- data/ext/nokogiri/xml_document.c +5 -0
- data/ext/nokogiri/xml_libxml2_hacks.c +112 -0
- data/ext/nokogiri/xml_libxml2_hacks.h +12 -0
- data/ext/nokogiri/xml_node.c +56 -16
- data/ext/nokogiri/xml_node_set.c +7 -7
- data/ext/nokogiri/xml_reader.c +20 -1
- data/ext/nokogiri/xml_relax_ng.c +0 -7
- data/ext/nokogiri/xml_xpath_context.c +2 -0
- 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/nokogiri.rb +1 -2
- data/lib/nokogiri/css/generated_parser.rb +155 -148
- data/lib/nokogiri/css/generated_tokenizer.rb +2 -1
- data/lib/nokogiri/css/parser.y +3 -0
- data/lib/nokogiri/css/xpath_visitor.rb +1 -7
- data/lib/nokogiri/html.rb +2 -2
- data/lib/nokogiri/html/document_fragment.rb +7 -4
- data/lib/nokogiri/nokogiri.jar +0 -0
- data/lib/nokogiri/version.rb +3 -6
- data/lib/nokogiri/xml/builder.rb +1 -1
- data/lib/nokogiri/xml/document.rb +1 -2
- data/lib/nokogiri/xml/document_fragment.rb +7 -0
- data/lib/nokogiri/xml/node.rb +5 -3
- data/lib/nokogiri/xml/node_set.rb +25 -0
- data/lib/nokogiri/xml/reader.rb +2 -0
- data/lib/nokogiri/xml/sax/document.rb +3 -1
- data/lib/xercesImpl.jar +0 -0
- data/spec/helper.rb +3 -0
- data/spec/xml/reader_spec.rb +307 -0
- data/tasks/test.rb +1 -1
- data/test/css/test_parser.rb +11 -1
- data/test/html/sax/test_parser_context.rb +2 -2
- data/test/html/test_document.rb +2 -2
- data/test/html/test_document_fragment.rb +34 -6
- data/test/test_memory_leak.rb +2 -2
- data/test/test_reader.rb +28 -6
- data/test/test_xslt_transforms.rb +2 -3
- data/test/xml/test_attr.rb +31 -4
- data/test/xml/test_builder.rb +5 -5
- data/test/xml/test_cdata.rb +3 -3
- data/test/xml/test_document.rb +8 -8
- data/test/xml/test_document_fragment.rb +4 -12
- data/test/xml/test_node.rb +1 -1
- data/test/xml/test_node_reparenting.rb +26 -11
- data/test/xml/test_node_set.rb +38 -2
- data/test/xml/test_text.rb +11 -2
- data/test/xml/test_unparented_node.rb +1 -1
- data/test/xml/test_xpath.rb +11 -7
- metadata +68 -5
- data/lib/nokogiri/version_warning.rb +0 -14
@@ -0,0 +1,35 @@
|
|
1
|
+
package nokogiri.internals;
|
2
|
+
|
3
|
+
import nokogiri.XmlSyntaxError;
|
4
|
+
import org.jruby.Ruby;
|
5
|
+
import org.jruby.RubyArray;
|
6
|
+
import org.xml.sax.ErrorHandler;
|
7
|
+
import org.xml.sax.SAXException;
|
8
|
+
import org.xml.sax.SAXParseException;
|
9
|
+
|
10
|
+
/**
|
11
|
+
*
|
12
|
+
* @author sergio
|
13
|
+
*/
|
14
|
+
public class SchemaErrorHandler implements ErrorHandler{
|
15
|
+
private RubyArray errors;
|
16
|
+
private Ruby ruby;
|
17
|
+
|
18
|
+
public SchemaErrorHandler(Ruby ruby, RubyArray array) {
|
19
|
+
this.ruby = ruby;
|
20
|
+
this.errors = array;
|
21
|
+
}
|
22
|
+
|
23
|
+
public void warning(SAXParseException ex) throws SAXException {
|
24
|
+
this.errors.append(new XmlSyntaxError(ruby, ex));
|
25
|
+
}
|
26
|
+
|
27
|
+
public void error(SAXParseException ex) throws SAXException {
|
28
|
+
this.errors.append(new XmlSyntaxError(ruby, ex));
|
29
|
+
}
|
30
|
+
|
31
|
+
public void fatalError(SAXParseException ex) throws SAXException {
|
32
|
+
throw ex;
|
33
|
+
}
|
34
|
+
|
35
|
+
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
package nokogiri.internals;
|
2
|
+
|
3
|
+
import java.io.IOException;
|
4
|
+
|
5
|
+
import nokogiri.XmlDocument;
|
6
|
+
|
7
|
+
import org.apache.xerces.parsers.DOMParser;
|
8
|
+
import org.apache.xerces.xni.parser.XMLParserConfiguration;
|
9
|
+
import org.cyberneko.dtd.DTDConfiguration;
|
10
|
+
import org.w3c.dom.Document;
|
11
|
+
import org.xml.sax.InputSource;
|
12
|
+
import org.xml.sax.SAXException;
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Sets up a Xerces/XNI DOM Parser for use with Nokogiri. Uses
|
16
|
+
* NekoDTD to parse the DTD into a tree of Nodes.
|
17
|
+
*
|
18
|
+
* @author Patrick Mahoney <pat@polycrystal.org>
|
19
|
+
*/
|
20
|
+
public class XmlDomParser extends DOMParser {
|
21
|
+
DOMParser dtd;
|
22
|
+
|
23
|
+
public XmlDomParser() {
|
24
|
+
super();
|
25
|
+
|
26
|
+
DTDConfiguration dtdConfig = new DTDConfiguration();
|
27
|
+
dtd = new DOMParser(dtdConfig);
|
28
|
+
|
29
|
+
XMLParserConfiguration config = getXMLParserConfiguration();
|
30
|
+
config.setDTDHandler(dtdConfig);
|
31
|
+
config.setDTDContentModelHandler(dtdConfig);
|
32
|
+
}
|
33
|
+
|
34
|
+
@Override
|
35
|
+
public void parse(InputSource source) throws SAXException, IOException {
|
36
|
+
dtd.reset();
|
37
|
+
super.parse(source);
|
38
|
+
Document doc = getDocument();
|
39
|
+
if (doc == null)
|
40
|
+
throw new RuntimeException("null document");
|
41
|
+
|
42
|
+
doc.setUserData(XmlDocument.DTD_RAW_DOCUMENT, dtd.getDocument(),
|
43
|
+
null);
|
44
|
+
}
|
45
|
+
}
|
@@ -0,0 +1,201 @@
|
|
1
|
+
package nokogiri.internals;
|
2
|
+
|
3
|
+
import static nokogiri.internals.NokogiriHelpers.getNokogiriClass;
|
4
|
+
|
5
|
+
import java.io.ByteArrayInputStream;
|
6
|
+
import java.io.IOException;
|
7
|
+
import java.util.ArrayList;
|
8
|
+
import java.util.List;
|
9
|
+
|
10
|
+
import nokogiri.XmlDocument;
|
11
|
+
import nokogiri.XmlSyntaxError;
|
12
|
+
|
13
|
+
import org.apache.xerces.parsers.DOMParser;
|
14
|
+
import org.jruby.Ruby;
|
15
|
+
import org.jruby.RubyArray;
|
16
|
+
import org.jruby.RubyClass;
|
17
|
+
import org.jruby.exceptions.RaiseException;
|
18
|
+
import org.jruby.runtime.ThreadContext;
|
19
|
+
import org.jruby.runtime.builtin.IRubyObject;
|
20
|
+
import org.w3c.dom.Document;
|
21
|
+
import org.w3c.dom.Node;
|
22
|
+
import org.w3c.dom.NodeList;
|
23
|
+
import org.xml.sax.EntityResolver;
|
24
|
+
import org.xml.sax.InputSource;
|
25
|
+
import org.xml.sax.SAXException;
|
26
|
+
|
27
|
+
/**
|
28
|
+
*
|
29
|
+
* @author sergio
|
30
|
+
*/
|
31
|
+
public class XmlDomParserContext extends ParserContext {
|
32
|
+
protected static final String FEATURE_LOAD_EXTERNAL_DTD =
|
33
|
+
"http://apache.org/xml/features/nonvalidating/load-external-dtd";
|
34
|
+
protected static final String FEATURE_INCLUDE_IGNORABLE_WHITESPACE =
|
35
|
+
"http://apache.org/xml/features/dom/include-ignorable-whitespace";
|
36
|
+
protected static final String FEATURE_VALIDATION = "http://xml.org/sax/features/validation";
|
37
|
+
|
38
|
+
protected ParserContext.Options options;
|
39
|
+
protected DOMParser parser;
|
40
|
+
protected NokogiriErrorHandler errorHandler;
|
41
|
+
protected String java_encoding;
|
42
|
+
protected IRubyObject ruby_encoding;
|
43
|
+
|
44
|
+
public XmlDomParserContext(Ruby runtime, IRubyObject options) {
|
45
|
+
this(runtime, runtime.getNil(), options);
|
46
|
+
}
|
47
|
+
|
48
|
+
public XmlDomParserContext(Ruby runtime, IRubyObject encoding, IRubyObject options) {
|
49
|
+
super(runtime);
|
50
|
+
this.options = new ParserContext.Options((Long)options.toJava(Long.class));
|
51
|
+
this.java_encoding = encoding.isNil() ? NokogiriHelpers.guessEncoding(runtime) : (String)encoding.toJava(String.class);
|
52
|
+
ruby_encoding = encoding;
|
53
|
+
initErrorHandler();
|
54
|
+
initParser(runtime);
|
55
|
+
}
|
56
|
+
|
57
|
+
protected void initErrorHandler() {
|
58
|
+
if (continuesOnError()) {
|
59
|
+
errorHandler = new NokogiriNonStrictErrorHandler();
|
60
|
+
} else {
|
61
|
+
errorHandler = new NokogiriStrictErrorHandler();
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
protected void initParser(Ruby runtime) {
|
66
|
+
parser = new XmlDomParser();
|
67
|
+
parser.setErrorHandler(errorHandler);
|
68
|
+
|
69
|
+
if (options.noBlanks) {
|
70
|
+
setFeature(FEATURE_INCLUDE_IGNORABLE_WHITESPACE, false);
|
71
|
+
}
|
72
|
+
|
73
|
+
if (options.dtdValid) {
|
74
|
+
setFeature(FEATURE_VALIDATION, true);
|
75
|
+
}
|
76
|
+
// If we turn off loading of external DTDs complete, we don't
|
77
|
+
// getthe publicID. Instead of turning off completely, we use
|
78
|
+
// an entity resolver that returns empty documents.
|
79
|
+
if (options.dtdLoad) {
|
80
|
+
setFeature(FEATURE_LOAD_EXTERNAL_DTD, true);
|
81
|
+
parser.setEntityResolver(new ChdirEntityResolver(runtime));
|
82
|
+
} else {
|
83
|
+
parser.setEntityResolver(new EntityResolver() {
|
84
|
+
public InputSource resolveEntity(String arg0, String arg1)
|
85
|
+
throws SAXException, IOException {
|
86
|
+
ByteArrayInputStream empty =
|
87
|
+
new ByteArrayInputStream(new byte[0]);
|
88
|
+
return new InputSource(empty);
|
89
|
+
}
|
90
|
+
});
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
/**
|
95
|
+
* Convenience method that catches and ignores SAXException
|
96
|
+
* (unrecognized and unsupported exceptions).
|
97
|
+
*/
|
98
|
+
protected void setFeature(String feature, boolean value) {
|
99
|
+
try {
|
100
|
+
parser.setFeature(feature, value);
|
101
|
+
} catch (SAXException e) {
|
102
|
+
// ignore
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
/**
|
107
|
+
* Convenience method that catches and ignores SAXException
|
108
|
+
* (unrecognized and unsupported exceptions).
|
109
|
+
*/
|
110
|
+
protected void setProperty(String property, Object value) {
|
111
|
+
try {
|
112
|
+
parser.setProperty(property, value);
|
113
|
+
} catch (SAXException e) {
|
114
|
+
// ignore
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
public void addErrorsIfNecessary(ThreadContext context, XmlDocument doc) {
|
119
|
+
Ruby ruby = context.getRuntime();
|
120
|
+
RubyArray errors = ruby.newArray(this.errorHandler.getErrorsReadyForRuby(context));
|
121
|
+
doc.setInstanceVariable("@errors", errors);
|
122
|
+
}
|
123
|
+
|
124
|
+
public XmlDocument getDocumentWithErrorsOrRaiseException(ThreadContext context, Exception ex) {
|
125
|
+
if(this.continuesOnError()) {
|
126
|
+
XmlDocument doc = this.getNewEmptyDocument(context);
|
127
|
+
this.addErrorsIfNecessary(context, doc);
|
128
|
+
((RubyArray) doc.getInstanceVariable("@errors")).append(new XmlSyntaxError(context.getRuntime(), ex));
|
129
|
+
return doc;
|
130
|
+
} else {
|
131
|
+
throw new RaiseException(new XmlSyntaxError(context.getRuntime(), ex));
|
132
|
+
}
|
133
|
+
}
|
134
|
+
|
135
|
+
protected XmlDocument getNewEmptyDocument(ThreadContext context) {
|
136
|
+
IRubyObject[] args = new IRubyObject[0];
|
137
|
+
return (XmlDocument) XmlDocument.rbNew(context,
|
138
|
+
getNokogiriClass(context.getRuntime(), "Nokogiri::XML::Document"),
|
139
|
+
args);
|
140
|
+
}
|
141
|
+
|
142
|
+
public boolean continuesOnError() {
|
143
|
+
return options.recover;
|
144
|
+
}
|
145
|
+
|
146
|
+
/**
|
147
|
+
* This method is broken out so that HtmlDomParserContext can
|
148
|
+
* override it.
|
149
|
+
*/
|
150
|
+
protected XmlDocument wrapDocument(ThreadContext context,
|
151
|
+
RubyClass klass,
|
152
|
+
Document doc) {
|
153
|
+
XmlDocument xmlDocument = new XmlDocument(context.getRuntime(), klass, doc);
|
154
|
+
xmlDocument.setEncoding(ruby_encoding);
|
155
|
+
return xmlDocument;
|
156
|
+
}
|
157
|
+
|
158
|
+
/**
|
159
|
+
* Must call setInputSource() before this method.
|
160
|
+
*/
|
161
|
+
public XmlDocument parse(ThreadContext context,
|
162
|
+
IRubyObject klass,
|
163
|
+
IRubyObject url) {
|
164
|
+
try {
|
165
|
+
Document doc = do_parse();
|
166
|
+
XmlDocument xmlDoc = wrapDocument(context, (RubyClass)klass, doc);
|
167
|
+
xmlDoc.setUrl(url);
|
168
|
+
addErrorsIfNecessary(context, xmlDoc);
|
169
|
+
return xmlDoc;
|
170
|
+
} catch (SAXException e) {
|
171
|
+
return getDocumentWithErrorsOrRaiseException(context, e);
|
172
|
+
} catch (IOException e) {
|
173
|
+
return getDocumentWithErrorsOrRaiseException(context, e);
|
174
|
+
}
|
175
|
+
}
|
176
|
+
|
177
|
+
protected Document do_parse() throws SAXException, IOException {
|
178
|
+
parser.parse(getInputSource());
|
179
|
+
if (options.noBlanks) {
|
180
|
+
List<Node> emptyNodes = new ArrayList<Node>();
|
181
|
+
findEmptyTexts(parser.getDocument(), emptyNodes);
|
182
|
+
if (emptyNodes.size() > 0) {
|
183
|
+
for (Node node : emptyNodes) {
|
184
|
+
node.getParentNode().removeChild(node);
|
185
|
+
}
|
186
|
+
}
|
187
|
+
}
|
188
|
+
return parser.getDocument();
|
189
|
+
}
|
190
|
+
|
191
|
+
private void findEmptyTexts(Node node, List<Node> emptyNodes) {
|
192
|
+
if (node.getNodeType() == Node.TEXT_NODE && "".equals(node.getTextContent().trim())) {
|
193
|
+
emptyNodes.add(node);
|
194
|
+
} else {
|
195
|
+
NodeList children = node.getChildNodes();
|
196
|
+
for (int i=0; i < children.getLength(); i++) {
|
197
|
+
findEmptyTexts(children.item(i), emptyNodes);
|
198
|
+
}
|
199
|
+
}
|
200
|
+
}
|
201
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
package nokogiri.internals;
|
2
|
+
|
3
|
+
import org.apache.xerces.parsers.SAXParser;
|
4
|
+
import org.apache.xerces.xni.Augmentations;
|
5
|
+
import org.apache.xerces.xni.XNIException;
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Extends SAXParser in order to receive xmlDecl events and pass them
|
9
|
+
* on to a handler.
|
10
|
+
*
|
11
|
+
* @author Patrick Mahoney <pat@polycrystal.org>
|
12
|
+
*/
|
13
|
+
public class XmlSaxParser extends SAXParser {
|
14
|
+
|
15
|
+
protected XmlDeclHandler xmlDeclHandler = null;
|
16
|
+
|
17
|
+
public XmlSaxParser() {
|
18
|
+
super();
|
19
|
+
}
|
20
|
+
|
21
|
+
public void setXmlDeclHandler(XmlDeclHandler xmlDeclHandler) {
|
22
|
+
this.xmlDeclHandler = xmlDeclHandler;
|
23
|
+
}
|
24
|
+
|
25
|
+
@Override
|
26
|
+
public void xmlDecl(String version, String encoding, String standalone,
|
27
|
+
Augmentations augs) throws XNIException {
|
28
|
+
super.xmlDecl(version, encoding, standalone, augs);
|
29
|
+
if (xmlDeclHandler != null) {
|
30
|
+
xmlDeclHandler.xmlDecl(version, encoding, standalone);
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
data/ext/nokogiri/depend
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
html_document.o: html_document.c
|
2
|
+
html_element_description.o: html_element_description.c
|
3
|
+
html_entity_lookup.o: html_entity_lookup.c
|
4
|
+
html_sax_parser_context.o: html_sax_parser_context.c
|
5
|
+
nokogiri.o: nokogiri.c
|
6
|
+
xml_attr.o: xml_attr.c
|
7
|
+
xml_attribute_decl.o: xml_attribute_decl.c
|
8
|
+
xml_cdata.o: xml_cdata.c
|
9
|
+
xml_comment.o: xml_comment.c
|
10
|
+
xml_document.o: xml_document.c
|
11
|
+
xml_document_fragment.o: xml_document_fragment.c
|
12
|
+
xml_dtd.o: xml_dtd.c
|
13
|
+
xml_element_content.o: xml_element_content.c
|
14
|
+
xml_element_decl.o: xml_element_decl.c
|
15
|
+
xml_encoding_handler.o: xml_encoding_handler.c
|
16
|
+
xml_entity_decl.o: xml_entity_decl.c
|
17
|
+
xml_entity_reference.o: xml_entity_reference.c
|
18
|
+
xml_io.o: xml_io.c
|
19
|
+
xml_namespace.o: xml_namespace.c
|
20
|
+
xml_node.o: xml_node.c
|
21
|
+
xml_node_set.o: xml_node_set.c
|
22
|
+
xml_processing_instruction.o: xml_processing_instruction.c
|
23
|
+
xml_reader.o: xml_reader.c
|
24
|
+
xml_relax_ng.o: xml_relax_ng.c
|
25
|
+
xml_sax_parser.o: xml_sax_parser.c
|
26
|
+
xml_sax_parser_context.o: xml_sax_parser_context.c
|
27
|
+
xml_sax_push_parser.o: xml_sax_push_parser.c
|
28
|
+
xml_schema.o: xml_schema.c
|
29
|
+
xml_syntax_error.o: xml_syntax_error.c
|
30
|
+
xml_text.o: xml_text.c
|
31
|
+
xml_xpath_context.o: xml_xpath_context.c
|
32
|
+
xslt_stylesheet.o: xslt_stylesheet.c
|
data/ext/nokogiri/extconf.rb
CHANGED
@@ -17,7 +17,7 @@ end
|
|
17
17
|
$CFLAGS << " #{ENV["CFLAGS"]}"
|
18
18
|
$LIBS << " #{ENV["LIBS"]}"
|
19
19
|
|
20
|
-
if Config::CONFIG['target_os'] == 'mingw32'
|
20
|
+
if Config::CONFIG['target_os'] == 'mingw32' || Config::CONFIG['target_os'] =~ /mswin32/
|
21
21
|
$CFLAGS << " -DXP_WIN -DXP_WIN32 -DUSE_INCLUDED_VASPRINTF"
|
22
22
|
elsif Config::CONFIG['target_os'] =~ /solaris/
|
23
23
|
$CFLAGS << " -DUSE_INCLUDED_VASPRINTF"
|
@@ -29,58 +29,87 @@ if RbConfig::MAKEFILE_CONFIG['CC'] =~ /mingw/
|
|
29
29
|
$CFLAGS << " -DIN_LIBXML"
|
30
30
|
end
|
31
31
|
|
32
|
-
|
32
|
+
if RbConfig::MAKEFILE_CONFIG['CC'] =~ /gcc/
|
33
|
+
$CFLAGS << " -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline"
|
34
|
+
end
|
35
|
+
|
36
|
+
if Config::CONFIG['target_os'] =~ /mswin32/
|
37
|
+
lib_prefix = 'lib'
|
38
|
+
|
39
|
+
# There's no default include/lib dir on Windows. Let's just add the Ruby ones
|
40
|
+
# and resort on the search path specified by INCLUDE and LIB environment
|
41
|
+
# variables
|
42
|
+
HEADER_DIRS = [INCLUDEDIR]
|
43
|
+
LIB_DIRS = [LIBDIR]
|
44
|
+
XML2_HEADER_DIRS = [File.join(INCLUDEDIR, "libxml2"), INCLUDEDIR]
|
33
45
|
|
34
|
-
|
35
|
-
|
36
|
-
|
46
|
+
else
|
47
|
+
lib_prefix = ''
|
48
|
+
|
49
|
+
HEADER_DIRS = [
|
50
|
+
# First search /opt/local for macports
|
51
|
+
'/opt/local/include',
|
37
52
|
|
38
|
-
|
39
|
-
|
53
|
+
# Then search /usr/local for people that installed from source
|
54
|
+
'/usr/local/include',
|
40
55
|
|
41
|
-
|
42
|
-
|
56
|
+
# Check the ruby install locations
|
57
|
+
INCLUDEDIR,
|
43
58
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
]
|
59
|
+
# Finally fall back to /usr
|
60
|
+
'/usr/include',
|
61
|
+
'/usr/include/libxml2',
|
62
|
+
]
|
48
63
|
|
49
|
-
LIB_DIRS = [
|
50
|
-
|
51
|
-
|
64
|
+
LIB_DIRS = [
|
65
|
+
# First search /opt/local for macports
|
66
|
+
'/opt/local/lib',
|
52
67
|
|
53
|
-
|
54
|
-
|
68
|
+
# Then search /usr/local for people that installed from source
|
69
|
+
'/usr/local/lib',
|
55
70
|
|
56
|
-
|
57
|
-
|
71
|
+
# Check the ruby install locations
|
72
|
+
LIBDIR,
|
58
73
|
|
59
|
-
|
60
|
-
|
61
|
-
]
|
74
|
+
# Finally fall back to /usr
|
75
|
+
'/usr/lib',
|
76
|
+
]
|
77
|
+
|
78
|
+
XML2_HEADER_DIRS = [
|
79
|
+
'/opt/local/include/libxml2',
|
80
|
+
'/usr/local/include/libxml2',
|
81
|
+
File.join(INCLUDEDIR, "libxml2")
|
82
|
+
] + HEADER_DIRS
|
83
|
+
end
|
62
84
|
|
63
85
|
dir_config('zlib', HEADER_DIRS, LIB_DIRS)
|
64
86
|
dir_config('iconv', HEADER_DIRS, LIB_DIRS)
|
65
|
-
dir_config('xml2',
|
66
|
-
'/opt/local/include/libxml2',
|
67
|
-
'/usr/local/include/libxml2',
|
68
|
-
File.join(INCLUDEDIR, "libxml2")] + HEADER_DIRS, LIB_DIRS)
|
87
|
+
dir_config('xml2', XML2_HEADER_DIRS, LIB_DIRS)
|
69
88
|
dir_config('xslt', HEADER_DIRS, LIB_DIRS)
|
70
89
|
|
71
90
|
def asplode(lib)
|
72
91
|
abort "-----\n#{lib} is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.\n-----"
|
73
92
|
end
|
74
93
|
|
75
|
-
|
94
|
+
# Use this with cross compiling
|
95
|
+
# PKG_CONFIG_PATH=/Users/apatterson/git/nokogiri/tmp/cross/lib/pkgconfig/ \
|
96
|
+
# rake cross compile RUBY_CC_VERSION=1.9.1
|
97
|
+
pkg_config('libxslt') if RUBY_PLATFORM =~ /mingw/
|
98
|
+
|
76
99
|
asplode "libxml2" unless find_header('libxml/parser.h')
|
77
100
|
asplode "libxslt" unless find_header('libxslt/xslt.h')
|
78
101
|
asplode "libexslt" unless find_header('libexslt/exslt.h')
|
79
|
-
asplode "
|
80
|
-
asplode "
|
81
|
-
asplode "
|
82
|
-
|
102
|
+
asplode "libxml2" unless find_library("#{lib_prefix}xml2", 'xmlParseDoc')
|
103
|
+
asplode "libxslt" unless find_library("#{lib_prefix}xslt", 'xsltParseStylesheetDoc')
|
104
|
+
asplode "libexslt" unless find_library("#{lib_prefix}exslt", 'exsltFuncRegister')
|
105
|
+
|
106
|
+
unless have_func('xmlHasFeature')
|
107
|
+
abort "-----\nThe function 'xmlHasFeature' is missing from your installation of libxml2. Likely this means that your installed version of libxml2 is old enough that nokogiri will not work well. To get around this problem, please upgrade your installation of libxml2.
|
108
|
+
|
109
|
+
Please visit http://nokogiri.org/tutorials/installing_nokogiri.html for more help!"
|
110
|
+
end
|
83
111
|
|
112
|
+
have_func 'xmlFirstElementChild'
|
84
113
|
have_func('xmlRelaxNGSetParserStructuredErrors')
|
85
114
|
have_func('xmlRelaxNGSetParserStructuredErrors')
|
86
115
|
have_func('xmlRelaxNGSetValidStructuredErrors')
|