rdf 3.0.13 → 3.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/AUTHORS +1 -1
- data/README.md +46 -11
- data/VERSION +1 -1
- data/etc/doap.nt +74 -80
- data/lib/rdf.rb +32 -23
- data/lib/rdf/changeset.rb +87 -19
- data/lib/rdf/cli.rb +6 -6
- data/lib/rdf/format.rb +17 -10
- data/lib/rdf/mixin/enumerable.rb +3 -2
- data/lib/rdf/mixin/mutable.rb +5 -15
- data/lib/rdf/mixin/queryable.rb +12 -4
- data/lib/rdf/mixin/writable.rb +9 -14
- data/lib/rdf/model/dataset.rb +1 -1
- data/lib/rdf/model/graph.rb +5 -2
- data/lib/rdf/model/list.rb +5 -5
- data/lib/rdf/model/statement.rb +30 -7
- data/lib/rdf/model/uri.rb +42 -23
- data/lib/rdf/nquads.rb +6 -6
- data/lib/rdf/ntriples.rb +6 -4
- data/lib/rdf/ntriples/reader.rb +32 -7
- data/lib/rdf/ntriples/writer.rb +10 -1
- data/lib/rdf/query.rb +27 -35
- data/lib/rdf/query/hash_pattern_normalizer.rb +14 -12
- data/lib/rdf/query/pattern.rb +51 -18
- data/lib/rdf/query/solution.rb +20 -1
- data/lib/rdf/query/solutions.rb +15 -5
- data/lib/rdf/query/variable.rb +17 -5
- data/lib/rdf/reader.rb +76 -25
- data/lib/rdf/repository.rb +32 -18
- data/lib/rdf/transaction.rb +1 -1
- data/lib/rdf/util.rb +6 -5
- data/lib/rdf/util/cache.rb +2 -2
- data/lib/rdf/util/coercions.rb +60 -0
- data/lib/rdf/util/file.rb +2 -2
- data/lib/rdf/util/logger.rb +7 -7
- data/lib/rdf/vocab/owl.rb +401 -86
- data/lib/rdf/vocab/rdfs.rb +81 -18
- data/lib/rdf/vocab/rdfv.rb +147 -1
- data/lib/rdf/vocab/writer.rb +43 -4
- data/lib/rdf/vocab/xsd.rb +203 -2
- data/lib/rdf/vocabulary.rb +108 -14
- data/lib/rdf/writer.rb +32 -10
- metadata +28 -27
data/lib/rdf/vocab/xsd.rb
CHANGED
@@ -5,9 +5,210 @@ require 'rdf'
|
|
5
5
|
module RDF
|
6
6
|
# @!parse
|
7
7
|
# # Vocabulary for <http://www.w3.org/2001/XMLSchema#>
|
8
|
+
# #
|
8
9
|
# class XSD < RDF::Vocabulary
|
10
|
+
# # `ENTITIES` represents the `ENTITIES` attribute type from [XML](http://www.w3.org/TR/2000/WD-xml-2e-20000814). The ·value space· of `ENTITIES` is the set of finite, non-zero-length sequences of ·{ENTITY}· values that have been declared as unparsed entities in a document type definition. The ·lexical space· of `ENTITIES` is the set of space-separated lists of tokens, of which each token is in the ·lexical space· of {ENTITY}. The ·item type· of `ENTITIES` is {ENTITY}. `ENTITIES` is derived from ·{anySimpleType}· in two steps: an anonymous list type is defined, whose ·item type· is {ENTITY}; this is the ·base type· of `ENTITIES`, which restricts its value space to lists with at least one item.
|
11
|
+
# # @return [RDF::Vocabulary::Term]
|
12
|
+
# attr_reader :ENTITIES
|
13
|
+
#
|
14
|
+
# # `ENTITY` represents the `ENTITY` attribute type from [XML](http://www.w3.org/TR/2000/WD-xml-2e-20000814). The ·value space· of `ENTITY` is the set of all strings that ·match· the `NCName` production in [Namespaces in XML](http://www.w3.org/TR/1999/REC-xml-names-19990114/) and have been declared as an unparsed entity in a document type definition. The ·lexical space· of `ENTITY` is the set of all strings that ·match· the `NCName` production in [Namespaces in XML](http://www.w3.org/TR/1999/REC-xml-names-19990114/). The ·base type· of `ENTITY` is {NCName}.
|
15
|
+
# # @return [RDF::Vocabulary::Term]
|
16
|
+
# attr_reader :ENTITY
|
17
|
+
#
|
18
|
+
# # `ID` represents the ID attribute type from [XML](http://www.w3.org/TR/2000/WD-xml-2e-20000814). The ·value space· of `ID` is the set of all strings that ·match· the `NCName` production in [Namespaces in XML]. The ·lexical space· of `ID` is the set of all strings that ·match· the `NCName` production in [Namespaces in XML](http://www.w3.org/TR/1999/REC-xml-names-19990114/). The ·base type· of `ID` is {NCName}.
|
19
|
+
# # @return [RDF::Vocabulary::Term]
|
20
|
+
# attr_reader :ID
|
21
|
+
#
|
22
|
+
# # `IDREF` represents the `IDRE`F attribute type from [XML](http://www.w3.org/TR/2000/WD-xml-2e-20000814). The ·value space· of `IDREF` is the set of all strings that ·match· the `NCName` production in [Namespaces in XML](http://www.w3.org/TR/1999/REC-xml-names-19990114/). The ·lexical space· of `IDREF` is the set of strings that ·match· the `NCName` production in [Namespaces in XML](http://www.w3.org/TR/1999/REC-xml-names-19990114/). The ·base type· of `IDREF` is {NCName}.
|
23
|
+
# # @return [RDF::Vocabulary::Term]
|
24
|
+
# attr_reader :IDREF
|
25
|
+
#
|
26
|
+
# # `IDREFS` represents the `IDREFS` attribute type from [XML](http://www.w3.org/TR/2000/WD-xml-2e-20000814). The ·value space· of `IDREFS` is the set of finite, non-zero-length sequences of `IDREFs`. The ·lexical space· of `IDREFS` is the set of space-separated lists of tokens, of which each token is in the ·lexical space· of `IDREF.` The ·item type· of `IDREFS` is {IDREF}. `IDREFS` is derived from ·{anySimpleType}· in two steps: an anonymous list type is defined, whose ·item type· is {IDREF}; this is the ·base type· of `IDREFS`, which restricts its value space to lists with at least one item.
|
27
|
+
# # @return [RDF::Vocabulary::Term]
|
28
|
+
# attr_reader :IDREFS
|
29
|
+
#
|
30
|
+
# # `NCName` represents XML "non-colonized" `Names`. The ·value space· of `NCName` is the set of all strings which ·match· the `NCName` production of [Namespaces in XML](http://www.w3.org/TR/1999/REC-xml-names-19990114/). The ·lexical space· of `NCName` is the set of all strings which ·match· the `NCName` production of [Namespaces in XML](http://www.w3.org/TR/1999/REC-xml-names-19990114/). The ·base type· of `NCName` is {Name}.
|
31
|
+
# # @return [RDF::Vocabulary::Term]
|
32
|
+
# attr_reader :NCName
|
33
|
+
#
|
34
|
+
# # `NMTOKEN` represents the `NMTOKEN` attribute type from [XML](http://www.w3.org/TR/2000/WD-xml-2e-20000814). The ·value space· of `NMTOKEN` is the set of tokens that ·match· the `Nmtoken` production in [XML](http://www.w3.org/TR/2000/WD-xml-2e-20000814). The ·lexical space· of `NMTOKEN` is the set of strings that ·match· the `Nmtoken` production in [XML](http://www.w3.org/TR/2000/WD-xml-2e-20000814). The ·base type· of `NMTOKEN` is {token}.
|
35
|
+
# # @return [RDF::Vocabulary::Term]
|
36
|
+
# attr_reader :NMTOKEN
|
37
|
+
#
|
38
|
+
# # `NMTOKENS` represents the `NMTOKENS` attribute type from [XML](http://www.w3.org/TR/2000/WD-xml-2e-20000814). The ·value space· of `NMTOKENS` is the set of finite, non-zero-length sequences of ·`NMTOKEN`·s. The ·lexical space· of `NMTOKENS` is the set of space-separated lists of tokens, of which each token is in the ·lexical space· of `NMTOKEN`. The ·item type· of `NMTOKENS` is `NMTOKEN`. `NMTOKEN`S is derived from ·{anySimpleType}· in two steps: an anonymous list type is defined, whose ·item type· is `NMTOKEN`; this is the ·base type· of `NMTOKENS`, which restricts its value space to lists with at least one item.
|
39
|
+
# # @return [RDF::Vocabulary::Term]
|
40
|
+
# attr_reader :NMTOKENS
|
41
|
+
#
|
42
|
+
# # `NOTATION` represents the `NOTATION` attribute type from [XML](http://www.w3.org/TR/2000/WD-xml-2e-20000814). The ·value space· of `NOTATION` is the set of `QName`s of notations declared in the current schema. The ·lexical space· of `NOTATION` is the set of all names of notations declared in the current schema (in the form of `QNames`).
|
43
|
+
# # @return [RDF::Vocabulary::Term]
|
44
|
+
# attr_reader :NOTATION
|
45
|
+
#
|
46
|
+
# # `Name` represents XML Names. The ·value space· of `Name` is the set of all strings which ·match· the `Name` production of [XML](http://www.w3.org/TR/2000/WD-xml-2e-20000814)(http://www.w3.org/TR/2000/WD-xml-2e-20000814). The ·lexical space· of `Name` is the set of all strings which ·match· the `Name` production of [XML](http://www.w3.org/TR/2000/WD-xml-2e-20000814). The ·base type· of `Name` is {token}.
|
47
|
+
# # @return [RDF::Vocabulary::Term]
|
48
|
+
# attr_reader :Name
|
49
|
+
#
|
50
|
+
# # `QName` represents XML qualified names. The ·value space· of `QName` is the set of tuples `{namespace name, local part}`, where namespace name is an anyURI and local part is an NCName. The ·lexical space· of `QName` is the set of strings that ·match· the `QName` production of [Namespaces in XML](http://www.w3.org/TR/1999/REC-xml-names-19990114/).
|
51
|
+
# # @return [RDF::Vocabulary::Term]
|
52
|
+
# attr_reader :QName
|
53
|
+
#
|
54
|
+
# # `anyAtomicType` is a special ·restriction· of {anySimpleType}. The ·value· and ·lexical spaces· of `anyAtomicType` are the unions of the ·value· and ·lexical spaces· of all the ·primitive· datatypes, and `anyAtomicType` is their ·base type·.
|
55
|
+
# # @return [RDF::Vocabulary::Term]
|
56
|
+
# attr_reader :anyAtomicType
|
57
|
+
#
|
58
|
+
# # The definition of `anySimpleType` is a special ·restriction· of {anyType}. The ·lexical space· of `anySimpleType` is the set of all sequences of Unicode characters, and its ·value space· includes all ·atomic values· and all finite-length lists of zero or more ·atomic values·.
|
59
|
+
# # @return [RDF::Vocabulary::Term]
|
60
|
+
# attr_reader :anySimpleType
|
61
|
+
#
|
62
|
+
# # The root of the [XML Schema 1.1] datatype heirarchy.
|
63
|
+
# # @return [RDF::Vocabulary::Term]
|
64
|
+
# attr_reader :anyType
|
65
|
+
#
|
66
|
+
# # `anyURI` represents an Internationalized Resource Identifier Reference (`IRI`). An `anyURI` value can be absolute or relative, and may have an optional fragment identifier (i.e., it may be an `IRI Reference`). This type should be used when the value fulfills the role of an `IRI`, as defined in [RFC 2045](https://www.ietf.org/rfc/rfc3987.txt) or its successor(s) in the IETF Standards Track.
|
67
|
+
# # @return [RDF::Vocabulary::Term]
|
68
|
+
# attr_reader :anyURI
|
69
|
+
#
|
70
|
+
# # `base64Binary` represents arbitrary `Base64`-encoded binary data. For `base64Binary` data the entire binary stream is encoded using the `Base64` Encoding defined in [RFC 3548](https://www.ietf.org/rfc/rfc3548.txt), which is derived from the encoding described in [RFC 2045](https://www.ietf.org/rfc/rfc2045.txt).
|
71
|
+
# # @return [RDF::Vocabulary::Term]
|
72
|
+
# attr_reader :base64Binary
|
73
|
+
#
|
74
|
+
# # `boolean` represents the values of two-valued logic.
|
75
|
+
# # @return [RDF::Vocabulary::Term]
|
76
|
+
# attr_reader :boolean
|
77
|
+
#
|
78
|
+
# # ` byte` is ·derived· from short by setting the value of ·`maxInclusive`· to be `127` and ·`minInclusive`· to be `-128`. The ·base type· of `byte` is {short}.
|
79
|
+
# # @return [RDF::Vocabulary::Term]
|
80
|
+
# attr_reader :byte
|
81
|
+
#
|
82
|
+
# # `date` represents top-open intervals of exactly one day in length on the timelines of {dateTime}, beginning on the beginning moment of each day, up to but not including the beginning moment of the next day). For non-timezoned values, the top-open intervals disjointly cover the non-timezoned timeline, one per day. For timezoned values, the intervals begin at every minute and therefore overlap.
|
83
|
+
# # @return [RDF::Vocabulary::Term]
|
84
|
+
# attr_reader :date
|
85
|
+
#
|
86
|
+
# # `dateTime` represents instants of time, optionally marked with a particular time zone offset. Values representing the same instant but having different time zone offsets are equal but not identical.
|
87
|
+
# # @return [RDF::Vocabulary::Term]
|
88
|
+
# attr_reader :dateTime
|
89
|
+
#
|
90
|
+
# # The `dateTimeStamp` datatype is ·derived· from {dateTime} by giving the value required to its explicitTimezone facet. The result is that all values of `dateTimeStamp` are required to have explicit time zone offsets and the datatype is totally ordered.
|
91
|
+
# # @return [RDF::Vocabulary::Term]
|
92
|
+
# attr_reader :dateTimeStamp
|
93
|
+
#
|
94
|
+
# # `dayTimeDuration` is a datatype ·derived· from {duration} by restricting its ·lexical representations· to instances of `dayTimeDurationLexicalRep`. The ·value space· of `dayTimeDuration` is therefore that of {duration} restricted to those whose ·months· property is 0. This results in a {duration} datatype which is totally ordered.
|
95
|
+
# # @return [RDF::Vocabulary::Term]
|
96
|
+
# attr_reader :dayTimeDuration
|
97
|
+
#
|
98
|
+
# # `decimal` represents a subset of the real numbers, which can be represented by decimal numerals. The ·value space· of `decimal` is the set of numbers that can be obtained by dividing an integer by a non-negative power of ten, i.e., expressible as `i / 10n` where `i` and `n` are integers and `n ≥ 0`. Precision is not reflected in this value space; the number `2.0` is not distinct from the number `2.00`. The order relation on `decimal` is the order relation on real numbers, restricted to this subset.
|
99
|
+
# # @return [RDF::Vocabulary::Term]
|
100
|
+
# attr_reader :decimal
|
101
|
+
#
|
102
|
+
# # The `double` datatype is patterned after the IEEE double-precision 64-bit floating point datatype [IEEE 754-2008](https://ieeexplore.ieee.org/document/4610935). Each floating point datatype has a value space that is a subset of the rational numbers. Floating point numbers are often used to approximate arbitrary real numbers.
|
103
|
+
# # @return [RDF::Vocabulary::Term]
|
104
|
+
# attr_reader :double
|
105
|
+
#
|
106
|
+
# # `duration` is a datatype that represents durations of time. The concept of duration being captured is drawn from those of [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html), specifically durations without fixed endpoints. For example, "15 days" (whose most common lexical representation in duration is "'P15D'") is a `duration` value; "15 days beginning 12 July 1995" and "15 days ending 12 July 1995" are not `duration` values. `duration` can provide addition and subtraction operations between duration values and between `duration`/{dateTime} value pairs, and can be the result of subtracting dateTime values. However, only addition to {dateTime} is required for XML Schema processing and is defined in the function ·`dateTimePlusDuration`·.
|
107
|
+
# # @return [RDF::Vocabulary::Term]
|
108
|
+
# attr_reader :duration
|
109
|
+
#
|
110
|
+
# # The `float` datatype is patterned after the IEEE single-precision 32-bit floating point datatype [IEEE 754-2008](https://ieeexplore.ieee.org/document/4610935). Its value space is a subset of the rational numbers. Floating point numbers are often used to approximate arbitrary real numbers.
|
111
|
+
# # @return [RDF::Vocabulary::Term]
|
112
|
+
# attr_reader :float
|
113
|
+
#
|
114
|
+
# # `gDay` represents whole days within an arbitrary month—days that recur at the same point in each (Gregorian) month. This datatype is used to represent a specific day of the month. To indicate, for example, that an employee gets a paycheck on the 15th of each month. (Obviously, days beyond 28 cannot occur in all months; they are nonetheless permitted, up to 31.)
|
115
|
+
# # @return [RDF::Vocabulary::Term]
|
116
|
+
# attr_reader :gDay
|
117
|
+
#
|
118
|
+
# # `gMonth` represents whole (Gregorian) months within an arbitrary year—months that recur at the same point in each year. It might be used, for example, to say what month annual Thanksgiving celebrations fall in different countries (--11 in the United States, --10 in Canada, and possibly other months in other countries).
|
119
|
+
# # @return [RDF::Vocabulary::Term]
|
120
|
+
# attr_reader :gMonth
|
121
|
+
#
|
122
|
+
# # `gMonthDay` represents whole calendar days that recur at the same point in each calendar year, or that occur in some arbitrary calendar year. (Obviously, days beyond 28 cannot occur in all Februaries; 29 is nonetheless permitted.)
|
123
|
+
# # @return [RDF::Vocabulary::Term]
|
124
|
+
# attr_reader :gMonthDay
|
125
|
+
#
|
126
|
+
# # `gYear` represents Gregorian calendar years.
|
127
|
+
# # @return [RDF::Vocabulary::Term]
|
128
|
+
# attr_reader :gYear
|
129
|
+
#
|
130
|
+
# # `gYearMonth` represents specific whole Gregorian months in specific Gregorian years.
|
131
|
+
# # @return [RDF::Vocabulary::Term]
|
132
|
+
# attr_reader :gYearMonth
|
133
|
+
#
|
134
|
+
# # `hexBinary` represents arbitrary hex-encoded binary data.
|
135
|
+
# # @return [RDF::Vocabulary::Term]
|
136
|
+
# attr_reader :hexBinary
|
137
|
+
#
|
138
|
+
# # `int` is ·derived· from long by setting the value of ·`maxInclusive`· to be ``2147483647`` and ·`minInclusive`· to be ``-2147483648``. The ·base type· of `int` is {long}.
|
139
|
+
# # @return [RDF::Vocabulary::Term]
|
140
|
+
# attr_reader :int
|
141
|
+
#
|
142
|
+
# # `integer` is ·derived· from {decimal} by fixing the value of ·`fractionDigits`· to be `0` and disallowing the trailing decimal point. This results in the standard mathematical concept of the integer numbers. The ·value space· of `integer` is the infinite set `{...,-2,-1,0,1,2,...}`. The ·base type· of `integer` is {decimal}.
|
143
|
+
# # @return [RDF::Vocabulary::Term]
|
144
|
+
# attr_reader :integer
|
145
|
+
#
|
146
|
+
# # `language` represents formal natural language identifiers, as defined by [BCP 47](https://tools.ietf.org/html/bcp47) (currently represented by [RFC 2045](https://www.ietf.org/rfc/rfc4646.txt) and [RFC 2045](https://www.ietf.org/rfc/rfc4647.txt)) or its successor(s). The ·value space· and ·lexical space· of `language` are the set of all strings that conform to the pattern `[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*`
|
147
|
+
# # @return [RDF::Vocabulary::Term]
|
148
|
+
# attr_reader :language
|
149
|
+
#
|
150
|
+
# # `long` is ·derived· from {integer} by setting the value of ·`maxInclusive`· to be `9223372036854775807` and ·`minInclusive`· to be `-9223372036854775808`. The ·base type· of `long` is {integer}.
|
151
|
+
# # @return [RDF::Vocabulary::Term]
|
152
|
+
# attr_reader :long
|
153
|
+
#
|
154
|
+
# # `negativeInteger` is ·derived· from {nonPositiveInteger} by setting the value of ·`maxInclusive`· to be `-1`. This results in the standard mathematical concept of the negative integers. The ·value space· of `negativeInteger` is the infinite set `{...,-2,-1}`. The ·base type· of `negativeInteger` is {nonPositiveInteger}.
|
155
|
+
# # @return [RDF::Vocabulary::Term]
|
156
|
+
# attr_reader :negativeInteger
|
157
|
+
#
|
158
|
+
# # `nonNegativeInteger` is ·derived· from {integer} by setting the value of ·`minInclusive`· to be `0`. This results in the standard mathematical concept of the non-negative integers. The ·value space· of `nonNegativeInteger` is the infinite set `{0,1,2,...}`. The ·base type· of `nonNegativeInteger` is {integer}.
|
159
|
+
# # @return [RDF::Vocabulary::Term]
|
160
|
+
# attr_reader :nonNegativeInteger
|
161
|
+
#
|
162
|
+
# # `nonPositiveInteger` is ·derived· from {integer} by setting the value of ·`maxInclusive`· to be `0`. This results in the standard mathematical concept of the non-positive integers. The ·value space· of `nonPositiveInteger` is the infinite set `{...,-2,-1,0}`. The ·base type· of `nonPositiveInteger` is {integer}.
|
163
|
+
# # @return [RDF::Vocabulary::Term]
|
164
|
+
# attr_reader :nonPositiveInteger
|
165
|
+
#
|
166
|
+
# # `normalizedString` represents white space normalized strings. The ·value space· of `normalizedString` is the set of strings that do not contain the carriage return `(#xD)`, line feed `(#xA) no`r tab `(#x9)` characters. The ·lexical space· of `normalizedString` is the set of strings that do not contain the carriage return `(#xD)`, line feed `(#xA)` nor tab `(#x9)` characters. The ·base type· of `normalizedString` is {string}.
|
167
|
+
# # @return [RDF::Vocabulary::Term]
|
168
|
+
# attr_reader :normalizedString
|
169
|
+
#
|
170
|
+
# # `positiveInteger` is ·derived· from `nonNegativeInteger` by setting the value of ·`minInclusive`· to be `1`. This results in the standard mathematical concept of the positive integer numbers. The ·value space· of `positiveInteger` is the infinite set `{1,2,...}`. The ·base type· of `positiveInteger` is {nonNegativeInteger}.
|
171
|
+
# # @return [RDF::Vocabulary::Term]
|
172
|
+
# attr_reader :positiveInteger
|
173
|
+
#
|
174
|
+
# # `short` is ·derived· from `int` by setting the value of ·`maxInclusive`· to be `32767` and ·minInclusive· to be `-32768`. The ·base type· of `short` is {int}.
|
175
|
+
# # @return [RDF::Vocabulary::Term]
|
176
|
+
# attr_reader :short
|
177
|
+
#
|
178
|
+
# # The `string` datatype represents character strings in XML.
|
179
|
+
# # @return [RDF::Vocabulary::Term]
|
180
|
+
# attr_reader :string
|
181
|
+
#
|
182
|
+
# # `time` represents instants of time that recur at the same point in each calendar day, or that occur in some arbitrary calendar day.
|
183
|
+
# # @return [RDF::Vocabulary::Term]
|
184
|
+
# attr_reader :time
|
185
|
+
#
|
186
|
+
# # `token` represents tokenized strings. The ·value space· of `token` is the set of strings that do not contain the carriage return `(#xD)`, line feed `(#xA)` nor tab `(#x9)` characters, that have no leading or trailing spaces `(#x20)` and that have no internal sequences of two or more spaces. The ·lexical space· of `token` is the set of strings that do not contain the carriage return `(#xD)`, line feed `(#xA)` nor tab `(#x9)` characters, that have no leading or trailing spaces `(#x20)` and that have no internal sequences of two or more spaces. The ·base type· of `token` is {normalizedString}.
|
187
|
+
# # @return [RDF::Vocabulary::Term]
|
188
|
+
# attr_reader :token
|
189
|
+
#
|
190
|
+
# # `unsignedByte` is ·derived· from {unsignedShort} by setting the value of ·`maxInclusive`· to be `255`. The ·base type· of `unsignedByte` is {unsignedShort}.
|
191
|
+
# # @return [RDF::Vocabulary::Term]
|
192
|
+
# attr_reader :unsignedByte
|
193
|
+
#
|
194
|
+
# # `unsignedInt` is ·derived· from {unsignedLong} by setting the value of ·`maxInclusive`· to be `4294967295`. The ·base type· of `unsignedInt` is {unsignedLong}.
|
195
|
+
# # @return [RDF::Vocabulary::Term]
|
196
|
+
# attr_reader :unsignedInt
|
197
|
+
#
|
198
|
+
# # `unsignedLong` is ·derived· from {nonNegativeInteger} by setting the value of ·`maxInclusive`· to be `18446744073709551615`. The ·base type· of `unsignedLong` is {nonNegativeInteger}.
|
199
|
+
# # @return [RDF::Vocabulary::Term]
|
200
|
+
# attr_reader :unsignedLong
|
201
|
+
#
|
202
|
+
# # `unsignedShort` is ·derived· from {unsignedInt} by setting the value of ·`maxInclusive`· to be `65535`. The ·base type· of `unsignedShort` is {unsignedInt}.
|
203
|
+
# # @return [RDF::Vocabulary::Term]
|
204
|
+
# attr_reader :unsignedShort
|
205
|
+
#
|
206
|
+
# # `yearMonthDuration` is a datatype ·derived· from {duration} by restricting its ·lexical representations· to instances of `yearMonthDurationLexicalRep`. The ·value space· of `yearMonthDuration` is therefore that of {duration} restricted to those whose ·seconds· property is 0. This results in a duration datatype which is totally ordered.
|
207
|
+
# # @return [RDF::Vocabulary::Term]
|
208
|
+
# attr_reader :yearMonthDuration
|
209
|
+
#
|
9
210
|
# end
|
10
|
-
|
211
|
+
XSD = Class.new(RDF::Vocabulary("http://www.w3.org/2001/XMLSchema#")) do
|
11
212
|
|
12
213
|
# Datatype definitions
|
13
214
|
term :ENTITIES,
|
@@ -190,7 +391,7 @@ module RDF
|
|
190
391
|
comment: %(
|
191
392
|
boolean represents the values of two-valued logic.
|
192
393
|
).freeze,
|
193
|
-
label: "
|
394
|
+
label: "boolean".freeze,
|
194
395
|
subClassOf: "xsd:anyAtomicType".freeze,
|
195
396
|
type: "rdfs:Datatype".freeze
|
196
397
|
term :byte,
|
data/lib/rdf/vocabulary.rb
CHANGED
@@ -58,6 +58,9 @@ module RDF
|
|
58
58
|
class Vocabulary
|
59
59
|
extend ::Enumerable
|
60
60
|
|
61
|
+
autoload :Format, 'rdf/vocab/writer'
|
62
|
+
autoload :Writer, 'rdf/vocab/writer'
|
63
|
+
|
61
64
|
class << self
|
62
65
|
##
|
63
66
|
# Enumerates known RDF vocabulary classes.
|
@@ -67,16 +70,103 @@ module RDF
|
|
67
70
|
# @return [Enumerator]
|
68
71
|
def each(&block)
|
69
72
|
if self.equal?(Vocabulary)
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
73
|
+
if @vocabs
|
74
|
+
@vocabs.select(&:name).each(&block)
|
75
|
+
else
|
76
|
+
# This is needed since all vocabulary classes are defined using
|
77
|
+
# Ruby's autoloading facility, meaning that `@@subclasses` will be
|
78
|
+
# empty until each subclass has been touched or require'd.
|
79
|
+
RDF::VOCABS.each { |v, p| RDF.const_get(p[:class_name].to_sym) unless v == :rdf }
|
80
|
+
@@subclasses.select(&:name).each(&block)
|
81
|
+
end
|
75
82
|
else
|
76
83
|
__properties__.each(&block)
|
77
84
|
end
|
78
85
|
end
|
79
86
|
|
87
|
+
##
|
88
|
+
# A hash of all vocabularies by prefix showing relevant URI and
|
89
|
+
# associated vocabulary Class Name
|
90
|
+
#
|
91
|
+
# @return [Hash{Symbol => Hash{Symbol => String}}]
|
92
|
+
def vocab_map
|
93
|
+
# Create an initial duplicate of RDF::VOCABS. We want to
|
94
|
+
# ensure the hash itself is modifiable but the values are
|
95
|
+
# frozen.
|
96
|
+
@vocab_map ||= RDF::VOCABS.transform_values(&:freeze)
|
97
|
+
end
|
98
|
+
|
99
|
+
##
|
100
|
+
# Return the vocabulary based on it's class_name symbol
|
101
|
+
#
|
102
|
+
# @param [Symbol] sym
|
103
|
+
# @return [RDF::Vocabulary]
|
104
|
+
def from_sym(sym)
|
105
|
+
RDF.const_get(sym.to_sym)
|
106
|
+
end
|
107
|
+
|
108
|
+
##
|
109
|
+
# Register a vocabulary for internal prefix lookups. Parameters
|
110
|
+
# of interest include `:uri`, `:class_name`, `:source`, and `:skip`.
|
111
|
+
#
|
112
|
+
# @param prefix [Symbol] the prefix to use
|
113
|
+
# @param vocab [String, Class] either the URI or the vocab class
|
114
|
+
# @param params [Hash{Symbol => String}] Relevant parameters
|
115
|
+
# @return [Hash] The parameter hash, but frozen
|
116
|
+
def register(prefix, vocab, **params)
|
117
|
+
# check the input
|
118
|
+
raise ArgumentError, "#{prefix} must be symbol-able" unless
|
119
|
+
[String, Symbol].any? { |c| prefix.is_a? c }
|
120
|
+
|
121
|
+
# note an explicit uri: param overrides
|
122
|
+
case vocab
|
123
|
+
when String then params[:uri] ||= vocab
|
124
|
+
when Class
|
125
|
+
raise ArgumentError, 'vocab must be an RDF::(Strict)Vocabulary' unless
|
126
|
+
vocab.ancestors.include? RDF::Vocabulary
|
127
|
+
params[:class] = vocab
|
128
|
+
params[:uri] ||= vocab.to_uri.to_s
|
129
|
+
end
|
130
|
+
|
131
|
+
# fill in the class name
|
132
|
+
params[:class_name] ||= prefix.to_s.upcase
|
133
|
+
|
134
|
+
# now freeze and assign
|
135
|
+
vocab_map[prefix.to_s.to_sym] = params.freeze
|
136
|
+
end
|
137
|
+
|
138
|
+
##
|
139
|
+
# Limits iteration over vocabularies to just those selected
|
140
|
+
#
|
141
|
+
# @example limit to set of vocabularies by symbol
|
142
|
+
# RDF::Vocabulary.limit_vocabs(:rdf, :rdfs
|
143
|
+
# RDF::Vocabulary.find_term('http://www.w3.org/2000/01/rdf-schema#Resource').pname
|
144
|
+
# # => 'rdfs:Resource'
|
145
|
+
#
|
146
|
+
# @example limit to set of vocabularies by class name
|
147
|
+
# RDF::Vocabulary.limit_vocabs(RDF::RDFV, RDF::RDFS)
|
148
|
+
# RDF::Vocabulary.find_term('http://www.w3.org/2000/01/rdf-schema#Resource').pname
|
149
|
+
# # => 'rdfs:Resource'
|
150
|
+
#
|
151
|
+
# @param [Array<symbol, RDF::Vocabulary>] vocabs
|
152
|
+
# A list of vocabularies (symbols or classes) which may
|
153
|
+
# be returned by {Vocabulary.each}. Also limits
|
154
|
+
# vocabularies that will be inspeced for other methods.
|
155
|
+
# Set to nil, or an empty array to reset.
|
156
|
+
# @return [Array<RDF::Vocabulary>]
|
157
|
+
def limit_vocabs(*vocabs)
|
158
|
+
@vocabs = if Array(vocabs).empty?
|
159
|
+
nil
|
160
|
+
else
|
161
|
+
vocabs.map do |vocab|
|
162
|
+
vocab = :rdfv if vocab == :rdf
|
163
|
+
vocab.is_a?(Symbol) && RDF::VOCABS.key?(vocab) ?
|
164
|
+
RDF.const_get(RDF::VOCABS[vocab][:class_name].to_sym) :
|
165
|
+
vocab
|
166
|
+
end.compact
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
80
170
|
##
|
81
171
|
# Is this a strict vocabulary, or a liberal vocabulary allowing arbitrary properties?
|
82
172
|
def strict?; false; end
|
@@ -291,7 +381,9 @@ module RDF
|
|
291
381
|
prefix, suffix = pname.to_s.split(":", 2)
|
292
382
|
if prefix == "rdf"
|
293
383
|
RDF[suffix]
|
294
|
-
elsif
|
384
|
+
elsif vocab_detail = RDF::Vocabulary.vocab_map[prefix.to_sym]
|
385
|
+
vocab = vocab_detail[:class] ||
|
386
|
+
RDF::Vocabulary.from_sym(vocab_detail[:class_name])
|
295
387
|
suffix.to_s.empty? ? vocab.to_uri : vocab[suffix]
|
296
388
|
else
|
297
389
|
(RDF::Vocabulary.find_term(pname) rescue nil) || RDF::URI(pname, validate: true)
|
@@ -817,11 +909,10 @@ module RDF
|
|
817
909
|
# @return [RDF::Vocabulary]
|
818
910
|
attr_reader :vocab
|
819
911
|
|
820
|
-
#
|
821
|
-
#
|
912
|
+
# Attributes of this vocabulary term, used for finding `label` and `comment` and to serialize the term back to RDF.
|
913
|
+
# @return [Hash{Symbol,Resource => Term, #to_s}]
|
822
914
|
attr_reader :attributes
|
823
915
|
|
824
|
-
|
825
916
|
##
|
826
917
|
# @overload new(uri, attributes:, **options)
|
827
918
|
# @param [URI, String, #to_s] uri
|
@@ -873,8 +964,8 @@ module RDF
|
|
873
964
|
#
|
874
965
|
# @param (see #initialize)
|
875
966
|
# @return [RDF::URI] an immutable, frozen URI object
|
876
|
-
def self.intern(str, *args)
|
877
|
-
(URI.cache[(str = str.to_s).to_sym] ||= self.new(str, *args)).freeze
|
967
|
+
def self.intern(str, *args, **options)
|
968
|
+
(URI.cache[(str = str.to_s).to_sym] ||= self.new(str, *args, **options)).freeze
|
878
969
|
end
|
879
970
|
|
880
971
|
##
|
@@ -882,7 +973,10 @@ module RDF
|
|
882
973
|
#
|
883
974
|
# @return [RDF::URI]
|
884
975
|
def dup
|
885
|
-
|
976
|
+
term = super.extend(Term)
|
977
|
+
term.instance_variable_set(:@vocab, vocab)
|
978
|
+
term.instance_variable_set(:@attributes, attributes)
|
979
|
+
term
|
886
980
|
end
|
887
981
|
|
888
982
|
##
|
@@ -943,7 +1037,7 @@ module RDF
|
|
943
1037
|
##
|
944
1038
|
# Values of an attributes as {RDF::Value}
|
945
1039
|
#
|
946
|
-
# @
|
1040
|
+
# @param [Symbol] prop
|
947
1041
|
# @return [RDF::Value, Array<RDF::Value>]
|
948
1042
|
def attribute_value(prop)
|
949
1043
|
values = attributes[prop]
|
@@ -1001,7 +1095,7 @@ module RDF
|
|
1001
1095
|
when :domainIncludes, :rangeIncludes
|
1002
1096
|
RDF::Vocabulary.find_term("http://schema.org/#{p}")
|
1003
1097
|
when :broader, :definition, :exactMatch, :hasTopConcept, :inScheme,
|
1004
|
-
:member, :narrower, :related, :altLabel, :
|
1098
|
+
:member, :narrower, :related, :altLabel, :editorialNote,
|
1005
1099
|
:notation, :note, :prefLabel
|
1006
1100
|
RDF::Vocabulary.find_term("http://www.w3.org/2004/02/skos/core##{p}")
|
1007
1101
|
else
|
data/lib/rdf/writer.rb
CHANGED
@@ -79,7 +79,7 @@ module RDF
|
|
79
79
|
# @param [String] filename
|
80
80
|
# @return [Class]
|
81
81
|
#
|
82
|
-
# @overload for(
|
82
|
+
# @overload for(options = {})
|
83
83
|
# Finds an RDF writer class based on various options.
|
84
84
|
#
|
85
85
|
# @param [Hash{Symbol => Object}] options
|
@@ -89,9 +89,15 @@ module RDF
|
|
89
89
|
# @return [Class]
|
90
90
|
#
|
91
91
|
# @return [Class]
|
92
|
-
def self.for(
|
93
|
-
|
94
|
-
|
92
|
+
def self.for(*arg, &block)
|
93
|
+
case arg.length
|
94
|
+
when 0 then arg = nil
|
95
|
+
when 1 then arg = arg.first
|
96
|
+
else
|
97
|
+
raise ArgumentError, "Format.for accepts zero or one argument, got #{arg.length}."
|
98
|
+
end
|
99
|
+
arg = arg.merge(has_writer: true) if arg.is_a?(Hash)
|
100
|
+
if format = self.format || Format.for(arg)
|
95
101
|
format.writer
|
96
102
|
end
|
97
103
|
end
|
@@ -505,11 +511,12 @@ module RDF
|
|
505
511
|
# @since 0.3.0
|
506
512
|
def format_term(term, **options)
|
507
513
|
case term
|
508
|
-
when String
|
509
|
-
when RDF::List
|
510
|
-
when RDF::Literal
|
511
|
-
when RDF::URI
|
512
|
-
when RDF::Node
|
514
|
+
when String then format_literal(RDF::Literal(term, **options), **options)
|
515
|
+
when RDF::List then format_list(term, **options)
|
516
|
+
when RDF::Literal then format_literal(term, **options)
|
517
|
+
when RDF::URI then format_uri(term, **options)
|
518
|
+
when RDF::Node then format_node(term, **options)
|
519
|
+
when RDF::Statement then format_rdfstar(term, **options)
|
513
520
|
else nil
|
514
521
|
end
|
515
522
|
end
|
@@ -553,7 +560,22 @@ module RDF
|
|
553
560
|
# @abstract
|
554
561
|
# @since 0.2.3
|
555
562
|
def format_list(value, **options)
|
556
|
-
format_term(value.subject, options)
|
563
|
+
format_term(value.subject, **options)
|
564
|
+
end
|
565
|
+
|
566
|
+
##
|
567
|
+
# Formats a referenced triple.
|
568
|
+
#
|
569
|
+
# @example
|
570
|
+
# <<<s> <p> <o>>> <p> <o> .
|
571
|
+
#
|
572
|
+
# @param [RDF::Statement] value
|
573
|
+
# @param [Hash{Symbol => Object}] options = ({})
|
574
|
+
# @return [String]
|
575
|
+
# @raise [NotImplementedError] unless implemented in subclass
|
576
|
+
# @abstract
|
577
|
+
def format_rdfstar(value, **options)
|
578
|
+
raise NotImplementedError.new("#{self.class}#format_statement") # override in subclasses
|
557
579
|
end
|
558
580
|
|
559
581
|
protected
|