nokogiri-backport 1.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/LICENSE-DEPENDENCIES.md +1682 -0
- data/LICENSE.md +9 -0
- data/README.md +272 -0
- data/bin/nokogiri +118 -0
- data/dependencies.yml +74 -0
- data/ext/java/nokogiri/EncodingHandler.java +124 -0
- data/ext/java/nokogiri/HtmlDocument.java +178 -0
- data/ext/java/nokogiri/HtmlElementDescription.java +148 -0
- data/ext/java/nokogiri/HtmlEntityLookup.java +79 -0
- data/ext/java/nokogiri/HtmlSaxParserContext.java +282 -0
- data/ext/java/nokogiri/HtmlSaxPushParser.java +222 -0
- data/ext/java/nokogiri/NokogiriService.java +597 -0
- data/ext/java/nokogiri/XmlAttr.java +162 -0
- data/ext/java/nokogiri/XmlAttributeDecl.java +129 -0
- data/ext/java/nokogiri/XmlCdata.java +82 -0
- data/ext/java/nokogiri/XmlComment.java +97 -0
- data/ext/java/nokogiri/XmlDocument.java +633 -0
- data/ext/java/nokogiri/XmlDocumentFragment.java +185 -0
- data/ext/java/nokogiri/XmlDtd.java +481 -0
- data/ext/java/nokogiri/XmlElement.java +68 -0
- data/ext/java/nokogiri/XmlElementContent.java +382 -0
- data/ext/java/nokogiri/XmlElementDecl.java +147 -0
- data/ext/java/nokogiri/XmlEntityDecl.java +157 -0
- data/ext/java/nokogiri/XmlEntityReference.java +101 -0
- data/ext/java/nokogiri/XmlNamespace.java +199 -0
- data/ext/java/nokogiri/XmlNode.java +1684 -0
- data/ext/java/nokogiri/XmlNodeSet.java +434 -0
- data/ext/java/nokogiri/XmlProcessingInstruction.java +100 -0
- data/ext/java/nokogiri/XmlReader.java +531 -0
- data/ext/java/nokogiri/XmlRelaxng.java +151 -0
- data/ext/java/nokogiri/XmlSaxParserContext.java +374 -0
- data/ext/java/nokogiri/XmlSaxPushParser.java +286 -0
- data/ext/java/nokogiri/XmlSchema.java +388 -0
- data/ext/java/nokogiri/XmlSyntaxError.java +138 -0
- data/ext/java/nokogiri/XmlText.java +110 -0
- data/ext/java/nokogiri/XmlXpathContext.java +301 -0
- data/ext/java/nokogiri/XsltStylesheet.java +347 -0
- data/ext/java/nokogiri/internals/ClosedStreamException.java +10 -0
- data/ext/java/nokogiri/internals/HtmlDomParserContext.java +252 -0
- data/ext/java/nokogiri/internals/IgnoreSchemaErrorsErrorHandler.java +20 -0
- data/ext/java/nokogiri/internals/NokogiriBlockingQueueInputStream.java +151 -0
- data/ext/java/nokogiri/internals/NokogiriDomParser.java +116 -0
- data/ext/java/nokogiri/internals/NokogiriEntityResolver.java +121 -0
- data/ext/java/nokogiri/internals/NokogiriErrorHandler.java +69 -0
- data/ext/java/nokogiri/internals/NokogiriHandler.java +327 -0
- data/ext/java/nokogiri/internals/NokogiriHelpers.java +734 -0
- data/ext/java/nokogiri/internals/NokogiriNamespaceCache.java +217 -0
- data/ext/java/nokogiri/internals/NokogiriNamespaceContext.java +127 -0
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java +100 -0
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java +121 -0
- data/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java +78 -0
- data/ext/java/nokogiri/internals/NokogiriXPathFunction.java +180 -0
- data/ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java +72 -0
- data/ext/java/nokogiri/internals/NokogiriXPathVariableResolver.java +60 -0
- data/ext/java/nokogiri/internals/NokogiriXsltErrorListener.java +87 -0
- data/ext/java/nokogiri/internals/ParserContext.java +259 -0
- data/ext/java/nokogiri/internals/ReaderNode.java +488 -0
- data/ext/java/nokogiri/internals/SaveContextVisitor.java +778 -0
- data/ext/java/nokogiri/internals/SchemaErrorHandler.java +73 -0
- data/ext/java/nokogiri/internals/XalanDTMManagerPatch.java +168 -0
- data/ext/java/nokogiri/internals/XmlDeclHandler.java +42 -0
- data/ext/java/nokogiri/internals/XmlDomParserContext.java +274 -0
- data/ext/java/nokogiri/internals/XmlSaxParser.java +65 -0
- data/ext/java/nokogiri/internals/c14n/AttrCompare.java +119 -0
- data/ext/java/nokogiri/internals/c14n/C14nHelper.java +159 -0
- data/ext/java/nokogiri/internals/c14n/CanonicalFilter.java +37 -0
- data/ext/java/nokogiri/internals/c14n/CanonicalizationException.java +93 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer.java +252 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer11.java +639 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer11_OmitComments.java +38 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer11_WithComments.java +38 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315.java +367 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315Excl.java +295 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclOmitComments.java +40 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclWithComments.java +44 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315OmitComments.java +44 -0
- data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315WithComments.java +43 -0
- data/ext/java/nokogiri/internals/c14n/CanonicalizerBase.java +630 -0
- data/ext/java/nokogiri/internals/c14n/CanonicalizerPhysical.java +173 -0
- data/ext/java/nokogiri/internals/c14n/CanonicalizerSpi.java +76 -0
- data/ext/java/nokogiri/internals/c14n/Constants.java +42 -0
- data/ext/java/nokogiri/internals/c14n/ElementProxy.java +293 -0
- data/ext/java/nokogiri/internals/c14n/HelperNodeList.java +93 -0
- data/ext/java/nokogiri/internals/c14n/IgnoreAllErrorHandler.java +79 -0
- data/ext/java/nokogiri/internals/c14n/InclusiveNamespaces.java +166 -0
- data/ext/java/nokogiri/internals/c14n/InvalidCanonicalizerException.java +76 -0
- data/ext/java/nokogiri/internals/c14n/NameSpaceSymbTable.java +402 -0
- data/ext/java/nokogiri/internals/c14n/NodeFilter.java +51 -0
- data/ext/java/nokogiri/internals/c14n/UtfHelpper.java +179 -0
- data/ext/java/nokogiri/internals/c14n/XMLUtils.java +507 -0
- data/ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java +1745 -0
- data/ext/java/nokogiri/internals/dom2dtm/DOM2DTMdefaultNamespaceDeclarationNode.java +685 -0
- data/ext/nokogiri/depend +477 -0
- data/ext/nokogiri/extconf.rb +836 -0
- data/ext/nokogiri/html_document.c +171 -0
- data/ext/nokogiri/html_document.h +10 -0
- data/ext/nokogiri/html_element_description.c +279 -0
- data/ext/nokogiri/html_element_description.h +10 -0
- data/ext/nokogiri/html_entity_lookup.c +32 -0
- data/ext/nokogiri/html_entity_lookup.h +8 -0
- data/ext/nokogiri/html_sax_parser_context.c +116 -0
- data/ext/nokogiri/html_sax_parser_context.h +11 -0
- data/ext/nokogiri/html_sax_push_parser.c +87 -0
- data/ext/nokogiri/html_sax_push_parser.h +9 -0
- data/ext/nokogiri/nokogiri.c +135 -0
- data/ext/nokogiri/nokogiri.h +130 -0
- data/ext/nokogiri/xml_attr.c +103 -0
- data/ext/nokogiri/xml_attr.h +9 -0
- data/ext/nokogiri/xml_attribute_decl.c +70 -0
- data/ext/nokogiri/xml_attribute_decl.h +9 -0
- data/ext/nokogiri/xml_cdata.c +62 -0
- data/ext/nokogiri/xml_cdata.h +9 -0
- data/ext/nokogiri/xml_comment.c +69 -0
- data/ext/nokogiri/xml_comment.h +9 -0
- data/ext/nokogiri/xml_document.c +622 -0
- data/ext/nokogiri/xml_document.h +23 -0
- data/ext/nokogiri/xml_document_fragment.c +48 -0
- data/ext/nokogiri/xml_document_fragment.h +10 -0
- data/ext/nokogiri/xml_dtd.c +202 -0
- data/ext/nokogiri/xml_dtd.h +10 -0
- data/ext/nokogiri/xml_element_content.c +123 -0
- data/ext/nokogiri/xml_element_content.h +10 -0
- data/ext/nokogiri/xml_element_decl.c +69 -0
- data/ext/nokogiri/xml_element_decl.h +9 -0
- data/ext/nokogiri/xml_encoding_handler.c +79 -0
- data/ext/nokogiri/xml_encoding_handler.h +8 -0
- data/ext/nokogiri/xml_entity_decl.c +110 -0
- data/ext/nokogiri/xml_entity_decl.h +10 -0
- data/ext/nokogiri/xml_entity_reference.c +52 -0
- data/ext/nokogiri/xml_entity_reference.h +9 -0
- data/ext/nokogiri/xml_io.c +63 -0
- data/ext/nokogiri/xml_io.h +11 -0
- data/ext/nokogiri/xml_libxml2_hacks.c +112 -0
- data/ext/nokogiri/xml_libxml2_hacks.h +12 -0
- data/ext/nokogiri/xml_namespace.c +111 -0
- data/ext/nokogiri/xml_namespace.h +14 -0
- data/ext/nokogiri/xml_node.c +1773 -0
- data/ext/nokogiri/xml_node.h +13 -0
- data/ext/nokogiri/xml_node_set.c +486 -0
- data/ext/nokogiri/xml_node_set.h +12 -0
- data/ext/nokogiri/xml_processing_instruction.c +56 -0
- data/ext/nokogiri/xml_processing_instruction.h +9 -0
- data/ext/nokogiri/xml_reader.c +657 -0
- data/ext/nokogiri/xml_reader.h +10 -0
- data/ext/nokogiri/xml_relax_ng.c +179 -0
- data/ext/nokogiri/xml_relax_ng.h +9 -0
- data/ext/nokogiri/xml_sax_parser.c +305 -0
- data/ext/nokogiri/xml_sax_parser.h +39 -0
- data/ext/nokogiri/xml_sax_parser_context.c +262 -0
- data/ext/nokogiri/xml_sax_parser_context.h +10 -0
- data/ext/nokogiri/xml_sax_push_parser.c +159 -0
- data/ext/nokogiri/xml_sax_push_parser.h +9 -0
- data/ext/nokogiri/xml_schema.c +276 -0
- data/ext/nokogiri/xml_schema.h +9 -0
- data/ext/nokogiri/xml_syntax_error.c +64 -0
- data/ext/nokogiri/xml_syntax_error.h +13 -0
- data/ext/nokogiri/xml_text.c +52 -0
- data/ext/nokogiri/xml_text.h +9 -0
- data/ext/nokogiri/xml_xpath_context.c +374 -0
- data/ext/nokogiri/xml_xpath_context.h +10 -0
- data/ext/nokogiri/xslt_stylesheet.c +263 -0
- data/ext/nokogiri/xslt_stylesheet.h +14 -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/css/node.rb +53 -0
- data/lib/nokogiri/css/parser.rb +751 -0
- data/lib/nokogiri/css/parser.y +272 -0
- data/lib/nokogiri/css/parser_extras.rb +94 -0
- data/lib/nokogiri/css/syntax_error.rb +8 -0
- data/lib/nokogiri/css/tokenizer.rb +154 -0
- data/lib/nokogiri/css/tokenizer.rex +55 -0
- data/lib/nokogiri/css/xpath_visitor.rb +260 -0
- data/lib/nokogiri/css.rb +28 -0
- data/lib/nokogiri/decorators/slop.rb +43 -0
- data/lib/nokogiri/html/builder.rb +36 -0
- data/lib/nokogiri/html/document.rb +322 -0
- data/lib/nokogiri/html/document_fragment.rb +50 -0
- data/lib/nokogiri/html/element_description.rb +24 -0
- data/lib/nokogiri/html/element_description_defaults.rb +672 -0
- data/lib/nokogiri/html/entity_lookup.rb +14 -0
- data/lib/nokogiri/html/sax/parser.rb +63 -0
- data/lib/nokogiri/html/sax/parser_context.rb +17 -0
- data/lib/nokogiri/html/sax/push_parser.rb +37 -0
- data/lib/nokogiri/html.rb +38 -0
- data/lib/nokogiri/jruby/dependencies.rb +20 -0
- data/lib/nokogiri/syntax_error.rb +5 -0
- data/lib/nokogiri/version/constant.rb +5 -0
- data/lib/nokogiri/version/info.rb +182 -0
- data/lib/nokogiri/version.rb +3 -0
- data/lib/nokogiri/xml/attr.rb +15 -0
- data/lib/nokogiri/xml/attribute_decl.rb +19 -0
- data/lib/nokogiri/xml/builder.rb +447 -0
- data/lib/nokogiri/xml/cdata.rb +12 -0
- data/lib/nokogiri/xml/character_data.rb +8 -0
- data/lib/nokogiri/xml/document.rb +290 -0
- data/lib/nokogiri/xml/document_fragment.rb +159 -0
- data/lib/nokogiri/xml/dtd.rb +33 -0
- data/lib/nokogiri/xml/element_content.rb +37 -0
- data/lib/nokogiri/xml/element_decl.rb +14 -0
- data/lib/nokogiri/xml/entity_decl.rb +20 -0
- data/lib/nokogiri/xml/entity_reference.rb +19 -0
- data/lib/nokogiri/xml/namespace.rb +14 -0
- data/lib/nokogiri/xml/node/save_options.rb +62 -0
- data/lib/nokogiri/xml/node.rb +1240 -0
- data/lib/nokogiri/xml/node_set.rb +372 -0
- data/lib/nokogiri/xml/notation.rb +7 -0
- data/lib/nokogiri/xml/parse_options.rb +127 -0
- data/lib/nokogiri/xml/pp/character_data.rb +19 -0
- data/lib/nokogiri/xml/pp/node.rb +57 -0
- data/lib/nokogiri/xml/pp.rb +3 -0
- data/lib/nokogiri/xml/processing_instruction.rb +9 -0
- data/lib/nokogiri/xml/reader.rb +116 -0
- data/lib/nokogiri/xml/relax_ng.rb +37 -0
- data/lib/nokogiri/xml/sax/document.rb +172 -0
- data/lib/nokogiri/xml/sax/parser.rb +123 -0
- data/lib/nokogiri/xml/sax/parser_context.rb +17 -0
- data/lib/nokogiri/xml/sax/push_parser.rb +61 -0
- data/lib/nokogiri/xml/sax.rb +5 -0
- data/lib/nokogiri/xml/schema.rb +72 -0
- data/lib/nokogiri/xml/searchable.rb +239 -0
- data/lib/nokogiri/xml/syntax_error.rb +71 -0
- data/lib/nokogiri/xml/text.rb +10 -0
- data/lib/nokogiri/xml/xpath/syntax_error.rb +12 -0
- data/lib/nokogiri/xml/xpath.rb +11 -0
- data/lib/nokogiri/xml/xpath_context.rb +17 -0
- data/lib/nokogiri/xml.rb +76 -0
- data/lib/nokogiri/xslt/stylesheet.rb +26 -0
- data/lib/nokogiri/xslt.rb +57 -0
- data/lib/nokogiri.rb +144 -0
- data/lib/serializer.jar +0 -0
- data/lib/xalan.jar +0 -0
- data/lib/xercesImpl.jar +0 -0
- data/lib/xml-apis.jar +0 -0
- data/lib/xsd/xmlparser/nokogiri.rb +103 -0
- metadata +531 -0
@@ -0,0 +1,262 @@
|
|
1
|
+
#include <xml_sax_parser_context.h>
|
2
|
+
|
3
|
+
VALUE cNokogiriXmlSaxParserContext ;
|
4
|
+
|
5
|
+
static void deallocate(xmlParserCtxtPtr ctxt)
|
6
|
+
{
|
7
|
+
NOKOGIRI_DEBUG_START(ctxt);
|
8
|
+
|
9
|
+
ctxt->sax = NULL;
|
10
|
+
|
11
|
+
xmlFreeParserCtxt(ctxt);
|
12
|
+
|
13
|
+
NOKOGIRI_DEBUG_END(ctxt);
|
14
|
+
}
|
15
|
+
|
16
|
+
/*
|
17
|
+
* call-seq:
|
18
|
+
* parse_io(io, encoding)
|
19
|
+
*
|
20
|
+
* Parse +io+ object with +encoding+
|
21
|
+
*/
|
22
|
+
static VALUE
|
23
|
+
parse_io(VALUE klass, VALUE io, VALUE encoding)
|
24
|
+
{
|
25
|
+
xmlParserCtxtPtr ctxt;
|
26
|
+
xmlCharEncoding enc = (xmlCharEncoding)NUM2INT(encoding);
|
27
|
+
|
28
|
+
ctxt = xmlCreateIOParserCtxt(NULL, NULL,
|
29
|
+
(xmlInputReadCallback)io_read_callback,
|
30
|
+
(xmlInputCloseCallback)io_close_callback,
|
31
|
+
(void *)io, enc);
|
32
|
+
if (ctxt->sax) {
|
33
|
+
xmlFree(ctxt->sax);
|
34
|
+
ctxt->sax = NULL;
|
35
|
+
}
|
36
|
+
|
37
|
+
return Data_Wrap_Struct(klass, NULL, deallocate, ctxt);
|
38
|
+
}
|
39
|
+
|
40
|
+
/*
|
41
|
+
* call-seq:
|
42
|
+
* parse_file(filename)
|
43
|
+
*
|
44
|
+
* Parse file given +filename+
|
45
|
+
*/
|
46
|
+
static VALUE parse_file(VALUE klass, VALUE filename)
|
47
|
+
{
|
48
|
+
xmlParserCtxtPtr ctxt = xmlCreateFileParserCtxt(StringValueCStr(filename));
|
49
|
+
return Data_Wrap_Struct(klass, NULL, deallocate, ctxt);
|
50
|
+
}
|
51
|
+
|
52
|
+
/*
|
53
|
+
* call-seq:
|
54
|
+
* parse_memory(data)
|
55
|
+
*
|
56
|
+
* Parse the XML stored in memory in +data+
|
57
|
+
*/
|
58
|
+
static VALUE
|
59
|
+
parse_memory(VALUE klass, VALUE data)
|
60
|
+
{
|
61
|
+
xmlParserCtxtPtr ctxt;
|
62
|
+
|
63
|
+
if (NIL_P(data))
|
64
|
+
rb_raise(rb_eArgError, "data cannot be nil");
|
65
|
+
if (!(int)RSTRING_LEN(data))
|
66
|
+
rb_raise(rb_eRuntimeError, "data cannot be empty");
|
67
|
+
|
68
|
+
ctxt = xmlCreateMemoryParserCtxt(StringValuePtr(data),
|
69
|
+
(int)RSTRING_LEN(data));
|
70
|
+
if (ctxt->sax) {
|
71
|
+
xmlFree(ctxt->sax);
|
72
|
+
ctxt->sax = NULL;
|
73
|
+
}
|
74
|
+
|
75
|
+
return Data_Wrap_Struct(klass, NULL, deallocate, ctxt);
|
76
|
+
}
|
77
|
+
|
78
|
+
static VALUE
|
79
|
+
parse_doc(VALUE ctxt_val)
|
80
|
+
{
|
81
|
+
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctxt_val;
|
82
|
+
xmlParseDocument(ctxt);
|
83
|
+
return Qnil;
|
84
|
+
}
|
85
|
+
|
86
|
+
static VALUE
|
87
|
+
parse_doc_finalize(VALUE ctxt_val)
|
88
|
+
{
|
89
|
+
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr)ctxt_val;
|
90
|
+
|
91
|
+
if (NULL != ctxt->myDoc)
|
92
|
+
xmlFreeDoc(ctxt->myDoc);
|
93
|
+
|
94
|
+
NOKOGIRI_SAX_TUPLE_DESTROY(ctxt->userData);
|
95
|
+
return Qnil;
|
96
|
+
}
|
97
|
+
|
98
|
+
/*
|
99
|
+
* call-seq:
|
100
|
+
* parse_with(sax_handler)
|
101
|
+
*
|
102
|
+
* Use +sax_handler+ and parse the current document
|
103
|
+
*/
|
104
|
+
static VALUE
|
105
|
+
parse_with(VALUE self, VALUE sax_handler)
|
106
|
+
{
|
107
|
+
xmlParserCtxtPtr ctxt;
|
108
|
+
xmlSAXHandlerPtr sax;
|
109
|
+
|
110
|
+
if (!rb_obj_is_kind_of(sax_handler, cNokogiriXmlSaxParser))
|
111
|
+
rb_raise(rb_eArgError, "argument must be a Nokogiri::XML::SAX::Parser");
|
112
|
+
|
113
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
114
|
+
Data_Get_Struct(sax_handler, xmlSAXHandler, sax);
|
115
|
+
|
116
|
+
/* Free the sax handler since we'll assign our own */
|
117
|
+
if (ctxt->sax && ctxt->sax != (xmlSAXHandlerPtr)&xmlDefaultSAXHandler)
|
118
|
+
xmlFree(ctxt->sax);
|
119
|
+
|
120
|
+
ctxt->sax = sax;
|
121
|
+
ctxt->userData = (void *)NOKOGIRI_SAX_TUPLE_NEW(ctxt, sax_handler);
|
122
|
+
|
123
|
+
rb_ensure(parse_doc, (VALUE)ctxt, parse_doc_finalize, (VALUE)ctxt);
|
124
|
+
|
125
|
+
return Qnil;
|
126
|
+
}
|
127
|
+
|
128
|
+
/*
|
129
|
+
* call-seq:
|
130
|
+
* replace_entities=(boolean)
|
131
|
+
*
|
132
|
+
* Should this parser replace entities? & will get converted to '&' if
|
133
|
+
* set to true
|
134
|
+
*/
|
135
|
+
static VALUE set_replace_entities(VALUE self, VALUE value)
|
136
|
+
{
|
137
|
+
xmlParserCtxtPtr ctxt;
|
138
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
139
|
+
|
140
|
+
if(Qfalse == value)
|
141
|
+
ctxt->replaceEntities = 0;
|
142
|
+
else
|
143
|
+
ctxt->replaceEntities = 1;
|
144
|
+
|
145
|
+
return value;
|
146
|
+
}
|
147
|
+
|
148
|
+
/*
|
149
|
+
* call-seq:
|
150
|
+
* replace_entities
|
151
|
+
*
|
152
|
+
* Should this parser replace entities? & will get converted to '&' if
|
153
|
+
* set to true
|
154
|
+
*/
|
155
|
+
static VALUE get_replace_entities(VALUE self)
|
156
|
+
{
|
157
|
+
xmlParserCtxtPtr ctxt;
|
158
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
159
|
+
|
160
|
+
if(0 == ctxt->replaceEntities)
|
161
|
+
return Qfalse;
|
162
|
+
else
|
163
|
+
return Qtrue;
|
164
|
+
}
|
165
|
+
|
166
|
+
/*
|
167
|
+
* call-seq: line
|
168
|
+
*
|
169
|
+
* Get the current line the parser context is processing.
|
170
|
+
*/
|
171
|
+
static VALUE line(VALUE self)
|
172
|
+
{
|
173
|
+
xmlParserCtxtPtr ctxt;
|
174
|
+
xmlParserInputPtr io;
|
175
|
+
|
176
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
177
|
+
|
178
|
+
io = ctxt->input;
|
179
|
+
if(io)
|
180
|
+
return INT2NUM(io->line);
|
181
|
+
|
182
|
+
return Qnil;
|
183
|
+
}
|
184
|
+
|
185
|
+
/*
|
186
|
+
* call-seq: column
|
187
|
+
*
|
188
|
+
* Get the current column the parser context is processing.
|
189
|
+
*/
|
190
|
+
static VALUE column(VALUE self)
|
191
|
+
{
|
192
|
+
xmlParserCtxtPtr ctxt;
|
193
|
+
xmlParserInputPtr io;
|
194
|
+
|
195
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
196
|
+
|
197
|
+
io = ctxt->input;
|
198
|
+
if(io)
|
199
|
+
return INT2NUM(io->col);
|
200
|
+
|
201
|
+
return Qnil;
|
202
|
+
}
|
203
|
+
|
204
|
+
/*
|
205
|
+
* call-seq:
|
206
|
+
* recovery=(boolean)
|
207
|
+
*
|
208
|
+
* Should this parser recover from structural errors? It will not stop processing
|
209
|
+
* file on structural errors if set to true
|
210
|
+
*/
|
211
|
+
static VALUE set_recovery(VALUE self, VALUE value)
|
212
|
+
{
|
213
|
+
xmlParserCtxtPtr ctxt;
|
214
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
215
|
+
|
216
|
+
if(value == Qfalse)
|
217
|
+
ctxt->recovery = 0;
|
218
|
+
else
|
219
|
+
ctxt->recovery = 1;
|
220
|
+
|
221
|
+
return value;
|
222
|
+
}
|
223
|
+
|
224
|
+
/*
|
225
|
+
* call-seq:
|
226
|
+
* recovery
|
227
|
+
*
|
228
|
+
* Should this parser recover from structural errors? It will not stop processing
|
229
|
+
* file on structural errors if set to true
|
230
|
+
*/
|
231
|
+
static VALUE get_recovery(VALUE self)
|
232
|
+
{
|
233
|
+
xmlParserCtxtPtr ctxt;
|
234
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
235
|
+
|
236
|
+
if(ctxt->recovery == 0)
|
237
|
+
return Qfalse;
|
238
|
+
else
|
239
|
+
return Qtrue;
|
240
|
+
}
|
241
|
+
|
242
|
+
void init_xml_sax_parser_context()
|
243
|
+
{
|
244
|
+
VALUE nokogiri = rb_define_module("Nokogiri");
|
245
|
+
VALUE xml = rb_define_module_under(nokogiri, "XML");
|
246
|
+
VALUE sax = rb_define_module_under(xml, "SAX");
|
247
|
+
VALUE klass = rb_define_class_under(sax, "ParserContext", rb_cObject);
|
248
|
+
|
249
|
+
cNokogiriXmlSaxParserContext = klass;
|
250
|
+
|
251
|
+
rb_define_singleton_method(klass, "io", parse_io, 2);
|
252
|
+
rb_define_singleton_method(klass, "memory", parse_memory, 1);
|
253
|
+
rb_define_singleton_method(klass, "file", parse_file, 1);
|
254
|
+
|
255
|
+
rb_define_method(klass, "parse_with", parse_with, 1);
|
256
|
+
rb_define_method(klass, "replace_entities=", set_replace_entities, 1);
|
257
|
+
rb_define_method(klass, "replace_entities", get_replace_entities, 0);
|
258
|
+
rb_define_method(klass, "recovery=", set_recovery, 1);
|
259
|
+
rb_define_method(klass, "recovery", get_recovery, 0);
|
260
|
+
rb_define_method(klass, "line", line, 0);
|
261
|
+
rb_define_method(klass, "column", column, 0);
|
262
|
+
}
|
@@ -0,0 +1,159 @@
|
|
1
|
+
#include <xml_sax_push_parser.h>
|
2
|
+
|
3
|
+
static void deallocate(xmlParserCtxtPtr ctx)
|
4
|
+
{
|
5
|
+
NOKOGIRI_DEBUG_START(ctx);
|
6
|
+
if (ctx != NULL) {
|
7
|
+
NOKOGIRI_SAX_TUPLE_DESTROY(ctx->userData);
|
8
|
+
xmlFreeParserCtxt(ctx);
|
9
|
+
}
|
10
|
+
NOKOGIRI_DEBUG_END(ctx);
|
11
|
+
}
|
12
|
+
|
13
|
+
static VALUE allocate(VALUE klass)
|
14
|
+
{
|
15
|
+
return Data_Wrap_Struct(klass, NULL, deallocate, NULL);
|
16
|
+
}
|
17
|
+
|
18
|
+
/*
|
19
|
+
* call-seq:
|
20
|
+
* native_write(chunk, last_chunk)
|
21
|
+
*
|
22
|
+
* Write +chunk+ to PushParser. +last_chunk+ triggers the end_document handle
|
23
|
+
*/
|
24
|
+
static VALUE native_write(VALUE self, VALUE _chunk, VALUE _last_chunk)
|
25
|
+
{
|
26
|
+
xmlParserCtxtPtr ctx;
|
27
|
+
const char * chunk = NULL;
|
28
|
+
int size = 0;
|
29
|
+
|
30
|
+
|
31
|
+
Data_Get_Struct(self, xmlParserCtxt, ctx);
|
32
|
+
|
33
|
+
if (Qnil != _chunk) {
|
34
|
+
chunk = StringValuePtr(_chunk);
|
35
|
+
size = (int)RSTRING_LEN(_chunk);
|
36
|
+
}
|
37
|
+
|
38
|
+
if (xmlParseChunk(ctx, chunk, size, Qtrue == _last_chunk ? 1 : 0)) {
|
39
|
+
if (!(ctx->options & XML_PARSE_RECOVER)) {
|
40
|
+
xmlErrorPtr e = xmlCtxtGetLastError(ctx);
|
41
|
+
Nokogiri_error_raise(NULL, e);
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
return self;
|
46
|
+
}
|
47
|
+
|
48
|
+
/*
|
49
|
+
* call-seq:
|
50
|
+
* initialize_native(xml_sax, filename)
|
51
|
+
*
|
52
|
+
* Initialize the push parser with +xml_sax+ using +filename+
|
53
|
+
*/
|
54
|
+
static VALUE initialize_native(VALUE self, VALUE _xml_sax, VALUE _filename)
|
55
|
+
{
|
56
|
+
xmlSAXHandlerPtr sax;
|
57
|
+
const char * filename = NULL;
|
58
|
+
xmlParserCtxtPtr ctx;
|
59
|
+
|
60
|
+
Data_Get_Struct(_xml_sax, xmlSAXHandler, sax);
|
61
|
+
|
62
|
+
if (_filename != Qnil) { filename = StringValueCStr(_filename); }
|
63
|
+
|
64
|
+
ctx = xmlCreatePushParserCtxt(
|
65
|
+
sax,
|
66
|
+
NULL,
|
67
|
+
NULL,
|
68
|
+
0,
|
69
|
+
filename
|
70
|
+
);
|
71
|
+
if (ctx == NULL) {
|
72
|
+
rb_raise(rb_eRuntimeError, "Could not create a parser context");
|
73
|
+
}
|
74
|
+
|
75
|
+
ctx->userData = NOKOGIRI_SAX_TUPLE_NEW(ctx, self);
|
76
|
+
|
77
|
+
ctx->sax2 = 1;
|
78
|
+
DATA_PTR(self) = ctx;
|
79
|
+
return self;
|
80
|
+
}
|
81
|
+
|
82
|
+
static VALUE get_options(VALUE self)
|
83
|
+
{
|
84
|
+
xmlParserCtxtPtr ctx;
|
85
|
+
Data_Get_Struct(self, xmlParserCtxt, ctx);
|
86
|
+
|
87
|
+
return INT2NUM(ctx->options);
|
88
|
+
}
|
89
|
+
|
90
|
+
static VALUE set_options(VALUE self, VALUE options)
|
91
|
+
{
|
92
|
+
xmlParserCtxtPtr ctx;
|
93
|
+
Data_Get_Struct(self, xmlParserCtxt, ctx);
|
94
|
+
|
95
|
+
if (xmlCtxtUseOptions(ctx, (int)NUM2INT(options)) != 0) {
|
96
|
+
rb_raise(rb_eRuntimeError, "Cannot set XML parser context options");
|
97
|
+
}
|
98
|
+
|
99
|
+
return Qnil;
|
100
|
+
}
|
101
|
+
|
102
|
+
/*
|
103
|
+
* call-seq:
|
104
|
+
* replace_entities
|
105
|
+
*
|
106
|
+
* Should this parser replace entities? & will get converted to '&' if
|
107
|
+
* set to true
|
108
|
+
*/
|
109
|
+
static VALUE get_replace_entities(VALUE self)
|
110
|
+
{
|
111
|
+
xmlParserCtxtPtr ctx;
|
112
|
+
Data_Get_Struct(self, xmlParserCtxt, ctx);
|
113
|
+
|
114
|
+
if (0 == ctx->replaceEntities) {
|
115
|
+
return Qfalse;
|
116
|
+
} else {
|
117
|
+
return Qtrue;
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
/*
|
122
|
+
* call-seq:
|
123
|
+
* replace_entities=(boolean)
|
124
|
+
*
|
125
|
+
* Should this parser replace entities? & will get converted to '&' if
|
126
|
+
* set to true
|
127
|
+
*/
|
128
|
+
static VALUE set_replace_entities(VALUE self, VALUE value)
|
129
|
+
{
|
130
|
+
xmlParserCtxtPtr ctx;
|
131
|
+
Data_Get_Struct(self, xmlParserCtxt, ctx);
|
132
|
+
|
133
|
+
if (Qfalse == value) {
|
134
|
+
ctx->replaceEntities = 0;
|
135
|
+
} else {
|
136
|
+
ctx->replaceEntities = 1;
|
137
|
+
}
|
138
|
+
|
139
|
+
return value;
|
140
|
+
}
|
141
|
+
|
142
|
+
VALUE cNokogiriXmlSaxPushParser ;
|
143
|
+
void init_xml_sax_push_parser()
|
144
|
+
{
|
145
|
+
VALUE nokogiri = rb_define_module("Nokogiri");
|
146
|
+
VALUE xml = rb_define_module_under(nokogiri, "XML");
|
147
|
+
VALUE sax = rb_define_module_under(xml, "SAX");
|
148
|
+
VALUE klass = rb_define_class_under(sax, "PushParser", rb_cObject);
|
149
|
+
|
150
|
+
cNokogiriXmlSaxPushParser = klass;
|
151
|
+
|
152
|
+
rb_define_alloc_func(klass, allocate);
|
153
|
+
rb_define_private_method(klass, "initialize_native", initialize_native, 2);
|
154
|
+
rb_define_private_method(klass, "native_write", native_write, 2);
|
155
|
+
rb_define_method(klass, "options", get_options, 0);
|
156
|
+
rb_define_method(klass, "options=", set_options, 1);
|
157
|
+
rb_define_method(klass, "replace_entities", get_replace_entities, 0);
|
158
|
+
rb_define_method(klass, "replace_entities=", set_replace_entities, 1);
|
159
|
+
}
|
@@ -0,0 +1,276 @@
|
|
1
|
+
#include <xml_schema.h>
|
2
|
+
|
3
|
+
static void dealloc(xmlSchemaPtr schema)
|
4
|
+
{
|
5
|
+
NOKOGIRI_DEBUG_START(schema);
|
6
|
+
xmlSchemaFree(schema);
|
7
|
+
NOKOGIRI_DEBUG_END(schema);
|
8
|
+
}
|
9
|
+
|
10
|
+
/*
|
11
|
+
* call-seq:
|
12
|
+
* validate_document(document)
|
13
|
+
*
|
14
|
+
* Validate a Nokogiri::XML::Document against this Schema.
|
15
|
+
*/
|
16
|
+
static VALUE validate_document(VALUE self, VALUE document)
|
17
|
+
{
|
18
|
+
xmlDocPtr doc;
|
19
|
+
xmlSchemaPtr schema;
|
20
|
+
xmlSchemaValidCtxtPtr valid_ctxt;
|
21
|
+
VALUE errors;
|
22
|
+
|
23
|
+
Data_Get_Struct(self, xmlSchema, schema);
|
24
|
+
Data_Get_Struct(document, xmlDoc, doc);
|
25
|
+
|
26
|
+
errors = rb_ary_new();
|
27
|
+
|
28
|
+
valid_ctxt = xmlSchemaNewValidCtxt(schema);
|
29
|
+
|
30
|
+
if(NULL == valid_ctxt) {
|
31
|
+
/* we have a problem */
|
32
|
+
rb_raise(rb_eRuntimeError, "Could not create a validation context");
|
33
|
+
}
|
34
|
+
|
35
|
+
#ifdef HAVE_XMLSCHEMASETVALIDSTRUCTUREDERRORS
|
36
|
+
xmlSchemaSetValidStructuredErrors(
|
37
|
+
valid_ctxt,
|
38
|
+
Nokogiri_error_array_pusher,
|
39
|
+
(void *)errors
|
40
|
+
);
|
41
|
+
#endif
|
42
|
+
|
43
|
+
xmlSchemaValidateDoc(valid_ctxt, doc);
|
44
|
+
|
45
|
+
xmlSchemaFreeValidCtxt(valid_ctxt);
|
46
|
+
|
47
|
+
return errors;
|
48
|
+
}
|
49
|
+
|
50
|
+
/*
|
51
|
+
* call-seq:
|
52
|
+
* validate_file(filename)
|
53
|
+
*
|
54
|
+
* Validate a file against this Schema.
|
55
|
+
*/
|
56
|
+
static VALUE validate_file(VALUE self, VALUE rb_filename)
|
57
|
+
{
|
58
|
+
xmlSchemaPtr schema;
|
59
|
+
xmlSchemaValidCtxtPtr valid_ctxt;
|
60
|
+
const char *filename ;
|
61
|
+
VALUE errors;
|
62
|
+
|
63
|
+
Data_Get_Struct(self, xmlSchema, schema);
|
64
|
+
filename = (const char*)StringValueCStr(rb_filename) ;
|
65
|
+
|
66
|
+
errors = rb_ary_new();
|
67
|
+
|
68
|
+
valid_ctxt = xmlSchemaNewValidCtxt(schema);
|
69
|
+
|
70
|
+
if(NULL == valid_ctxt) {
|
71
|
+
/* we have a problem */
|
72
|
+
rb_raise(rb_eRuntimeError, "Could not create a validation context");
|
73
|
+
}
|
74
|
+
|
75
|
+
#ifdef HAVE_XMLSCHEMASETVALIDSTRUCTUREDERRORS
|
76
|
+
xmlSchemaSetValidStructuredErrors(
|
77
|
+
valid_ctxt,
|
78
|
+
Nokogiri_error_array_pusher,
|
79
|
+
(void *)errors
|
80
|
+
);
|
81
|
+
#endif
|
82
|
+
|
83
|
+
xmlSchemaValidateFile(valid_ctxt, filename, 0);
|
84
|
+
|
85
|
+
xmlSchemaFreeValidCtxt(valid_ctxt);
|
86
|
+
|
87
|
+
return errors;
|
88
|
+
}
|
89
|
+
|
90
|
+
/*
|
91
|
+
* call-seq:
|
92
|
+
* read_memory(string)
|
93
|
+
*
|
94
|
+
* Create a new Schema from the contents of +string+
|
95
|
+
*/
|
96
|
+
static VALUE read_memory(int argc, VALUE *argv, VALUE klass)
|
97
|
+
{
|
98
|
+
VALUE content;
|
99
|
+
VALUE parse_options;
|
100
|
+
int parse_options_int;
|
101
|
+
xmlSchemaParserCtxtPtr ctx;
|
102
|
+
xmlSchemaPtr schema;
|
103
|
+
VALUE errors;
|
104
|
+
VALUE rb_schema;
|
105
|
+
int scanned_args = 0;
|
106
|
+
xmlExternalEntityLoader old_loader = 0;
|
107
|
+
|
108
|
+
scanned_args = rb_scan_args(argc, argv, "11", &content, &parse_options);
|
109
|
+
if (scanned_args == 1) {
|
110
|
+
parse_options = rb_const_get(rb_const_get(mNokogiriXml, rb_intern("ParseOptions")), rb_intern("DEFAULT_SCHEMA"));
|
111
|
+
}
|
112
|
+
parse_options_int = (int)NUM2INT(rb_funcall(parse_options, rb_intern("to_i"), 0));
|
113
|
+
|
114
|
+
ctx = xmlSchemaNewMemParserCtxt((const char *)StringValuePtr(content), (int)RSTRING_LEN(content));
|
115
|
+
|
116
|
+
errors = rb_ary_new();
|
117
|
+
xmlSetStructuredErrorFunc((void *)errors, Nokogiri_error_array_pusher);
|
118
|
+
|
119
|
+
#ifdef HAVE_XMLSCHEMASETPARSERSTRUCTUREDERRORS
|
120
|
+
xmlSchemaSetParserStructuredErrors(
|
121
|
+
ctx,
|
122
|
+
Nokogiri_error_array_pusher,
|
123
|
+
(void *)errors
|
124
|
+
);
|
125
|
+
#endif
|
126
|
+
|
127
|
+
if (parse_options_int & XML_PARSE_NONET) {
|
128
|
+
old_loader = xmlGetExternalEntityLoader();
|
129
|
+
xmlSetExternalEntityLoader(xmlNoNetExternalEntityLoader);
|
130
|
+
}
|
131
|
+
|
132
|
+
schema = xmlSchemaParse(ctx);
|
133
|
+
|
134
|
+
if (old_loader) {
|
135
|
+
xmlSetExternalEntityLoader(old_loader);
|
136
|
+
}
|
137
|
+
|
138
|
+
xmlSetStructuredErrorFunc(NULL, NULL);
|
139
|
+
xmlSchemaFreeParserCtxt(ctx);
|
140
|
+
|
141
|
+
if(NULL == schema) {
|
142
|
+
xmlErrorPtr error = xmlGetLastError();
|
143
|
+
if(error)
|
144
|
+
Nokogiri_error_raise(NULL, error);
|
145
|
+
else
|
146
|
+
rb_raise(rb_eRuntimeError, "Could not parse document");
|
147
|
+
|
148
|
+
return Qnil;
|
149
|
+
}
|
150
|
+
|
151
|
+
rb_schema = Data_Wrap_Struct(klass, 0, dealloc, schema);
|
152
|
+
rb_iv_set(rb_schema, "@errors", errors);
|
153
|
+
rb_iv_set(rb_schema, "@parse_options", parse_options);
|
154
|
+
|
155
|
+
return rb_schema;
|
156
|
+
}
|
157
|
+
|
158
|
+
/* Schema creation will remove and deallocate "blank" nodes.
|
159
|
+
* If those blank nodes have been exposed to Ruby, they could get freed
|
160
|
+
* out from under the VALUE pointer. This function checks to see if any of
|
161
|
+
* those nodes have been exposed to Ruby, and if so we should raise an exception.
|
162
|
+
*/
|
163
|
+
static int has_blank_nodes_p(VALUE cache)
|
164
|
+
{
|
165
|
+
long i;
|
166
|
+
|
167
|
+
if (NIL_P(cache)) {
|
168
|
+
return 0;
|
169
|
+
}
|
170
|
+
|
171
|
+
for (i = 0; i < RARRAY_LEN(cache); i++) {
|
172
|
+
xmlNodePtr node;
|
173
|
+
VALUE element = rb_ary_entry(cache, i);
|
174
|
+
Data_Get_Struct(element, xmlNode, node);
|
175
|
+
if (xmlIsBlankNode(node)) {
|
176
|
+
return 1;
|
177
|
+
}
|
178
|
+
}
|
179
|
+
|
180
|
+
return 0;
|
181
|
+
}
|
182
|
+
|
183
|
+
/*
|
184
|
+
* call-seq:
|
185
|
+
* from_document(doc)
|
186
|
+
*
|
187
|
+
* Create a new Schema from the Nokogiri::XML::Document +doc+
|
188
|
+
*/
|
189
|
+
static VALUE from_document(int argc, VALUE *argv, VALUE klass)
|
190
|
+
{
|
191
|
+
VALUE document;
|
192
|
+
VALUE parse_options;
|
193
|
+
int parse_options_int;
|
194
|
+
xmlDocPtr doc;
|
195
|
+
xmlSchemaParserCtxtPtr ctx;
|
196
|
+
xmlSchemaPtr schema;
|
197
|
+
VALUE errors;
|
198
|
+
VALUE rb_schema;
|
199
|
+
int scanned_args = 0;
|
200
|
+
xmlExternalEntityLoader old_loader = 0;
|
201
|
+
|
202
|
+
scanned_args = rb_scan_args(argc, argv, "11", &document, &parse_options);
|
203
|
+
|
204
|
+
Data_Get_Struct(document, xmlDoc, doc);
|
205
|
+
doc = doc->doc; /* In case someone passes us a node. ugh. */
|
206
|
+
|
207
|
+
if (scanned_args == 1) {
|
208
|
+
parse_options = rb_const_get(rb_const_get(mNokogiriXml, rb_intern("ParseOptions")), rb_intern("DEFAULT_SCHEMA"));
|
209
|
+
}
|
210
|
+
parse_options_int = (int)NUM2INT(rb_funcall(parse_options, rb_intern("to_i"), 0));
|
211
|
+
|
212
|
+
if (has_blank_nodes_p(DOC_NODE_CACHE(doc))) {
|
213
|
+
rb_raise(rb_eArgError, "Creating a schema from a document that has blank nodes exposed to Ruby is dangerous");
|
214
|
+
}
|
215
|
+
|
216
|
+
ctx = xmlSchemaNewDocParserCtxt(doc);
|
217
|
+
|
218
|
+
errors = rb_ary_new();
|
219
|
+
xmlSetStructuredErrorFunc((void *)errors, Nokogiri_error_array_pusher);
|
220
|
+
|
221
|
+
#ifdef HAVE_XMLSCHEMASETPARSERSTRUCTUREDERRORS
|
222
|
+
xmlSchemaSetParserStructuredErrors(
|
223
|
+
ctx,
|
224
|
+
Nokogiri_error_array_pusher,
|
225
|
+
(void *)errors
|
226
|
+
);
|
227
|
+
#endif
|
228
|
+
|
229
|
+
if (parse_options_int & XML_PARSE_NONET) {
|
230
|
+
old_loader = xmlGetExternalEntityLoader();
|
231
|
+
xmlSetExternalEntityLoader(xmlNoNetExternalEntityLoader);
|
232
|
+
}
|
233
|
+
|
234
|
+
schema = xmlSchemaParse(ctx);
|
235
|
+
|
236
|
+
if (old_loader) {
|
237
|
+
xmlSetExternalEntityLoader(old_loader);
|
238
|
+
}
|
239
|
+
|
240
|
+
xmlSetStructuredErrorFunc(NULL, NULL);
|
241
|
+
xmlSchemaFreeParserCtxt(ctx);
|
242
|
+
|
243
|
+
if(NULL == schema) {
|
244
|
+
xmlErrorPtr error = xmlGetLastError();
|
245
|
+
if(error)
|
246
|
+
Nokogiri_error_raise(NULL, error);
|
247
|
+
else
|
248
|
+
rb_raise(rb_eRuntimeError, "Could not parse document");
|
249
|
+
|
250
|
+
return Qnil;
|
251
|
+
}
|
252
|
+
|
253
|
+
rb_schema = Data_Wrap_Struct(klass, 0, dealloc, schema);
|
254
|
+
rb_iv_set(rb_schema, "@errors", errors);
|
255
|
+
rb_iv_set(rb_schema, "@parse_options", parse_options);
|
256
|
+
|
257
|
+
return rb_schema;
|
258
|
+
|
259
|
+
return Qnil;
|
260
|
+
}
|
261
|
+
|
262
|
+
VALUE cNokogiriXmlSchema;
|
263
|
+
void init_xml_schema()
|
264
|
+
{
|
265
|
+
VALUE nokogiri = rb_define_module("Nokogiri");
|
266
|
+
VALUE xml = rb_define_module_under(nokogiri, "XML");
|
267
|
+
VALUE klass = rb_define_class_under(xml, "Schema", rb_cObject);
|
268
|
+
|
269
|
+
cNokogiriXmlSchema = klass;
|
270
|
+
|
271
|
+
rb_define_singleton_method(klass, "read_memory", read_memory, -1);
|
272
|
+
rb_define_singleton_method(klass, "from_document", from_document, -1);
|
273
|
+
|
274
|
+
rb_define_private_method(klass, "validate_document", validate_document, 1);
|
275
|
+
rb_define_private_method(klass, "validate_file", validate_file, 1);
|
276
|
+
}
|