libxml-ruby 3.2.1 → 4.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY +37 -0
  3. data/Rakefile +24 -16
  4. data/ext/libxml/libxml.c +0 -1
  5. data/ext/libxml/libxml_ruby.def +0 -1
  6. data/ext/libxml/ruby_libxml.h +0 -23
  7. data/ext/libxml/ruby_xml.c +3 -37
  8. data/ext/libxml/ruby_xml.h +1 -1
  9. data/ext/libxml/ruby_xml_cbg.c +1 -1
  10. data/ext/libxml/ruby_xml_document.c +6 -0
  11. data/ext/libxml/ruby_xml_dtd.c +1 -1
  12. data/ext/libxml/ruby_xml_encoding.c +2 -2
  13. data/ext/libxml/ruby_xml_encoding.h +2 -0
  14. data/ext/libxml/ruby_xml_error.c +3 -3
  15. data/ext/libxml/ruby_xml_error.h +3 -1
  16. data/ext/libxml/ruby_xml_html_parser.c +2 -0
  17. data/ext/libxml/ruby_xml_html_parser_context.c +1 -1
  18. data/ext/libxml/ruby_xml_html_parser_options.c +2 -0
  19. data/ext/libxml/ruby_xml_input_cbg.c +4 -7
  20. data/ext/libxml/ruby_xml_io.c +1 -1
  21. data/ext/libxml/ruby_xml_namespace.c +1 -0
  22. data/ext/libxml/ruby_xml_node.c +11 -15
  23. data/ext/libxml/ruby_xml_parser.h +0 -2
  24. data/ext/libxml/ruby_xml_parser_context.c +2 -0
  25. data/ext/libxml/ruby_xml_parser_options.h +0 -2
  26. data/ext/libxml/ruby_xml_reader.c +3 -0
  27. data/ext/libxml/ruby_xml_reader.h +0 -3
  28. data/ext/libxml/ruby_xml_relaxng.c +2 -0
  29. data/ext/libxml/ruby_xml_relaxng.h +0 -2
  30. data/ext/libxml/ruby_xml_schema.c +223 -81
  31. data/ext/libxml/ruby_xml_schema.h +4 -788
  32. data/ext/libxml/ruby_xml_schema_attribute.c +69 -71
  33. data/ext/libxml/ruby_xml_schema_attribute.h +25 -3
  34. data/ext/libxml/ruby_xml_schema_element.c +28 -54
  35. data/ext/libxml/ruby_xml_schema_element.h +0 -3
  36. data/ext/libxml/ruby_xml_schema_facet.c +19 -21
  37. data/ext/libxml/ruby_xml_schema_facet.h +0 -4
  38. data/ext/libxml/ruby_xml_schema_type.c +56 -37
  39. data/ext/libxml/ruby_xml_version.h +4 -4
  40. data/ext/libxml/ruby_xml_writer.c +4 -0
  41. data/ext/libxml/ruby_xml_writer.h +0 -4
  42. data/ext/libxml/ruby_xml_xinclude.c +4 -0
  43. data/ext/libxml/ruby_xml_xpath.c +1 -0
  44. data/ext/libxml/ruby_xml_xpath.h +2 -0
  45. data/ext/libxml/ruby_xml_xpath_context.c +2 -0
  46. data/ext/libxml/ruby_xml_xpath_object.c +1 -0
  47. data/lib/libxml/error.rb +7 -7
  48. data/libxml-ruby.gemspec +1 -1
  49. data/test/model/shiporder.rnc +2 -2
  50. data/test/model/shiporder.rng +2 -2
  51. data/test/model/shiporder.xsd +7 -3
  52. data/test/model/shiporder_bad.xsd +40 -0
  53. data/test/model/shiporder_import.xsd +45 -0
  54. data/test/test_document.rb +2 -1
  55. data/test/test_dtd.rb +2 -1
  56. data/test/test_error.rb +173 -157
  57. data/test/test_helper.rb +6 -0
  58. data/test/test_parser.rb +1 -1
  59. data/test/test_parser_context.rb +1 -7
  60. data/test/test_reader.rb +2 -1
  61. data/test/test_sax_parser.rb +13 -6
  62. data/test/test_schema.rb +92 -29
  63. data/test/test_xml.rb +12 -7
  64. metadata +11 -18
  65. data/MANIFEST +0 -166
  66. data/ext/libxml/ruby_xml_xpointer.c +0 -99
  67. data/ext/libxml/ruby_xml_xpointer.h +0 -11
  68. data/setup.rb +0 -1584
  69. data/test/test.xml +0 -2
  70. data/test/test_suite.rb +0 -48
  71. data/test/test_xpointer.rb +0 -72
@@ -2,6 +2,52 @@
2
2
  #include "ruby_xml_schema_attribute.h"
3
3
  #include "ruby_xml_schema_type.h"
4
4
 
5
+ /**
6
+ * xmlSchemaBasicItem:
7
+ *
8
+ * The abstract base type for schema components.
9
+ */
10
+ typedef struct _xmlSchemaBasicItem xmlSchemaBasicItem;
11
+ typedef xmlSchemaBasicItem *xmlSchemaBasicItemPtr;
12
+ struct _xmlSchemaBasicItem {
13
+ xmlSchemaTypeType type;
14
+ };
15
+
16
+ /**
17
+ * xmlSchemaQNameRef:
18
+ *
19
+ * A component reference item (not a schema component)
20
+ * (Extends xmlSchemaBasicItem)
21
+ */
22
+ typedef struct _xmlSchemaQNameRef xmlSchemaQNameRef;
23
+ typedef xmlSchemaQNameRef *xmlSchemaQNameRefPtr;
24
+ struct _xmlSchemaQNameRef {
25
+ xmlSchemaTypeType type;
26
+ xmlSchemaBasicItemPtr item;
27
+ /* The resolved referenced item. */
28
+ xmlSchemaTypeType itemType;
29
+ const xmlChar *name;
30
+ const xmlChar *targetNamespace;
31
+ xmlNodePtr node;
32
+ };
33
+
34
+ /**
35
+ * xmlSchemaAttributeUseProhibPtr:
36
+ *
37
+ * A helper component to reflect attribute prohibitions.
38
+ * (Extends xmlSchemaBasicItem)
39
+ */
40
+ typedef struct _xmlSchemaAttributeUseProhib xmlSchemaAttributeUseProhib;
41
+ typedef xmlSchemaAttributeUseProhib *xmlSchemaAttributeUseProhibPtr;
42
+ struct _xmlSchemaAttributeUseProhib {
43
+ xmlSchemaTypeType type;
44
+ /* == XML_SCHEMA_EXTRA_ATTR_USE_PROHIB */
45
+ xmlNodePtr node;
46
+ const xmlChar *name;
47
+ const xmlChar *targetNamespace;
48
+ int isRef;
49
+ };
50
+
5
51
  VALUE cXMLSchemaAttribute;
6
52
 
7
53
  static void rxml_schema_attribute_free(xmlSchemaAttributeUsePtr attr)
@@ -12,62 +58,31 @@ static void rxml_schema_attribute_free(xmlSchemaAttributeUsePtr attr)
12
58
 
13
59
  VALUE rxml_wrap_schema_attribute(xmlSchemaAttributeUsePtr attr)
14
60
  {
15
- return Data_Wrap_Struct(cXMLSchemaAttribute, NULL, rxml_schema_attribute_free, attr);
16
- }
17
-
18
- static VALUE rxml_schema_attribute_namespace(VALUE self)
19
- {
20
- xmlSchemaAttributeUsePtr attr;
21
- const xmlChar *tns;
61
+ VALUE result;
62
+ const xmlChar *tns_str, *name_str;
22
63
 
23
- Data_Get_Struct(self, xmlSchemaAttributeUse, attr);
64
+ if (!attr)
65
+ rb_raise(rb_eArgError, "XML::Schema::Attribute required!");
24
66
 
25
- if (attr == NULL)
26
- return Qnil;
67
+ result = Data_Wrap_Struct(cXMLSchemaAttribute, NULL, rxml_schema_attribute_free, attr);
27
68
 
28
69
  if (attr->type == XML_SCHEMA_EXTRA_ATTR_USE_PROHIB) {
29
- tns = ((xmlSchemaAttributeUseProhibPtr) attr)->targetNamespace;
70
+ tns_str = ((xmlSchemaAttributeUseProhibPtr) attr)->targetNamespace;
71
+ name_str = ((xmlSchemaAttributeUseProhibPtr) attr)->name;
30
72
  } else if (attr->type == XML_SCHEMA_EXTRA_QNAMEREF) {
31
- tns = ((xmlSchemaQNameRefPtr) attr)->targetNamespace;
73
+ tns_str = ((xmlSchemaQNameRefPtr) attr)->targetNamespace;
74
+ name_str = ((xmlSchemaQNameRefPtr) attr)->name;
32
75
  } else {
33
- tns = ((xmlSchemaAttributePtr) ((xmlSchemaAttributeUsePtr) (attr))->attrDecl)->targetNamespace;
76
+ tns_str = ((xmlSchemaAttributePtr) (attr->attrDecl))->targetNamespace;
77
+ name_str = ((xmlSchemaAttributePtr) (attr->attrDecl))->name;
34
78
  }
79
+ rb_iv_set(result, "@target_namespace", QNIL_OR_STRING(tns_str));
80
+ rb_iv_set(result, "@name", QNIL_OR_STRING(name_str));
81
+ rb_iv_set(result, "@type", rxml_wrap_schema_type((xmlSchemaTypePtr)attr->attrDecl->subtypes));
82
+ rb_iv_set(result, "@value", QNIL_OR_STRING(attr->defValue));
83
+ rb_iv_set(result, "@occurs", INT2NUM(attr->occurs));
35
84
 
36
- QNIL_OR_STRING(tns)
37
- }
38
-
39
- static VALUE rxml_schema_attribute_name(VALUE self)
40
- {
41
- xmlSchemaAttributeUsePtr attr;
42
- const xmlChar *name;
43
-
44
- Data_Get_Struct(self, xmlSchemaAttributeUse, attr);
45
-
46
- if (attr == NULL)
47
- return Qnil;
48
-
49
- if (attr->type == XML_SCHEMA_EXTRA_ATTR_USE_PROHIB) {
50
- name = ((xmlSchemaAttributeUseProhibPtr) attr)->name;
51
- } else if (attr->type == XML_SCHEMA_EXTRA_QNAMEREF) {
52
- name = ((xmlSchemaQNameRefPtr) attr)->name;
53
- } else {
54
- xmlSchemaAttributePtr attrDecl = ((xmlSchemaAttributeUsePtr) attr)->attrDecl;
55
- name = attrDecl->name;
56
- }
57
-
58
- QNIL_OR_STRING(name)
59
- }
60
-
61
- static VALUE rxml_schema_attribute_type(VALUE self)
62
- {
63
- xmlSchemaAttributeUsePtr attr;
64
- xmlSchemaTypePtr xtype;
65
-
66
- Data_Get_Struct(self, xmlSchemaAttributeUse, attr);
67
-
68
- xtype = attr->attrDecl->subtypes;
69
-
70
- return rxml_wrap_schema_type((xmlSchemaTypePtr) xtype);
85
+ return result;
71
86
  }
72
87
 
73
88
  static VALUE rxml_schema_attribute_node(VALUE self)
@@ -79,31 +94,14 @@ static VALUE rxml_schema_attribute_node(VALUE self)
79
94
  return rxml_node_wrap(attr->node);
80
95
  }
81
96
 
82
- static VALUE rxml_schema_attribute_value(VALUE self)
83
- {
84
- xmlSchemaAttributeUsePtr attr;
85
-
86
- Data_Get_Struct(self, xmlSchemaAttributeUse, attr);
87
-
88
- QNIL_OR_STRING(attr->defValue)
89
- }
90
-
91
- static VALUE rxml_schema_attribute_occurs(VALUE self)
92
- {
93
- xmlSchemaAttributeUsePtr attr;
94
-
95
- Data_Get_Struct(self, xmlSchemaAttributeUse, attr);
96
-
97
- return INT2NUM(attr->occurs);
98
- }
99
-
100
97
  void rxml_init_schema_attribute(void)
101
98
  {
102
99
  cXMLSchemaAttribute = rb_define_class_under(cXMLSchema, "Attribute", rb_cObject);
103
- rb_define_method(cXMLSchemaAttribute, "namespace", rxml_schema_attribute_namespace, 0);
104
- rb_define_method(cXMLSchemaAttribute, "name", rxml_schema_attribute_name, 0);
105
- rb_define_method(cXMLSchemaAttribute, "type", rxml_schema_attribute_type, 0);
100
+ rb_define_attr(cXMLSchemaAttribute, "name", 1, 0);
101
+ rb_define_attr(cXMLSchemaAttribute, "type", 1, 0);
102
+ rb_define_attr(cXMLSchemaAttribute, "namespace", 1, 0);
103
+ rb_define_attr(cXMLSchemaAttribute, "value", 1, 0);
104
+ rb_define_attr(cXMLSchemaAttribute, "occurs", 1, 0);
105
+
106
106
  rb_define_method(cXMLSchemaAttribute, "node", rxml_schema_attribute_node, 0);
107
- rb_define_method(cXMLSchemaAttribute, "value", rxml_schema_attribute_value, 0);
108
- rb_define_method(cXMLSchemaAttribute, "occurs", rxml_schema_attribute_occurs, 0);
109
107
  }
@@ -2,12 +2,34 @@
2
2
  #define __RXML_SCHEMA_ATTRIBUTE__
3
3
 
4
4
  #include "ruby_xml_schema.h"
5
- #include <libxml/schemasInternals.h>
6
- #include <libxml/xmlschemas.h>
7
- #include <libxml/xmlschemastypes.h>
8
5
 
9
6
  extern VALUE cXMLSchemaAttribute;
10
7
 
8
+ /**
9
+ * xmlSchemaAttributeUsePtr:
10
+ *
11
+ * The abstract base type for tree-like structured schema components.
12
+ * (Extends xmlSchemaTreeItem)
13
+ */
14
+ typedef struct _xmlSchemaAttributeUse xmlSchemaAttributeUse;
15
+ typedef xmlSchemaAttributeUse *xmlSchemaAttributeUsePtr;
16
+ struct _xmlSchemaAttributeUse {
17
+ xmlSchemaTypeType type;
18
+ xmlSchemaAnnotPtr annot;
19
+ xmlSchemaAttributeUsePtr next; /* The next attr. use. */
20
+ /*
21
+ * The attr. decl. OR a QName-ref. to an attr. decl. OR
22
+ * a QName-ref. to an attribute group definition.
23
+ */
24
+ xmlSchemaAttributePtr attrDecl;
25
+
26
+ int flags;
27
+ xmlNodePtr node;
28
+ int occurs;
29
+ /* required, optional */
30
+ const xmlChar *defValue;
31
+ xmlSchemaValPtr defVal;
32
+ };
11
33
 
12
34
  void rxml_init_schema_attribute(void);
13
35
  VALUE rxml_wrap_schema_attribute(xmlSchemaAttributeUsePtr attr);
@@ -10,40 +10,21 @@ static void rxml_schema_element_free(xmlSchemaElementPtr xschema_element)
10
10
  xmlFree(xschema_element);
11
11
  }
12
12
 
13
- VALUE rxml_wrap_schema_element(xmlSchemaElementPtr xelement)
13
+ VALUE rxml_wrap_schema_element(xmlSchemaElementPtr xelem)
14
14
  {
15
- return Data_Wrap_Struct(cXMLSchemaElement, NULL, rxml_schema_element_free, xelement);
16
- }
15
+ VALUE result;
17
16
 
18
- static VALUE rxml_schema_element_namespace(VALUE self)
19
- {
20
- xmlSchemaElementPtr xelem;
17
+ if (!xelem)
18
+ rb_raise(rb_eArgError, "XML::Schema::Element is required!");
21
19
 
22
- Data_Get_Struct(self, xmlSchemaElement, xelem);
20
+ result = Data_Wrap_Struct(cXMLSchemaElement, NULL, rxml_schema_element_free, xelem);
23
21
 
24
- QNIL_OR_STRING(xelem->targetNamespace)
25
- }
22
+ rb_iv_set(result, "@name", QNIL_OR_STRING(xelem->name));
23
+ rb_iv_set(result, "@value", QNIL_OR_STRING(xelem->value));
24
+ rb_iv_set(result, "@namespace", QNIL_OR_STRING(xelem->targetNamespace));
25
+ rb_iv_set(result, "@type", rxml_wrap_schema_type((xmlSchemaTypePtr) (xelem->subtypes)));
26
26
 
27
- static VALUE rxml_schema_element_name(VALUE self)
28
- {
29
- xmlSchemaElementPtr xelem;
30
-
31
- Data_Get_Struct(self, xmlSchemaElement, xelem);
32
-
33
-
34
- QNIL_OR_STRING(xelem->name)
35
- }
36
-
37
- static VALUE rxml_schema_element_type(VALUE self)
38
- {
39
- xmlSchemaElementPtr xelem;
40
- xmlSchemaTypePtr xtype;
41
-
42
- Data_Get_Struct(self, xmlSchemaElement, xelem);
43
-
44
- xtype = xelem->subtypes;
45
-
46
- return rxml_wrap_schema_type((xmlSchemaTypePtr) xtype);
27
+ return result;
47
28
  }
48
29
 
49
30
  static VALUE rxml_schema_element_node(VALUE self)
@@ -55,41 +36,34 @@ static VALUE rxml_schema_element_node(VALUE self)
55
36
  return rxml_node_wrap(xelem->node);
56
37
  }
57
38
 
58
- static VALUE rxml_schema_element_value(VALUE self)
39
+ static VALUE rxml_schema_element_annot(VALUE self)
59
40
  {
60
41
  xmlSchemaElementPtr xelem;
42
+ VALUE annotation = Qnil;
61
43
 
62
44
  Data_Get_Struct(self, xmlSchemaElement, xelem);
63
45
 
64
- QNIL_OR_STRING(xelem->value)
65
- }
66
-
67
- static VALUE rxml_schema_element_annot(VALUE self)
68
- {
69
- VALUE result = Qnil;
70
- xmlSchemaElementPtr xelem;
71
-
72
- Data_Get_Struct(self, xmlSchemaElement, xelem);
73
-
74
- if (xelem != NULL && xelem->annot != NULL && xelem->annot->content != NULL)
75
- {
76
- xmlChar *content = xmlNodeGetContent(xelem->annot->content);
77
- if (content)
78
- {
79
- result = rxml_new_cstr(content, NULL);
80
- xmlFree(content);
81
- }
82
- }
83
- return result;
46
+ if ((xelem->annot != NULL) && (xelem->annot->content != NULL))
47
+ {
48
+ xmlChar *content = xmlNodeGetContent(xelem->annot->content);
49
+ if (content)
50
+ {
51
+ annotation = rxml_new_cstr(content, NULL);
52
+ xmlFree(content);
53
+ }
54
+ }
55
+
56
+ return annotation;
84
57
  }
85
58
 
86
59
  void rxml_init_schema_element(void)
87
60
  {
88
61
  cXMLSchemaElement = rb_define_class_under(cXMLSchema, "Element", rb_cObject);
89
- rb_define_method(cXMLSchemaElement, "namespace", rxml_schema_element_namespace, 0);
90
- rb_define_method(cXMLSchemaElement, "name", rxml_schema_element_name, 0);
91
- rb_define_method(cXMLSchemaElement, "type", rxml_schema_element_type, 0);
62
+ rb_define_attr(cXMLSchemaElement, "name", 1, 0);
63
+ rb_define_attr(cXMLSchemaElement, "value", 1, 0);
64
+ rb_define_attr(cXMLSchemaElement, "namespace", 1, 0);
65
+ rb_define_attr(cXMLSchemaElement, "type", 1, 0);
66
+
92
67
  rb_define_method(cXMLSchemaElement, "node", rxml_schema_element_node, 0);
93
- rb_define_method(cXMLSchemaElement, "value", rxml_schema_element_value, 0);
94
68
  rb_define_method(cXMLSchemaElement, "annotation", rxml_schema_element_annot, 0);
95
69
  }
@@ -2,9 +2,6 @@
2
2
  #define __RXML_SCHEMA_ELEMENT__
3
3
 
4
4
  #include "ruby_xml_schema.h"
5
- #include <libxml/schemasInternals.h>
6
- #include <libxml/xmlschemas.h>
7
- #include <libxml/xmlschemastypes.h>
8
5
 
9
6
  extern VALUE cXMLSchemaElement;
10
7
 
@@ -1,6 +1,10 @@
1
1
  #include "ruby_libxml.h"
2
2
  #include "ruby_xml_schema_facet.h"
3
3
 
4
+ #include <libxml/schemasInternals.h>
5
+ #include <libxml/xmlschemas.h>
6
+ #include <libxml/xmlschemastypes.h>
7
+
4
8
  VALUE cXMLSchemaFacet;
5
9
 
6
10
  static void rxml_schema_facet_free(xmlSchemaFacetPtr xschema_type)
@@ -9,44 +13,38 @@ static void rxml_schema_facet_free(xmlSchemaFacetPtr xschema_type)
9
13
  xmlFree(xschema_type);
10
14
  }
11
15
 
12
- /* START FACET*/
13
-
14
- static VALUE rxml_schema_facet_node(VALUE self)
16
+ VALUE rxml_wrap_schema_facet(xmlSchemaFacetPtr facet)
15
17
  {
16
- xmlSchemaFacetPtr facet;
18
+ VALUE result;
17
19
 
18
- Data_Get_Struct(self, xmlSchemaFacet, facet);
20
+ if (!facet)
21
+ rb_raise(rb_eArgError, "XML::Schema::Facet required!");
19
22
 
20
- return rxml_node_wrap(facet->node);
21
- }
23
+ result = Data_Wrap_Struct(cXMLSchemaFacet, NULL, rxml_schema_facet_free, facet);
22
24
 
23
- static VALUE rxml_schema_facet_value(VALUE self)
24
- {
25
- xmlSchemaFacetPtr facet;
25
+ rb_iv_set(result, "@kind", INT2NUM(facet->type));
26
+ rb_iv_set(result, "@value", QNIL_OR_STRING(facet->value));
26
27
 
27
- Data_Get_Struct(self, xmlSchemaFacet, facet);
28
+ return result;
28
29
 
29
- QNIL_OR_STRING(facet->value)
30
30
  }
31
31
 
32
- static VALUE rxml_schema_facet_kind(VALUE self)
32
+ /* START FACET*/
33
+
34
+ static VALUE rxml_schema_facet_node(VALUE self)
33
35
  {
34
36
  xmlSchemaFacetPtr facet;
35
37
 
36
38
  Data_Get_Struct(self, xmlSchemaFacet, facet);
37
39
 
38
- return INT2NUM(facet->type);
39
- }
40
-
41
- VALUE rxml_wrap_schema_facet(xmlSchemaFacetPtr facet)
42
- {
43
- return Data_Wrap_Struct(cXMLSchemaFacet, NULL, rxml_schema_facet_free, facet);
40
+ return rxml_node_wrap(facet->node);
44
41
  }
45
42
 
46
43
  void rxml_init_schema_facet(void)
47
44
  {
48
45
  cXMLSchemaFacet = rb_define_class_under(cXMLSchema, "Facet", rb_cObject);
49
- rb_define_method(cXMLSchemaFacet, "value", rxml_schema_facet_value, 0);
46
+ rb_define_attr(cXMLSchemaFacet, "kind", 1, 0);
47
+ rb_define_attr(cXMLSchemaFacet, "value", 1, 0);
48
+
50
49
  rb_define_method(cXMLSchemaFacet, "node", rxml_schema_facet_node, 0);
51
- rb_define_method(cXMLSchemaFacet, "kind", rxml_schema_facet_kind, 0);
52
50
  }
@@ -1,10 +1,6 @@
1
1
  #ifndef __RXML_SCHEMA_FACET__
2
2
  #define __RXML_SCHEMA_FACET__
3
3
 
4
- #include <libxml/schemasInternals.h>
5
- #include <libxml/xmlschemas.h>
6
- #include <libxml/xmlschemastypes.h>
7
-
8
4
  extern VALUE cXMLSchemaFacet;
9
5
 
10
6
  VALUE rxml_wrap_schema_facet(xmlSchemaFacetPtr facet);
@@ -7,6 +7,43 @@
7
7
  #define UNBOUNDED 1 << 30
8
8
  #define FREE_AND_NULL(str) if ((str) != NULL) { xmlFree((xmlChar *) (str)); str = NULL; }
9
9
 
10
+ /**
11
+ * xmlSchemaTreeItem:
12
+ *
13
+ * The abstract base type for tree-like structured schema components.
14
+ * (Extends xmlSchemaAnnotItem)
15
+ */
16
+ typedef struct _xmlSchemaTreeItem xmlSchemaTreeItem;
17
+ typedef xmlSchemaTreeItem *xmlSchemaTreeItemPtr;
18
+ struct _xmlSchemaTreeItem {
19
+ xmlSchemaTypeType type;
20
+ xmlSchemaAnnotPtr annot;
21
+ xmlSchemaTreeItemPtr next;
22
+ xmlSchemaTreeItemPtr children;
23
+ };
24
+
25
+ /**
26
+ * xmlSchemaParticle:
27
+ *
28
+ * A particle component.
29
+ * (Extends xmlSchemaTreeItem)
30
+ */
31
+ typedef struct _xmlSchemaParticle xmlSchemaParticle;
32
+ typedef xmlSchemaParticle *xmlSchemaParticlePtr;
33
+ struct _xmlSchemaParticle {
34
+ xmlSchemaTypeType type;
35
+ xmlSchemaAnnotPtr annot;
36
+ xmlSchemaTreeItemPtr next;
37
+ /* next particle */
38
+ xmlSchemaTreeItemPtr children;
39
+ /* the "term" (e.g. a model group,
40
+ a group definition, a XML_SCHEMA_EXTRA_QNAMEREF (if a reference),
41
+ etc.) */
42
+ int minOccurs;
43
+ int maxOccurs;
44
+ xmlNodePtr node;
45
+ };
46
+
10
47
  VALUE cXMLSchemaType;
11
48
 
12
49
  static void rxml_schema_type_free(xmlSchemaTypePtr xschema_type)
@@ -17,34 +54,36 @@ static void rxml_schema_type_free(xmlSchemaTypePtr xschema_type)
17
54
 
18
55
  VALUE rxml_wrap_schema_type(xmlSchemaTypePtr xtype)
19
56
  {
20
- return Data_Wrap_Struct(cXMLSchemaType, NULL, rxml_schema_type_free, xtype);
21
- }
57
+ VALUE result;
22
58
 
23
- static VALUE rxml_schema_type_namespace(VALUE self)
24
- {
25
- xmlSchemaTypePtr xtype;
59
+ if (!xtype)
60
+ rb_raise(rb_eArgError, "XML::Schema::Type required!");
26
61
 
27
- Data_Get_Struct(self, xmlSchemaType, xtype);
62
+ result = Data_Wrap_Struct(cXMLSchemaType, NULL, rxml_schema_type_free, xtype);
63
+
64
+ rb_iv_set(result, "@name", QNIL_OR_STRING(xtype->name));
65
+ rb_iv_set(result, "@namespace", QNIL_OR_STRING(xtype->targetNamespace));
66
+ rb_iv_set(result, "@kind", INT2NUM(xtype->type));
28
67
 
29
- QNIL_OR_STRING(xtype->targetNamespace)
68
+ return result;
30
69
  }
31
70
 
32
- static VALUE rxml_schema_type_name(VALUE self)
71
+ static VALUE rxml_schema_type_base(VALUE self)
33
72
  {
34
73
  xmlSchemaTypePtr xtype;
35
74
 
36
75
  Data_Get_Struct(self, xmlSchemaType, xtype);
37
76
 
38
- QNIL_OR_STRING(xtype->name)
77
+ return (xtype->baseType != xtype) ? rxml_wrap_schema_type(xtype->baseType) : Qnil;
39
78
  }
40
79
 
41
- static VALUE rxml_schema_type_base(VALUE self)
80
+ static VALUE rxml_schema_type_node(VALUE self)
42
81
  {
43
82
  xmlSchemaTypePtr xtype;
44
83
 
45
84
  Data_Get_Struct(self, xmlSchemaType, xtype);
46
85
 
47
- return Data_Wrap_Struct(cXMLSchemaType, NULL, rxml_schema_type_free, xtype->baseType);
86
+ return (xtype->node != NULL) ? rxml_node_wrap(xtype->node) : Qnil;
48
87
  }
49
88
 
50
89
  static VALUE rxml_schema_type_facets(VALUE self)
@@ -68,27 +107,6 @@ static VALUE rxml_schema_type_facets(VALUE self)
68
107
  return result;
69
108
  }
70
109
 
71
- static VALUE rxml_schema_type_node(VALUE self)
72
- {
73
- xmlSchemaTypePtr xtype;
74
-
75
- Data_Get_Struct(self, xmlSchemaType, xtype);
76
-
77
- if(xtype->node != NULL)
78
- return rxml_node_wrap(xtype->node);
79
- else
80
- return Qnil;
81
- }
82
-
83
- static VALUE rxml_schema_type_kind(VALUE self)
84
- {
85
- xmlSchemaTypePtr xtype;
86
-
87
- Data_Get_Struct(self, xmlSchemaType, xtype);
88
-
89
- return INT2NUM(xtype->type);
90
- }
91
-
92
110
  static VALUE rxml_schema_type_annot(VALUE self)
93
111
  {
94
112
  VALUE result = Qnil;
@@ -220,13 +238,14 @@ void rxml_init_schema_type(void)
220
238
 
221
239
  cXMLSchemaType = rb_define_class_under(cXMLSchema, "Type", rb_cObject);
222
240
 
223
- rb_define_method(cXMLSchemaType, "namespace", rxml_schema_type_namespace, 0);
224
- rb_define_method(cXMLSchemaType, "name", rxml_schema_type_name, 0);
225
- rb_define_method(cXMLSchemaType, "elements", rxml_schema_type_elements, 0);
226
- rb_define_method(cXMLSchemaType, "attributes", rxml_schema_type_attributes, 0);
241
+ rb_define_attr(cXMLSchemaType, "namespace", 1, 0);
242
+ rb_define_attr(cXMLSchemaType, "name", 1, 0);
243
+ rb_define_attr(cXMLSchemaType, "kind", 1, 0);
244
+
227
245
  rb_define_method(cXMLSchemaType, "base", rxml_schema_type_base, 0);
228
- rb_define_method(cXMLSchemaType, "kind", rxml_schema_type_kind, 0);
229
246
  rb_define_method(cXMLSchemaType, "node", rxml_schema_type_node, 0);
247
+ rb_define_method(cXMLSchemaType, "elements", rxml_schema_type_elements, 0);
248
+ rb_define_method(cXMLSchemaType, "attributes", rxml_schema_type_attributes, 0);
230
249
  rb_define_method(cXMLSchemaType, "facets", rxml_schema_type_facets, 0);
231
250
  rb_define_method(cXMLSchemaType, "annotation", rxml_schema_type_annot, 0);
232
251
  }
@@ -1,9 +1,9 @@
1
1
  /* Don't nuke this block! It is used for automatically updating the
2
2
  * versions below. VERSION = string formatting, VERNUM = numbered
3
3
  * version for inline testing: increment both or none at all.*/
4
- #define RUBY_LIBXML_VERSION "3.2.1"
5
- #define RUBY_LIBXML_VERNUM 321
6
- #define RUBY_LIBXML_VER_MAJ 3
7
- #define RUBY_LIBXML_VER_MIN 2
4
+ #define RUBY_LIBXML_VERSION "4.1.1"
5
+ #define RUBY_LIBXML_VERNUM 400
6
+ #define RUBY_LIBXML_VER_MAJ 4
7
+ #define RUBY_LIBXML_VER_MIN 1
8
8
  #define RUBY_LIBXML_VER_MIC 1
9
9
  #define RUBY_LIBXML_VER_PATCH 0
@@ -1,6 +1,10 @@
1
1
  #include "ruby_libxml.h"
2
2
  #include "ruby_xml_writer.h"
3
3
 
4
+ #ifdef LIBXML_WRITER_ENABLED
5
+ #include <libxml/xmlwriter.h>
6
+ #endif
7
+
4
8
  VALUE cXMLWriter;
5
9
  static VALUE sEncoding, sStandalone;
6
10
 
@@ -1,10 +1,6 @@
1
1
  #ifndef __RXML_WRITER__
2
2
  #define __RXML_WRITER__
3
3
 
4
- #ifdef LIBXML_WRITER_ENABLED
5
- #include <libxml/xmlwriter.h>
6
- #endif
7
-
8
4
  extern VALUE cXMLWriter;
9
5
  void rxml_init_writer(void);
10
6
  #endif
@@ -1,6 +1,10 @@
1
1
  #include "ruby_libxml.h"
2
2
  #include "ruby_xml_xinclude.h"
3
3
 
4
+ #ifdef LIBXML_XINCLUDE_ENABLED
5
+ #include <libxml/xinclude.h>
6
+ #endif
7
+
4
8
  VALUE cXMLXInclude;
5
9
 
6
10
  /*
@@ -75,6 +75,7 @@
75
75
  */
76
76
 
77
77
  #include "ruby_libxml.h"
78
+ #include <libxml/xpathInternals.h>
78
79
 
79
80
  VALUE mXPath;
80
81
 
@@ -3,6 +3,8 @@
3
3
  #ifndef __RXML_XPATH__
4
4
  #define __RXML_XPATH__
5
5
 
6
+ #include <libxml/xpath.h>
7
+
6
8
  extern VALUE mXPath;
7
9
 
8
10
  void rxml_init_xpath(void);
@@ -10,6 +10,8 @@
10
10
  #include <st.h>
11
11
  #endif
12
12
 
13
+ #include <libxml/xpathInternals.h>
14
+
13
15
  /*
14
16
  * Document-class: LibXML::XML::XPath::Context
15
17
  *
@@ -1,4 +1,5 @@
1
1
  #include "ruby_libxml.h"
2
+ #include <libxml/xpathInternals.h>
2
3
 
3
4
  /*
4
5
  * Document-class: LibXML::XML::XPath::Object