rxerces 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e19a59f7418eca81e344bf69e5a60b91a510615979d4716c23eb18cd79fd954f
4
- data.tar.gz: b8d5c62806c094fc61ca00ad47b4347990440d3f208d6e2678c1b26e9453b0e0
3
+ metadata.gz: 8a6f91adbbf73a000b638acc525461a8e0a06ce847bff4f8fd48ad5faf117483
4
+ data.tar.gz: ce10fe12e10294c5012624263cdbc05e4d751c7f62cad3647b2d73f88b19b8ab
5
5
  SHA512:
6
- metadata.gz: e2fd038f7d64bab9017b48b2a20b1abd1df859f6bc21082ae4e73e955f41a2d664eb5991d07bbc5aa1393eb8d72040e1f65358436c424987d1757261f71e086d
7
- data.tar.gz: 1493d18f198efc2bd6bf9f06282d071a96b7edf91f0de4cb5960ceefad6baf394fe3257348b1f835f193a982661be2af12d0dc12b80a9dcc933794d5a521e61f
6
+ metadata.gz: c70510870068a501df10218e42c2eee838df962588929e0731d7e37eb250a80f3e875f77646a254681b976f487435fa531aca4144c1efc39ba22c6ec79c722fc
7
+ data.tar.gz: 47cacc7b927ff6ea7a5c206cd24d2d44fb52bc74ebdb314d05fa67d3bacd8f228113d7053f759626f70acde116ddcfffa194969c85a46a6a8e7e5850f906f36e
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGES.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 0.3.0 - 14-Dec-2025
2
+ * Added Node#parent.
3
+ * Added Element#attributes.
4
+ * Added Node#next_node and Node#next_sibling.
5
+ * Added Node#previous_node and Node#previous_sibling.
6
+ * Added Element#add_child.
7
+ * Added Node#remove and Node#unlink.
8
+ * Added Document#create_element.
9
+ * Added Element#inner_xml and Element#inner_html.
10
+ * Added Node#path.
11
+ * Added Node#blank?
12
+
1
13
  ## 0.2.0 - 13-Dec-2025
2
14
  * The nokogiri compatibility layer is now optional.
3
15
  * Fixed up the gemspec with real values instead of the AI generated junk.
@@ -0,0 +1,107 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/rxerces'
3
+
4
+ # Define an XSD schema
5
+ schema_xsd = <<~XSD
6
+ <?xml version="1.0"?>
7
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
8
+ <xs:element name="person">
9
+ <xs:complexType>
10
+ <xs:sequence>
11
+ <xs:element name="name" type="xs:string"/>
12
+ <xs:element name="age" type="xs:integer"/>
13
+ <xs:element name="email" type="xs:string"/>
14
+ </xs:sequence>
15
+ </xs:complexType>
16
+ </xs:element>
17
+ </xs:schema>
18
+ XSD
19
+
20
+ puts "=" * 60
21
+ puts "RXerces Schema Validation Example"
22
+ puts "=" * 60
23
+
24
+ # Create a schema from the XSD
25
+ puts "\nCreating schema from XSD..."
26
+ schema = RXerces::XML::Schema.from_string(schema_xsd)
27
+ puts "✓ Schema created successfully"
28
+
29
+ # Test 1: Valid document
30
+ puts "\n" + "-" * 60
31
+ puts "Test 1: Validating a VALID document"
32
+ puts "-" * 60
33
+
34
+ valid_xml = <<~XML
35
+ <?xml version="1.0"?>
36
+ <person>
37
+ <name>John Doe</name>
38
+ <age>30</age>
39
+ <email>john@example.com</email>
40
+ </person>
41
+ XML
42
+
43
+ doc = RXerces::XML::Document.parse(valid_xml)
44
+ errors = doc.validate(schema)
45
+ if errors.empty?
46
+ puts "✓ Document is VALID (no validation errors)"
47
+ else
48
+ puts "✗ Document has validation errors:"
49
+ errors.each { |error| puts " - #{error}" }
50
+ end
51
+
52
+ # Test 2: Invalid document (missing required element)
53
+ puts "\n" + "-" * 60
54
+ puts "Test 2: Validating an INVALID document (missing 'email')"
55
+ puts "-" * 60
56
+
57
+ invalid_xml = <<~XML
58
+ <?xml version="1.0"?>
59
+ <person>
60
+ <name>Jane Doe</name>
61
+ <age>25</age>
62
+ </person>
63
+ XML
64
+
65
+ doc2 = RXerces::XML::Document.parse(invalid_xml)
66
+ errors2 = doc2.validate(schema)
67
+ if errors2.empty?
68
+ puts "✓ Document is VALID (no validation errors)"
69
+ else
70
+ puts "✗ Document has validation errors (as expected):"
71
+ errors2.each { |error| puts " - #{error}" }
72
+ end
73
+
74
+ # Test 3: Invalid document (wrong type)
75
+ puts "\n" + "-" * 60
76
+ puts "Test 3: Validating an INVALID document (wrong type for 'age')"
77
+ puts "-" * 60
78
+
79
+ invalid_xml2 = <<~XML
80
+ <?xml version="1.0"?>
81
+ <person>
82
+ <name>Bob Smith</name>
83
+ <age>not-a-number</age>
84
+ <email>bob@example.com</email>
85
+ </person>
86
+ XML
87
+
88
+ doc3 = RXerces::XML::Document.parse(invalid_xml2)
89
+ errors3 = doc3.validate(schema)
90
+ if errors3.empty?
91
+ puts "✓ Document is VALID (no validation errors)"
92
+ else
93
+ puts "✗ Document has validation errors (as expected):"
94
+ errors3.each { |error| puts " - #{error}" }
95
+ end
96
+
97
+ # You can also create a schema from a document
98
+ puts "\n" + "-" * 60
99
+ puts "Creating schema from a Document object..."
100
+ puts "-" * 60
101
+ schema_doc = RXerces::XML::Document.parse(schema_xsd)
102
+ schema2 = RXerces::XML::Schema.from_document(schema_doc)
103
+ puts "✓ Schema created from Document"
104
+
105
+ puts "\n" + "=" * 60
106
+ puts "Full XSD validation is now implemented using Xerces-C!"
107
+ puts "=" * 60