slaw 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.
@@ -0,0 +1,120 @@
1
+ <?xml version='1.0'?>
2
+ <xs:schema targetNamespace="http://www.w3.org/XML/1998/namespace" xmlns:xs="http://www.w3.org/2001/XMLSchema"
3
+ xml:lang="en">
4
+
5
+ <xs:annotation>
6
+ <xs:documentation>
7
+ See http://www.w3.org/XML/1998/namespace.html and
8
+ http://www.w3.org/TR/REC-xml for information about this namespace.
9
+
10
+ This schema document describes the XML namespace, in a form
11
+ suitable for import by other schema documents.
12
+
13
+ Note that local names in this namespace are intended to be defined
14
+ only by the World Wide Web Consortium or its subgroups. The
15
+ following names are currently defined in this namespace and should
16
+ not be used with conflicting semantics by any Working Group,
17
+ specification, or document instance:
18
+
19
+ base (as an attribute name): denotes an attribute whose value
20
+ provides a URI to be used as the base for interpreting any
21
+ relative URIs in the scope of the element on which it
22
+ appears; its value is inherited. This name is reserved
23
+ by virtue of its definition in the XML Base specification.
24
+
25
+ lang (as an attribute name): denotes an attribute whose value
26
+ is a language code for the natural language of the content of
27
+ any element; its value is inherited. This name is reserved
28
+ by virtue of its definition in the XML specification.
29
+
30
+ space (as an attribute name): denotes an attribute whose
31
+ value is a keyword indicating what whitespace processing
32
+ discipline is intended for the content of the element; its
33
+ value is inherited. This name is reserved by virtue of its
34
+ definition in the XML specification.
35
+
36
+ Father (in any context at all): denotes Jon Bosak, the chair of
37
+ the original XML Working Group. This name is reserved by
38
+ the following decision of the W3C XML Plenary and
39
+ XML Coordination groups:
40
+
41
+ In appreciation for his vision, leadership and dedication
42
+ the W3C XML Plenary on this 10th day of February, 2000
43
+ reserves for Jon Bosak in perpetuity the XML name
44
+ xml:Father
45
+ </xs:documentation>
46
+ </xs:annotation>
47
+
48
+ <xs:annotation>
49
+ <xs:documentation>This schema defines attributes and an attribute group
50
+ suitable for use by
51
+ schemas wishing to allow xml:base, xml:lang or xml:space attributes
52
+ on elements they define.
53
+
54
+ To enable this, such a schema must import this schema
55
+ for the XML namespace, e.g. as follows:
56
+ &lt;schema . . .>
57
+ . . .
58
+ &lt;import namespace="http://www.w3.org/XML/1998/namespace"
59
+ schemaLocation="http://www.w3.org/2001/03/xml.xsd"/>
60
+
61
+ Subsequently, qualified reference to any of the attributes
62
+ or the group defined below will have the desired effect, e.g.
63
+
64
+ &lt;type . . .>
65
+ . . .
66
+ &lt;attributeGroup ref="xml:specialAttrs"/>
67
+
68
+ will define a type which will schema-validate an instance
69
+ element with any of those attributes
70
+ </xs:documentation>
71
+ </xs:annotation>
72
+
73
+ <xs:annotation>
74
+ <xs:documentation>In keeping with the XML Schema WG's standard versioning
75
+ policy, this schema document will persist at
76
+ http://www.w3.org/2001/03/xml.xsd.
77
+ At the date of issue it can also be found at
78
+ http://www.w3.org/2001/xml.xsd.
79
+ The schema document at that URI may however change in the future,
80
+ in order to remain compatible with the latest version of XML Schema
81
+ itself. In other words, if the XML Schema namespace changes, the version
82
+ of this document at
83
+ http://www.w3.org/2001/xml.xsd will change
84
+ accordingly; the version at
85
+ http://www.w3.org/2001/03/xml.xsd will not change.
86
+ </xs:documentation>
87
+ </xs:annotation>
88
+
89
+ <xs:attribute name="lang" type="xs:language">
90
+ <xs:annotation>
91
+ <xs:documentation>In due course, we should install the relevant ISO 2- and 3-letter
92
+ codes as the enumerated possible values . . .
93
+ </xs:documentation>
94
+ </xs:annotation>
95
+ </xs:attribute>
96
+
97
+ <xs:attribute name="space" default="preserve">
98
+ <xs:simpleType>
99
+ <xs:restriction base="xs:NCName">
100
+ <xs:enumeration value="default"/>
101
+ <xs:enumeration value="preserve"/>
102
+ </xs:restriction>
103
+ </xs:simpleType>
104
+ </xs:attribute>
105
+
106
+ <xs:attribute name="base" type="xs:anyURI">
107
+ <xs:annotation>
108
+ <xs:documentation>See http://www.w3.org/TR/xmlbase/ for
109
+ information about this attribute.
110
+ </xs:documentation>
111
+ </xs:annotation>
112
+ </xs:attribute>
113
+
114
+ <xs:attributeGroup name="specialAttrs">
115
+ <xs:attribute ref="xml:base"/>
116
+ <xs:attribute ref="xml:lang"/>
117
+ <xs:attribute ref="xml:space"/>
118
+ </xs:attributeGroup>
119
+
120
+ </xs:schema>
data/lib/slaw/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Slaw
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -0,0 +1,68 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'spec_helper'
4
+ require 'slaw'
5
+
6
+ describe Slaw::ByLaw do
7
+ let(:filename) { File.dirname(__FILE__) + "/fixtures/community-fire-safety.xml" }
8
+ subject { Slaw::ByLaw.new(filename) }
9
+
10
+ it 'should have correct basic properties' do
11
+ subject.title.should == 'Community Fire Safety By-law as amended'
12
+ subject.amended?.should be_true
13
+ end
14
+
15
+ it 'should set the title correctly' do
16
+ subject.title = 'foo'
17
+ subject.meta.at_xpath('./a:identification/a:FRBRWork/a:FRBRalias', a: Slaw::NS)['value'].should == 'foo'
18
+ end
19
+
20
+ it 'should set the title if it doesnt exist' do
21
+ subject.meta.at_xpath('./a:identification/a:FRBRWork/a:FRBRalias', a: Slaw::NS).remove
22
+ subject.title = 'bar'
23
+ subject.title.should == 'bar as amended'
24
+ end
25
+
26
+ it 'should set the publication details' do
27
+ subject.meta.at_xpath('./a:publication', a: Slaw::NS).remove
28
+
29
+ subject.published!(name: 'foo', number: '1234', date: '2014-01-01')
30
+ subject.publication['name'].should == 'foo'
31
+ subject.publication['showAs'].should == 'foo'
32
+ subject.publication['number'].should == '1234'
33
+ end
34
+
35
+ it 'should get/set the work date' do
36
+ subject.date.should == '2002-02-28'
37
+
38
+ subject.date = '2014-01-01'
39
+ subject.date.should == '2014-01-01'
40
+ subject.meta.at_xpath('./a:identification/a:FRBRWork/a:FRBRdate[@name="Generation"]', a: Slaw::NS)['date'].should == '2014-01-01'
41
+ subject.meta.at_xpath('./a:identification/a:FRBRExpression/a:FRBRdate[@name="Generation"]', a: Slaw::NS)['date'].should == '2014-01-01'
42
+
43
+ subject.id_uri.should == '/za/by-law/cape-town/2014/community-fire-safety'
44
+ end
45
+
46
+ it 'should update the uri when the year changes' do
47
+ subject.id_uri.should == '/za/by-law/cape-town/2002/community-fire-safety'
48
+ subject.year = '1980'
49
+ subject.id_uri.should == '/za/by-law/cape-town/1980/community-fire-safety'
50
+ end
51
+
52
+ it 'should update the uri when the region changes' do
53
+ subject.id_uri.should == '/za/by-law/cape-town/2002/community-fire-safety'
54
+ subject.region = 'foo-bar'
55
+ subject.id_uri.should == '/za/by-law/foo-bar/2002/community-fire-safety'
56
+ end
57
+
58
+ it 'should update the uri when the name changes' do
59
+ subject.id_uri.should == '/za/by-law/cape-town/2002/community-fire-safety'
60
+ subject.name = 'foo-bar'
61
+ subject.id_uri.should == '/za/by-law/cape-town/2002/foo-bar'
62
+ end
63
+
64
+ it 'should validate' do
65
+ subject.validate.should == []
66
+ subject.validates?.should be_true
67
+ end
68
+ end