libxml-ruby 2.3.3-x86-mingw32 → 2.4.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,9 @@
1
+ #ifndef __RXML_SCHEMA_TYPE__
2
+ #define __RXML_SCHEMA_TYPE__
3
+
4
+ extern VALUE cXMLSchemaType;
5
+
6
+ VALUE rxml_wrap_schema_type(xmlSchemaTypePtr xtype);
7
+ void rxml_init_schema_type(void);
8
+
9
+ #endif
@@ -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 "2.3.3"
5
- #define RUBY_LIBXML_VERNUM 233
4
+ #define RUBY_LIBXML_VERSION "2.4.0"
5
+ #define RUBY_LIBXML_VERNUM 240
6
6
  #define RUBY_LIBXML_VER_MAJ 2
7
- #define RUBY_LIBXML_VER_MIN 3
8
- #define RUBY_LIBXML_VER_MIC 3
7
+ #define RUBY_LIBXML_VER_MIN 4
8
+ #define RUBY_LIBXML_VER_MIC 0
9
9
  #define RUBY_LIBXML_VER_PATCH 0
Binary file
Binary file
Binary file
data/lib/libxml.rb CHANGED
@@ -25,5 +25,11 @@ require 'libxml/sax_parser'
25
25
  require 'libxml/sax_callbacks'
26
26
  require 'libxml/xpath_object'
27
27
 
28
+ #Schema Interface
29
+ require 'libxml/schema'
30
+ require 'libxml/schema/type'
31
+ require 'libxml/schema/element'
32
+ require 'libxml/schema/attribute'
33
+
28
34
  # Deprecated
29
35
  require 'libxml/properties'
@@ -0,0 +1,67 @@
1
+ module LibXML
2
+ module XML
3
+ class Schema
4
+ module Types
5
+ XML_SCHEMA_TYPE_BASIC = 1 # A built-in datatype
6
+ XML_SCHEMA_TYPE_ANY = 2
7
+ XML_SCHEMA_TYPE_FACET = 3
8
+ XML_SCHEMA_TYPE_SIMPLE = 4
9
+ XML_SCHEMA_TYPE_COMPLEX = 5
10
+ XML_SCHEMA_TYPE_SEQUENCE = 6
11
+ XML_SCHEMA_TYPE_CHOICE = 7
12
+ XML_SCHEMA_TYPE_ALL = 8
13
+ XML_SCHEMA_TYPE_SIMPLE_CONTENT = 9
14
+ XML_SCHEMA_TYPE_COMPLEX_CONTENT = 10
15
+ XML_SCHEMA_TYPE_UR = 11
16
+ XML_SCHEMA_TYPE_RESTRICTION = 12
17
+ XML_SCHEMA_TYPE_EXTENSION = 13
18
+ XML_SCHEMA_TYPE_ELEMENT = 14
19
+ XML_SCHEMA_TYPE_ATTRIBUTE = 15
20
+ XML_SCHEMA_TYPE_ATTRIBUTEGROUP = 16
21
+ XML_SCHEMA_TYPE_GROUP = 17
22
+ XML_SCHEMA_TYPE_NOTATION = 18
23
+ XML_SCHEMA_TYPE_LIST = 19
24
+ XML_SCHEMA_TYPE_UNION = 20
25
+ XML_SCHEMA_TYPE_ANY_ATTRIBUTE = 21
26
+ XML_SCHEMA_TYPE_IDC_UNIQUE = 22
27
+ XML_SCHEMA_TYPE_IDC_KEY = 23
28
+ XML_SCHEMA_TYPE_IDC_KEYREF = 24
29
+ XML_SCHEMA_TYPE_PARTICLE = 25
30
+ XML_SCHEMA_TYPE_ATTRIBUTE_USE = 26
31
+ XML_SCHEMA_FACET_MININCLUSIVE = 1000
32
+ XML_SCHEMA_FACET_MINEXCLUSIVE = 1001
33
+ XML_SCHEMA_FACET_MAXINCLUSIVE = 1002
34
+ XML_SCHEMA_FACET_MAXEXCLUSIVE = 1003
35
+ XML_SCHEMA_FACET_TOTALDIGITS = 1004
36
+ XML_SCHEMA_FACET_FRACTIONDIGITS = 1005
37
+ XML_SCHEMA_FACET_PATTERN = 1006
38
+ XML_SCHEMA_FACET_ENUMERATION = 1007
39
+ XML_SCHEMA_FACET_WHITESPACE = 1008
40
+ XML_SCHEMA_FACET_LENGTH = 1009
41
+ XML_SCHEMA_FACET_MAXLENGTH = 1010
42
+ XML_SCHEMA_FACET_MINLENGTH = 1011
43
+ XML_SCHEMA_EXTRA_QNAMEREF = 2000
44
+ XML_SCHEMA_EXTRA_ATTR_USE_PROHIB = 2001
45
+ end
46
+
47
+ class Namespaces < Array
48
+ def find_by_href(href)
49
+ find { |n| n.href == href }
50
+ end
51
+
52
+ def find_by_prefix(prefix)
53
+ find { |n| n.prefix == prefix }
54
+ end
55
+ end
56
+
57
+ def namespaces
58
+ Namespaces.new(_namespaces.uniq { |n| n.href })
59
+ end
60
+
61
+ def self.cached(location)
62
+ @_schemas ||= {}
63
+ @_schemas[location] ||= new(location)
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,19 @@
1
+ # encoding: UTF-8
2
+
3
+ module LibXML
4
+ module XML
5
+ class Schema::Attribute
6
+ REQUIRED = 1
7
+ OPTIONAL = 2
8
+
9
+ def default
10
+ node['default']
11
+ end
12
+
13
+ def required?
14
+ occurs == REQUIRED
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,27 @@
1
+ # encoding: UTF-8
2
+
3
+ module LibXML
4
+ module XML
5
+ class Schema::Element
6
+ def required?
7
+ !min_occurs.zero?
8
+ end
9
+
10
+ def array?
11
+ max_occurs > 1
12
+ end
13
+
14
+ def elements
15
+ type.elements
16
+ end
17
+
18
+ def annotation
19
+ return if node.nil?
20
+ annotations = node.children.select { |n| n.name == 'annotation' }
21
+ annotations.map do |annotation|
22
+ annotation.children.map(&:content).join("\n")
23
+ end.join("\n")
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,29 @@
1
+ module LibXML
2
+ module XML
3
+ class Schema::Type
4
+ def kind_name
5
+ Schema::Types.constants.find { |k| Schema::Types.const_get(k) == kind }
6
+ end
7
+
8
+ def annotation
9
+ return if node.nil?
10
+ annotations = node.children.select { |n| n.name == 'annotation' }
11
+ annotations.map do |annotation|
12
+ annotation.children.map(&:content).join("\n")
13
+ end.join("\n")
14
+ end
15
+
16
+ def annonymus_subtypes
17
+ elements.select { |_, e| e.type.name.nil? }
18
+ end
19
+
20
+ def annonymus_subtypes_recursively(parent=nil)
21
+ annonymus_subtypes.map do |element_name, e|
22
+ [{[parent, element_name].compact.join('::') => e.type},
23
+ e.type.annonymus_subtypes_recursively(element_name)]
24
+ end.flatten
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -1,31 +1,40 @@
1
1
  <?xml version="1.0" encoding="iso-8859-1" ?>
2
2
  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
3
- <xs:element name="shiporder">
4
- <xs:complexType>
5
- <xs:sequence>
6
- <xs:element name="orderperson" type="xs:string"/>
7
- <xs:element name="shipto">
8
- <xs:complexType>
9
- <xs:sequence>
10
- <xs:element name="name" type="xs:string"/>
11
- <xs:element name="address" type="xs:string"/>
12
- <xs:element name="city" type="xs:string"/>
13
- <xs:element name="country" type="xs:string"/>
14
- </xs:sequence>
15
- </xs:complexType>
16
- </xs:element>
17
- <xs:element name="item" maxOccurs="unbounded">
18
- <xs:complexType>
19
- <xs:sequence>
20
- <xs:element name="title" type="xs:string"/>
21
- <xs:element name="note" type="xs:string" minOccurs="0"/>
22
- <xs:element name="quantity" type="xs:positiveInteger"/>
23
- <xs:element name="price" type="xs:decimal"/>
24
- </xs:sequence>
25
- </xs:complexType>
26
- </xs:element>
27
- </xs:sequence>
28
- <xs:attribute name="orderid" type="xs:string" use="required"/>
29
- </xs:complexType>
30
- </xs:element>
3
+ <xs:element name="shiporder" type="shiporder"/>
4
+
5
+ <xs:complexType name="shiporder">
6
+ <xs:annotation>
7
+ <xs:documentation>Shiporder type documentation</xs:documentation>
8
+ </xs:annotation>
9
+ <xs:sequence>
10
+ <xs:element name="orderperson" type="xs:string">
11
+ <xs:annotation>
12
+ <xs:documentation>orderperson element documentation</xs:documentation>
13
+ </xs:annotation>
14
+ </xs:element>
15
+ <xs:element name="shipto">
16
+ <xs:complexType>
17
+ <xs:sequence>
18
+ <xs:element name="name" type="xs:string"/>
19
+ <xs:element name="address" type="xs:string"/>
20
+ <xs:element name="city" type="xs:string"/>
21
+ <xs:element name="country" type="xs:string"/>
22
+ </xs:sequence>
23
+ </xs:complexType>
24
+ </xs:element>
25
+ <xs:element name="item" maxOccurs="unbounded">
26
+ <xs:complexType>
27
+ <xs:sequence>
28
+ <xs:element name="title" type="xs:string"/>
29
+ <xs:element name="note" type="xs:string" minOccurs="0"/>
30
+ <xs:element name="quantity" type="xs:positiveInteger"/>
31
+ <xs:element name="price" type="xs:decimal"/>
32
+ </xs:sequence>
33
+ </xs:complexType>
34
+ </xs:element>
35
+ </xs:sequence>
36
+ <xs:attribute name="orderid" type="xs:string" use="required"/>
37
+ <xs:attribute name="foo" default="1" type="xs:integer" use="optional"/>
38
+ <xs:attribute name="bar" use="prohibited"/>
39
+ </xs:complexType>
31
40
  </xs:schema>
data/test/tc_encoding.rb CHANGED
@@ -118,4 +118,9 @@ class TestEncoding < Test::Unit::TestCase
118
118
  assert_equal("109 246 116 108 101 121 95 99 114 252 101",
119
119
  name.bytes.to_a.join(" "))
120
120
  end
121
- end
121
+
122
+ def test_encoding_conversions
123
+ assert_equal("UTF-8", XML::Encoding.to_s(XML::Encoding::UTF_8))
124
+ assert_equal(XML::Encoding::UTF_8, XML::Encoding.from_s("UTF-8"))
125
+ end
126
+ end
@@ -99,7 +99,7 @@ class HTMLParserTest < Test::Unit::TestCase
99
99
  <body>Hello<br>World</html>
100
100
  EOS
101
101
 
102
- parser = XML::HTMLParser.string(html)
102
+ parser = XML::HTMLParser.string(html, :options => XML::HTMLParser::Options::NOBLANKS)
103
103
  doc = parser.parse
104
104
  assert_instance_of XML::Document, doc
105
105
 
data/test/tc_node.rb CHANGED
@@ -206,4 +206,11 @@ class TestNode < Test::Unit::TestCase
206
206
  text_node = node.first
207
207
  assert(text_node.empty?)
208
208
  end
209
- end
209
+
210
+ def test_set_content
211
+ node = XML::Node.new('test')
212
+ node.content = "unescaped & string"
213
+ assert_equal("unescaped & string", node.content)
214
+ assert_equal("<test>unescaped &amp; string</test>", node.to_s)
215
+ end
216
+ end
data/test/tc_schema.rb CHANGED
@@ -8,17 +8,17 @@ class TestSchema < Test::Unit::TestCase
8
8
  file = File.join(File.dirname(__FILE__), 'model/shiporder.xml')
9
9
  @doc = XML::Document.file(file)
10
10
  end
11
-
11
+
12
12
  def teardown
13
13
  @doc = nil
14
14
  end
15
-
15
+
16
16
  def schema
17
17
  document = XML::Document.file(File.join(File.dirname(__FILE__), 'model/shiporder.xsd'))
18
18
  XML::Schema.document(document)
19
19
  end
20
20
 
21
- def check_error(error)
21
+ def check_error(error)
22
22
  assert_not_nil(error)
23
23
  assert(error.message.match(/Error: Element 'invalid': This element is not expected. Expected is \( item \)/))
24
24
  assert_kind_of(XML::Error, error)
@@ -26,7 +26,6 @@ class TestSchema < Test::Unit::TestCase
26
26
  assert_equal(XML::Error::SCHEMAV_ELEMENT_CONTENT, error.code)
27
27
  assert_equal(XML::Error::ERROR, error.level)
28
28
  assert(error.file.match(/shiporder.xml/)) if error.file
29
- assert_nil(error.line)
30
29
  assert_nil(error.str1)
31
30
  assert_nil(error.str2)
32
31
  assert_nil(error.str3)
@@ -51,6 +50,7 @@ class TestSchema < Test::Unit::TestCase
51
50
  end
52
51
 
53
52
  check_error(error)
53
+ assert_nil(error.line)
54
54
  assert_not_nil(error.node)
55
55
  assert_equal('invalid', error.node.name)
56
56
  end
@@ -84,7 +84,79 @@ class TestSchema < Test::Unit::TestCase
84
84
 
85
85
  error = errors.first
86
86
  check_error(error)
87
+ assert_equal(21, error.line)
87
88
  ensure
88
89
  XML::Error.set_handler(&LibXML::XML::Error::VERBOSE_HANDLER)
89
90
  end
91
+
92
+
93
+ # Schema meta-data tests
94
+
95
+ def test_elements
96
+ assert_instance_of(Hash, schema.elements)
97
+ assert_equal(1, schema.elements.length)
98
+ assert_instance_of(XML::Schema::Element, schema.elements['shiporder'])
99
+ end
100
+
101
+ def test_types
102
+ assert_instance_of(Hash, schema.types)
103
+ assert_equal(1, schema.types.length)
104
+ assert_instance_of(XML::Schema::Type, schema.types['shiporder'])
105
+ end
106
+
107
+ def test_schema_type
108
+ type = schema.types['shiporder']
109
+
110
+ assert_equal('shiporder', type.name)
111
+ assert_equal(nil, type.namespace)
112
+ assert_equal("Shiporder type documentation", type.annotation)
113
+ assert_instance_of(XML::Node, type.node)
114
+ assert_equal(XML::Schema::Types::XML_SCHEMA_TYPE_COMPLEX, type.kind)
115
+ assert_instance_of(XML::Schema::Type, type.base)
116
+ assert_equal("anyType", type.base.name)
117
+ assert_equal(XML::Schema::Types::XML_SCHEMA_TYPE_BASIC, type.base.kind)
118
+
119
+ assert_instance_of(Hash, type.elements)
120
+ assert_equal(3, type.elements.length)
121
+ end
122
+
123
+ def test_schema_element
124
+ element = schema.types['shiporder'].elements['orderperson']
125
+
126
+ assert_equal('orderperson', element.name)
127
+ assert_equal(nil, element.namespace)
128
+ assert_equal("orderperson element documentation", element.annotation)
129
+ assert_equal(1, element.min_occurs)
130
+ assert_equal(1, element.max_occurs)
131
+
132
+
133
+ element = schema.types['shiporder'].elements['item']
134
+ assert_equal(Float::INFINITY, element.max_occurs)
135
+
136
+ element = schema.types['shiporder'].elements['item'].type.elements['note']
137
+ assert_equal(0, element.min_occurs)
138
+ assert_equal('string', element.type.name)
139
+ end
140
+
141
+ def test_schema_attributes
142
+ type = schema.types['shiporder']
143
+
144
+ assert_instance_of(Array, type.attributes)
145
+ assert_equal(2, type.attributes.length)
146
+ assert_instance_of(XML::Schema::Attribute, type.attributes.first)
147
+ end
148
+
149
+ def test_schema_attribute
150
+ attribute = schema.types['shiporder'].attributes.first
151
+
152
+ assert_equal("orderid", attribute.name)
153
+ assert_equal(nil, attribute.namespace)
154
+ assert_equal(1, attribute.occurs)
155
+ assert_equal('string', attribute.type.name)
156
+
157
+ attribute = schema.types['shiporder'].attributes[1]
158
+ assert_equal(2, attribute.occurs)
159
+ assert_equal('1', attribute.default)
160
+ assert_equal('integer', attribute.type.name)
161
+ end
90
162
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libxml-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.3
4
+ version: 2.4.0
5
5
  prerelease:
6
6
  platform: x86-mingw32
7
7
  authors:
@@ -15,7 +15,7 @@ authors:
15
15
  autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
- date: 2012-07-01 00:00:00.000000000 Z
18
+ date: 2012-12-14 00:00:00.000000000 Z
19
19
  dependencies: []
20
20
  description: ! " The Libxml-Ruby project provides Ruby language bindings for the
21
21
  GNOME\n Libxml2 XML toolkit. It is free software, released under the MIT License.\n
@@ -61,6 +61,10 @@ files:
61
61
  - ext/libxml/ruby_xml_sax2_handler.h
62
62
  - ext/libxml/ruby_xml_sax_parser.h
63
63
  - ext/libxml/ruby_xml_schema.h
64
+ - ext/libxml/ruby_xml_schema_attribute.h
65
+ - ext/libxml/ruby_xml_schema_element.h
66
+ - ext/libxml/ruby_xml_schema_facet.h
67
+ - ext/libxml/ruby_xml_schema_type.h
64
68
  - ext/libxml/ruby_xml_version.h
65
69
  - ext/libxml/ruby_xml_xinclude.h
66
70
  - ext/libxml/ruby_xml_xpath.h
@@ -94,6 +98,10 @@ files:
94
98
  - ext/libxml/ruby_xml_sax2_handler.c
95
99
  - ext/libxml/ruby_xml_sax_parser.c
96
100
  - ext/libxml/ruby_xml_schema.c
101
+ - ext/libxml/ruby_xml_schema_attribute.c
102
+ - ext/libxml/ruby_xml_schema_element.c
103
+ - ext/libxml/ruby_xml_schema_facet.c
104
+ - ext/libxml/ruby_xml_schema_type.c
97
105
  - ext/libxml/ruby_xml_xinclude.c
98
106
  - ext/libxml/ruby_xml_xpath.c
99
107
  - ext/libxml/ruby_xml_xpath_context.c
@@ -118,6 +126,10 @@ files:
118
126
  - lib/libxml/reader.rb
119
127
  - lib/libxml/sax_callbacks.rb
120
128
  - lib/libxml/sax_parser.rb
129
+ - lib/libxml/schema/attribute.rb
130
+ - lib/libxml/schema/element.rb
131
+ - lib/libxml/schema/type.rb
132
+ - lib/libxml/schema.rb
121
133
  - lib/libxml/tree.rb
122
134
  - lib/libxml/xpath_object.rb
123
135
  - lib/libxml.rb