libxml-ruby 4.1.0 → 4.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,112 +1,113 @@
1
- #include "ruby_libxml.h"
2
- #include "ruby_xml_relaxng.h"
3
-
4
- #include <libxml/relaxng.h>
5
-
6
- /*
7
- * Document-class: LibXML::XML::RelaxNG
8
- *
9
- * The XML::RelaxNG class is used to prepare RelaxNG schemas for validation
10
- * of xml documents.
11
- *
12
- * Schemas can be created from XML documents, strings or URIs using the
13
- * corresponding methods (new for URIs).
14
- *
15
- * Once a schema is prepared, an XML document can be validated by the
16
- * XML::Document#validate_relaxng method providing the XML::RelaxNG object
17
- * as parameter. The method will raise an exception if the document is
18
- * not valid.
19
- *
20
- * Basic Usage:
21
- *
22
- * # parse schema as xml document
23
- * relaxng_document = XML::Document.file('schema.rng')
24
- *
25
- * # prepare schema for validation
26
- * relaxng_schema = XML::RelaxNG.document(relaxng_document)
27
- *
28
- * # parse xml document to be validated
29
- * instance = XML::Document.file('instance.xml')
30
- *
31
- * # validate
32
- * instance.validate_relaxng(relaxng_schema)
33
- */
34
-
35
- VALUE cXMLRelaxNG;
36
-
37
- static void rxml_relaxng_free(xmlRelaxNGPtr xrelaxng)
38
- {
39
- xmlRelaxNGFree(xrelaxng);
40
- }
41
-
42
- /*
43
- * call-seq:
44
- * XML::Relaxng.new(relaxng_uri) -> relaxng
45
- *
46
- * Create a new relaxng from the specified URI.
47
- */
48
- static VALUE rxml_relaxng_init_from_uri(VALUE class, VALUE uri)
49
- {
50
- xmlRelaxNGParserCtxtPtr xparser;
51
- xmlRelaxNGPtr xrelaxng;
52
-
53
- Check_Type(uri, T_STRING);
54
-
55
- xparser = xmlRelaxNGNewParserCtxt(StringValuePtr(uri));
56
- xrelaxng = xmlRelaxNGParse(xparser);
57
- xmlRelaxNGFreeParserCtxt(xparser);
58
-
59
- return Data_Wrap_Struct(cXMLRelaxNG, NULL, rxml_relaxng_free, xrelaxng);
60
- }
61
-
62
- /*
63
- * call-seq:
64
- * XML::RelaxNG.document(document) -> relaxng
65
- *
66
- * Create a new relaxng from the specified document.
67
- */
68
- static VALUE rxml_relaxng_init_from_document(VALUE class, VALUE document)
69
- {
70
- xmlDocPtr xdoc;
71
- xmlRelaxNGPtr xrelaxng;
72
- xmlRelaxNGParserCtxtPtr xparser;
73
-
74
- Data_Get_Struct(document, xmlDoc, xdoc);
75
-
76
- xparser = xmlRelaxNGNewDocParserCtxt(xdoc);
77
- xrelaxng = xmlRelaxNGParse(xparser);
78
- xmlRelaxNGFreeParserCtxt(xparser);
79
-
80
- return Data_Wrap_Struct(cXMLRelaxNG, NULL, rxml_relaxng_free, xrelaxng);
81
- }
82
-
83
- /*
84
- * call-seq:
85
- * XML::RelaxNG.string("relaxng_data") -> "value"
86
- *
87
- * Create a new relaxng using the specified string.
88
- */
89
- static VALUE rxml_relaxng_init_from_string(VALUE self, VALUE relaxng_str)
90
- {
91
- xmlRelaxNGParserCtxtPtr xparser;
92
- xmlRelaxNGPtr xrelaxng;
93
-
94
- Check_Type(relaxng_str, T_STRING);
95
-
96
- xparser = xmlRelaxNGNewMemParserCtxt(StringValuePtr(relaxng_str), (int)strlen(StringValuePtr(relaxng_str)));
97
- xrelaxng = xmlRelaxNGParse(xparser);
98
- xmlRelaxNGFreeParserCtxt(xparser);
99
-
100
- return Data_Wrap_Struct(cXMLRelaxNG, NULL, rxml_relaxng_free, xrelaxng);
101
- }
102
-
103
- void rxml_init_relaxng(void)
104
- {
105
- cXMLRelaxNG = rb_define_class_under(mXML, "RelaxNG", rb_cObject);
106
- rb_define_singleton_method(cXMLRelaxNG, "new", rxml_relaxng_init_from_uri, 1);
107
- rb_define_singleton_method(cXMLRelaxNG, "from_string",
108
- rxml_relaxng_init_from_string, 1);
109
- rb_define_singleton_method(cXMLRelaxNG, "document",
110
- rxml_relaxng_init_from_document, 1);
111
- }
112
-
1
+ #include "ruby_libxml.h"
2
+ #include "ruby_xml_relaxng.h"
3
+
4
+ #include <libxml/relaxng.h>
5
+
6
+ /*
7
+ * Document-class: LibXML::XML::RelaxNG
8
+ *
9
+ * The XML::RelaxNG class is used to prepare RelaxNG schemas for validation
10
+ * of xml documents.
11
+ *
12
+ * Schemas can be created from XML documents, strings or URIs using the
13
+ * corresponding methods (new for URIs).
14
+ *
15
+ * Once a schema is prepared, an XML document can be validated by the
16
+ * XML::Document#validate_relaxng method providing the XML::RelaxNG object
17
+ * as parameter. The method will raise an exception if the document is
18
+ * not valid.
19
+ *
20
+ * Basic Usage:
21
+ *
22
+ * # parse schema as xml document
23
+ * relaxng_document = XML::Document.file('schema.rng')
24
+ *
25
+ * # prepare schema for validation
26
+ * relaxng_schema = XML::RelaxNG.document(relaxng_document)
27
+ *
28
+ * # parse xml document to be validated
29
+ * instance = XML::Document.file('instance.xml')
30
+ *
31
+ * # validate
32
+ * instance.validate_relaxng(relaxng_schema)
33
+ */
34
+
35
+ VALUE cXMLRelaxNG;
36
+
37
+ static void rxml_relaxng_free(xmlRelaxNGPtr xrelaxng)
38
+ {
39
+ xmlRelaxNGFree(xrelaxng);
40
+ }
41
+
42
+ /*
43
+ * call-seq:
44
+ * XML::Relaxng.new(relaxng_uri) -> relaxng
45
+ *
46
+ * Create a new relaxng from the specified URI.
47
+ */
48
+ static VALUE rxml_relaxng_init_from_uri(VALUE class, VALUE uri)
49
+ {
50
+ xmlRelaxNGParserCtxtPtr xparser;
51
+ xmlRelaxNGPtr xrelaxng;
52
+
53
+ Check_Type(uri, T_STRING);
54
+
55
+ xparser = xmlRelaxNGNewParserCtxt(StringValuePtr(uri));
56
+ xrelaxng = xmlRelaxNGParse(xparser);
57
+ xmlRelaxNGFreeParserCtxt(xparser);
58
+
59
+ return Data_Wrap_Struct(cXMLRelaxNG, NULL, rxml_relaxng_free, xrelaxng);
60
+ }
61
+
62
+ /*
63
+ * call-seq:
64
+ * XML::RelaxNG.document(document) -> relaxng
65
+ *
66
+ * Create a new relaxng from the specified document.
67
+ */
68
+ static VALUE rxml_relaxng_init_from_document(VALUE class, VALUE document)
69
+ {
70
+ xmlDocPtr xdoc;
71
+ xmlRelaxNGPtr xrelaxng;
72
+ xmlRelaxNGParserCtxtPtr xparser;
73
+
74
+ Data_Get_Struct(document, xmlDoc, xdoc);
75
+
76
+ xparser = xmlRelaxNGNewDocParserCtxt(xdoc);
77
+ xrelaxng = xmlRelaxNGParse(xparser);
78
+ xmlRelaxNGFreeParserCtxt(xparser);
79
+
80
+ return Data_Wrap_Struct(cXMLRelaxNG, NULL, rxml_relaxng_free, xrelaxng);
81
+ }
82
+
83
+ /*
84
+ * call-seq:
85
+ * XML::RelaxNG.string("relaxng_data") -> "value"
86
+ *
87
+ * Create a new relaxng using the specified string.
88
+ */
89
+ static VALUE rxml_relaxng_init_from_string(VALUE self, VALUE relaxng_str)
90
+ {
91
+ xmlRelaxNGParserCtxtPtr xparser;
92
+ xmlRelaxNGPtr xrelaxng;
93
+
94
+ Check_Type(relaxng_str, T_STRING);
95
+
96
+ xparser = xmlRelaxNGNewMemParserCtxt(StringValuePtr(relaxng_str), (int)strlen(StringValuePtr(relaxng_str)));
97
+ xrelaxng = xmlRelaxNGParse(xparser);
98
+ xmlRelaxNGFreeParserCtxt(xparser);
99
+
100
+ return Data_Wrap_Struct(cXMLRelaxNG, NULL, rxml_relaxng_free, xrelaxng);
101
+ }
102
+
103
+ void rxml_init_relaxng(void)
104
+ {
105
+ cXMLRelaxNG = rb_define_class_under(mXML, "RelaxNG", rb_cObject);
106
+ rb_undef_alloc_func(cXMLRelaxNG);
107
+ rb_define_singleton_method(cXMLRelaxNG, "new", rxml_relaxng_init_from_uri, 1);
108
+ rb_define_singleton_method(cXMLRelaxNG, "from_string",
109
+ rxml_relaxng_init_from_string, 1);
110
+ rb_define_singleton_method(cXMLRelaxNG, "document",
111
+ rxml_relaxng_init_from_document, 1);
112
+ }
113
+