rdf-rdfa 0.3.9 → 0.3.10
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.
- data/README +16 -8
- data/VERSION +1 -1
- data/lib/rdf/rdfa.rb +5 -6
- data/lib/rdf/rdfa/{profile.rb → context.rb} +42 -42
- data/lib/rdf/rdfa/context/html.rb +20 -0
- data/lib/rdf/rdfa/{profile → context}/xhtml.rb +9 -9
- data/lib/rdf/rdfa/context/xml.rb +55 -0
- data/lib/rdf/rdfa/expansion.rb +4 -4
- data/lib/rdf/rdfa/expansion/doap.rb +8 -8
- data/lib/rdf/rdfa/expansion/gr.rb +33 -21
- data/lib/rdf/rdfa/expansion/schema.rb +2 -0
- data/lib/rdf/rdfa/expansion/skosxl.rb +1 -1
- data/lib/rdf/rdfa/format.rb +4 -2
- data/lib/rdf/rdfa/reader.rb +135 -103
- data/lib/rdf/rdfa/reader/nokogiri.rb +1 -1
- data/lib/rdf/rdfa/reader/rexml.rb +1 -1
- data/lib/rdf/rdfa/writer.rb +5 -5
- metadata +130 -238
- data/lib/rdf/rdfa/profile/html.rb +0 -20
- data/lib/rdf/rdfa/profile/xml.rb +0 -53
@@ -4,34 +4,46 @@ require 'rdf/rdfa/expansion'
|
|
4
4
|
|
5
5
|
module RDF::RDFa::Expansion
|
6
6
|
[
|
7
|
-
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#
|
8
|
-
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#hasValue'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#hasMaxValue'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
9
|
-
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#height'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#quantitativeProductOrServiceProperty'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
10
|
-
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#hasValueInteger'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#hasMaxValueInteger'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
11
|
-
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#hasValueInteger'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#hasMinValueInteger'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
12
|
-
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#hasMaxValueInteger'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#hasMaxValue'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
13
|
-
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#hasMinValueInteger'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#hasMinValue'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
14
|
-
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#hasCurrencyValue'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#hasMaxCurrencyValue'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
15
|
-
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#hasCurrencyValue'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#hasMinCurrencyValue'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
16
|
-
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#depth'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#quantitativeProductOrServiceProperty'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
17
|
-
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#width'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#quantitativeProductOrServiceProperty'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
18
|
-
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#hasValueFloat'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#hasMinValueFloat'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
7
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#hasMPN'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://schema.org/productID'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
19
8
|
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#hasValueFloat'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#hasMaxValueFloat'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
20
|
-
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#
|
9
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#hasValueFloat'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#hasMinValueFloat'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
21
10
|
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#hasMaxValueFloat'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#hasMaxValue'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
11
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#hasMinValueFloat'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#hasMinValue'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
12
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#hasGTIN-8'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://schema.org/productID'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
13
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#depth'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#quantitativeProductOrServiceProperty'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
14
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#hasValueInteger'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#hasMinValueInteger'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
15
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#hasValueInteger'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#hasMaxValueInteger'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
16
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#hasMinValueInteger'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#hasMinValue'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
17
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#hasMaxValueInteger'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#hasMaxValue'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
22
18
|
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#color'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#datatypeProductOrServiceProperty'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
19
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#hasStockKeepingUnit'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://schema.org/productID'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
20
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#hasValue'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#hasMaxValue'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
21
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#hasValue'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#hasMinValue'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
22
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#hasGTIN-14'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://schema.org/productID'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
23
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#hasCurrencyValue'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#hasMinCurrencyValue'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
24
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#hasCurrencyValue'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#hasMaxCurrencyValue'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
23
25
|
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#weight'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#quantitativeProductOrServiceProperty'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
24
|
-
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#
|
26
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#hasEAN_UCC-13'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://schema.org/productID'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
27
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#height'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#quantitativeProductOrServiceProperty'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
28
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#width'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), RDF::URI('http://purl.org/goodrelations/v1#quantitativeProductOrServiceProperty'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
29
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#License'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://purl.org/goodrelations/v1#BusinessFunction'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
30
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#DeliveryModeParcelService'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://purl.org/goodrelations/v1#DeliveryMethod'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
25
31
|
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#DeliveryChargeSpecification'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://purl.org/goodrelations/v1#PriceSpecification'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
32
|
+
RDF::Statement.new(RDF::URI('http://schema.org/Person'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://purl.org/goodrelations/v1#BusinessEntity'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
26
33
|
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#QuantitativeValueInteger'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://purl.org/goodrelations/v1#QuantitativeValue'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
27
|
-
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#SomeItems'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://purl.org/goodrelations/v1#ProductOrService'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
28
|
-
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#ActualProductOrServiceInstance'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://purl.org/goodrelations/v1#ProductOrService'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
29
|
-
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#QuantitativeValueFloat'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://purl.org/goodrelations/v1#QuantitativeValue'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
30
|
-
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#Individual'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://purl.org/goodrelations/v1#ProductOrService'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
31
34
|
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#ProductOrServicesSomeInstancesPlaceholder'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://purl.org/goodrelations/v1#ProductOrService'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
32
|
-
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#DeliveryModeParcelService'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://purl.org/goodrelations/v1#DeliveryMethod'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
33
|
-
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#PaymentMethodCreditCard'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://purl.org/goodrelations/v1#PaymentMethod'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
34
|
-
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#PaymentChargeSpecification'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://purl.org/goodrelations/v1#PriceSpecification'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
35
35
|
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#ProductOrServiceModel'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://purl.org/goodrelations/v1#ProductOrService'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
36
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#ProductOrServiceModel'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://schema.org/Product'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
37
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#PaymentChargeSpecification'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://purl.org/goodrelations/v1#PriceSpecification'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
38
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#UnitPriceSpecification'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://purl.org/goodrelations/v1#PriceSpecification'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
39
|
+
RDF::Statement.new(RDF::URI('http://schema.org/Organization'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://purl.org/goodrelations/v1#BusinessEntity'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
40
|
+
RDF::Statement.new(RDF::URI('http://schema.org/Offer'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://purl.org/goodrelations/v1#Offering'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
41
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#PaymentMethodCreditCard'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://purl.org/goodrelations/v1#PaymentMethod'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
42
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#Individual'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://purl.org/goodrelations/v1#ProductOrService'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
43
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#Individual'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://schema.org/Product'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
44
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#ActualProductOrServiceInstance'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://purl.org/goodrelations/v1#ProductOrService'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
45
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#QuantitativeValueFloat'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://purl.org/goodrelations/v1#QuantitativeValue'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
46
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#SomeItems'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://purl.org/goodrelations/v1#ProductOrService'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
47
|
+
RDF::Statement.new(RDF::URI('http://purl.org/goodrelations/v1#SomeItems'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://schema.org/Product'), :context => RDF::URI('http://purl.org/goodrelations/v1#')),
|
36
48
|
].each {|st| COOKED_VOCAB_STATEMENTS << st }
|
37
49
|
end
|
@@ -77,6 +77,7 @@ module RDF::RDFa::Expansion
|
|
77
77
|
RDF::Statement.new(RDF::URI('http://schema.org/BookFormatType'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://schema.org/Enumeration'), :context => RDF::URI('http://schema.org/')),
|
78
78
|
RDF::Statement.new(RDF::URI('http://schema.org/ItemAvailability'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://schema.org/Enumeration'), :context => RDF::URI('http://schema.org/')),
|
79
79
|
RDF::Statement.new(RDF::URI('http://schema.org/OfferItemCondition'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://schema.org/Enumeration'), :context => RDF::URI('http://schema.org/')),
|
80
|
+
RDF::Statement.new(RDF::URI('http://schema.org/JobPosting'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://schema.org/Intangible'), :context => RDF::URI('http://schema.org/')),
|
80
81
|
RDF::Statement.new(RDF::URI('http://schema.org/Language'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://schema.org/Intangible'), :context => RDF::URI('http://schema.org/')),
|
81
82
|
RDF::Statement.new(RDF::URI('http://schema.org/Offer'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://schema.org/Intangible'), :context => RDF::URI('http://schema.org/')),
|
82
83
|
RDF::Statement.new(RDF::URI('http://schema.org/AggregateOffer'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://schema.org/Offer'), :context => RDF::URI('http://schema.org/')),
|
@@ -91,6 +92,7 @@ module RDF::RDFa::Expansion
|
|
91
92
|
RDF::Statement.new(RDF::URI('http://schema.org/ContactPoint'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://schema.org/StructuredValue'), :context => RDF::URI('http://schema.org/')),
|
92
93
|
RDF::Statement.new(RDF::URI('http://schema.org/PostalAddress'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://schema.org/ContactPoint'), :context => RDF::URI('http://schema.org/')),
|
93
94
|
RDF::Statement.new(RDF::URI('http://schema.org/GeoCoordinates'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://schema.org/StructuredValue'), :context => RDF::URI('http://schema.org/')),
|
95
|
+
RDF::Statement.new(RDF::URI('http://schema.org/GeoShape'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://schema.org/StructuredValue'), :context => RDF::URI('http://schema.org/')),
|
94
96
|
RDF::Statement.new(RDF::URI('http://schema.org/NutritionInformation'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://schema.org/StructuredValue'), :context => RDF::URI('http://schema.org/')),
|
95
97
|
RDF::Statement.new(RDF::URI('http://schema.org/Organization'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://schema.org/Thing'), :context => RDF::URI('http://schema.org/')),
|
96
98
|
RDF::Statement.new(RDF::URI('http://schema.org/Corporation'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::URI('http://schema.org/Organization'), :context => RDF::URI('http://schema.org/')),
|
@@ -4,6 +4,6 @@ require 'rdf/rdfa/expansion'
|
|
4
4
|
|
5
5
|
module RDF::RDFa::Expansion
|
6
6
|
[
|
7
|
-
RDF::Statement.new(RDF::URI('http://www.w3.org/2008/05/skos-xl#Label'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::Node.new('
|
7
|
+
RDF::Statement.new(RDF::URI('http://www.w3.org/2008/05/skos-xl#Label'), RDF::URI('http://www.w3.org/2000/01/rdf-schema#subClassOf'), RDF::Node.new('g70249981758620'), :context => RDF::URI('http://www.w3.org/2008/05/skos-xl#')),
|
8
8
|
].each {|st| COOKED_VOCAB_STATEMENTS << st }
|
9
9
|
end
|
data/lib/rdf/rdfa/format.rb
CHANGED
@@ -4,8 +4,8 @@ module RDF::RDFa
|
|
4
4
|
#
|
5
5
|
# @example Obtaining an RDFa format class
|
6
6
|
# RDF::Format.for(:rdfa) #=> RDF::RDFa::Format
|
7
|
-
# RDF::Format.for("etc/
|
8
|
-
# RDF::Format.for(:file_name => "etc/
|
7
|
+
# RDF::Format.for("etc/doap.html")
|
8
|
+
# RDF::Format.for(:file_name => "etc/doap.html")
|
9
9
|
# RDF::Format.for(:file_extension => "html")
|
10
10
|
# RDF::Format.for(:content_type => "text/html")
|
11
11
|
# RDF::Format.for(:content_type => "application/xhtml+xml")
|
@@ -49,6 +49,7 @@ module RDF::RDFa
|
|
49
49
|
# RDF::Format.for(:lite).writer # RDF::RDFa::Writer
|
50
50
|
class Lite < RDF::Format
|
51
51
|
content_encoding 'utf-8'
|
52
|
+
content_type 'text/html', :extension => :html
|
52
53
|
reader { RDF::RDFa::Reader }
|
53
54
|
writer { RDF::RDFa::Writer }
|
54
55
|
end
|
@@ -63,6 +64,7 @@ module RDF::RDFa
|
|
63
64
|
# RDF::Format.for(:html).writer # RDF::RDFa::Writer
|
64
65
|
class HTML < RDF::Format
|
65
66
|
content_encoding 'utf-8'
|
67
|
+
content_type 'text/html', :extension => :html
|
66
68
|
reader { RDF::RDFa::Reader }
|
67
69
|
writer { RDF::RDFa::Writer }
|
68
70
|
end
|
data/lib/rdf/rdfa/reader.rb
CHANGED
@@ -21,9 +21,9 @@ module RDF::RDFa
|
|
21
21
|
#
|
22
22
|
# Based on processing rules described here:
|
23
23
|
# @see http://www.w3.org/TR/rdfa-syntax/#s_model RDFa 1.0
|
24
|
-
# @see http://www.w3.org/TR/
|
25
|
-
# @see http://www.w3.org/TR/
|
26
|
-
# @see http://
|
24
|
+
# @see http://www.w3.org/TR/2012/CR-rdfa-core-20120313/
|
25
|
+
# @see http://www.w3.org/TR/2012/CR-xhtml-rdfa-20120313/
|
26
|
+
# @see http://dev.w3.org/html5/rdfa/
|
27
27
|
#
|
28
28
|
# @author [Gregg Kellogg](http://kellogg-assoc.com/)
|
29
29
|
class Reader < RDF::Reader
|
@@ -32,18 +32,18 @@ module RDF::RDFa
|
|
32
32
|
|
33
33
|
XHTML = "http://www.w3.org/1999/xhtml"
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
:"rdfa1.
|
35
|
+
# Content model for @about and @resource. In RDFa 1.0, this was URIorSafeCURIE
|
36
|
+
SafeCURIEorCURIEorIRI = {
|
37
|
+
:"rdfa1.0" => [:safe_curie, :uri, :bnode],
|
38
|
+
:"rdfa1.1" => [:safe_curie, :curie, :uri, :bnode],
|
38
39
|
}
|
39
|
-
|
40
|
+
|
41
|
+
# Content model for @datatype. In RDFa 1.0, this was CURIE
|
42
|
+
# Also plural TERMorCURIEorAbsIRIs, content model for @rel, @rev, @property and @typeof
|
43
|
+
TERMorCURIEorAbsIRI = {
|
40
44
|
:"rdfa1.0" => [:term, :curie],
|
41
45
|
:"rdfa1.1" => [:term, :curie, :absuri],
|
42
46
|
}
|
43
|
-
TERMorCURIEorAbsURIprop = {
|
44
|
-
:"rdfa1.0" => [:curie],
|
45
|
-
:"rdfa1.1" => [:term, :curie, :absuri],
|
46
|
-
}
|
47
47
|
|
48
48
|
# This expression matches an NCName as defined in
|
49
49
|
# [XML-NAMES](http://www.w3.org/TR/2009/REC-xml-names-20091208/#NT-NCName)
|
@@ -51,8 +51,6 @@ module RDF::RDFa
|
|
51
51
|
# @see http://www.w3.org/TR/2009/REC-xml-names-20091208/#NT-NCName
|
52
52
|
NC_REGEXP = Regexp.new(
|
53
53
|
%{^
|
54
|
-
(?!\\\\u0301) # ́ is a non-spacing acute accent.
|
55
|
-
# It is legal within an XML Name, but not as the first character.
|
56
54
|
( [a-zA-Z_]
|
57
55
|
| \\\\u[0-9a-fA-F]{4}
|
58
56
|
)
|
@@ -63,9 +61,11 @@ module RDF::RDFa
|
|
63
61
|
Regexp::EXTENDED)
|
64
62
|
|
65
63
|
# This expression matches an term as defined in
|
66
|
-
# [RDFA-CORE](http://www.w3.org/TR/
|
64
|
+
# [RDFA-CORE](# @see http://www.w3.org/TR/2012/CR-rdfa-core-20120313/#s_terms)
|
67
65
|
#
|
68
|
-
#
|
66
|
+
# For the avoidance of doubt, this definition means a 'term'
|
67
|
+
# in RDFa is an XML NCName that also permits slash as a non-leading character.
|
68
|
+
# @see http://www.w3.org/TR/2012/CR-rdfa-core-20120313/#s_terms
|
69
69
|
TERM_REGEXP = Regexp.new(
|
70
70
|
%{^
|
71
71
|
(?!\\\\u0301) # ́ is a non-spacing acute accent.
|
@@ -73,7 +73,7 @@ module RDF::RDFa
|
|
73
73
|
( [a-zA-Z_]
|
74
74
|
| \\\\u[0-9a-fA-F]{4}
|
75
75
|
)
|
76
|
-
( [0-9a-zA-Z_
|
76
|
+
( [0-9a-zA-Z_\.-\/]
|
77
77
|
| \\\\u([0-9a-fA-F]{4})
|
78
78
|
)*
|
79
79
|
$},
|
@@ -158,7 +158,7 @@ module RDF::RDFa
|
|
158
158
|
#
|
159
159
|
# This specification does not define an initial list.
|
160
160
|
# Host Languages may define an initial list.
|
161
|
-
# If a Host Language provides an initial list, it should do so via an RDFa
|
161
|
+
# If a Host Language provides an initial list, it should do so via an RDFa Context document.
|
162
162
|
#
|
163
163
|
# @attr [Hash{Symbol => RDF::URI}]
|
164
164
|
attr :term_mappings, true
|
@@ -234,14 +234,17 @@ module RDF::RDFa
|
|
234
234
|
# any additional options (see `RDF::Reader#initialize`)
|
235
235
|
# @option options [Symbol] :library
|
236
236
|
# One of :nokogiri or :rexml. If nil/unspecified uses :nokogiri if available, :rexml otherwise.
|
237
|
-
# @option options [Boolean] :
|
237
|
+
# @option options [Boolean] :vocab_expansion (false)
|
238
238
|
# whether to perform RDFS expansion on the resulting graph
|
239
239
|
# @option options [:xml1, :xhtml1, :xhtml5, :html4, :html5, :svg] :host_language (:xhtml1)
|
240
240
|
# Host Language
|
241
241
|
# @option options [:"rdfa1.0", :"rdfa1.1"] :version (:"rdfa1.1")
|
242
242
|
# Parser version information
|
243
|
-
# @option options [
|
244
|
-
#
|
243
|
+
# @option options [Proc] :processor_callback (nil)
|
244
|
+
# Callback used to provide processor graph triples.
|
245
|
+
# @option options [Array<Symbol>] :rdfagraph ([:output])
|
246
|
+
# Used to indicate if either or both of the :output or :processor graphs are output.
|
247
|
+
# Value is an array containing on or both of :output or :processor.
|
245
248
|
# @option options [Repository] :vocab_repository (nil)
|
246
249
|
# Repository to save loaded vocabularies.
|
247
250
|
# @option options [Array] :debug
|
@@ -254,8 +257,13 @@ module RDF::RDFa
|
|
254
257
|
def initialize(input = $stdin, options = {}, &block)
|
255
258
|
super do
|
256
259
|
@debug = options[:debug]
|
257
|
-
|
258
|
-
@
|
260
|
+
|
261
|
+
@options[:rdfagraph] = case @options[:rdfagraph]
|
262
|
+
when String, Symbol then @options[:rdfagraph].to_s.split(',').map(&:strip).map(&:to_sym)
|
263
|
+
when Array then @options[:rdfagraph].map {|o| o.to_s.to_sym}
|
264
|
+
else []
|
265
|
+
end.select {|o| [:output, :processor].include?(o)}
|
266
|
+
@options[:rdfagraph] << :output if @options[:rdfagraph].empty?
|
259
267
|
|
260
268
|
@library = case options[:library]
|
261
269
|
when nil
|
@@ -276,15 +284,15 @@ module RDF::RDFa
|
|
276
284
|
|
277
285
|
detect_host_language_version(input, options)
|
278
286
|
|
279
|
-
add_info(@doc, "version = #{@version}, host_language = #{@host_language}, library = #{@library}")
|
280
|
-
|
281
|
-
initialize_xml(input, options) rescue raise RDF::ReaderError.new($!.message)
|
287
|
+
add_info(@doc, "version = #{@version}, host_language = #{@host_language}, library = #{@library}, rdfagraph = #{@options[:rdfagraph].inspect}, expand = #{@options[:vocab_expansion]}")
|
282
288
|
|
283
|
-
|
284
|
-
|
285
|
-
|
289
|
+
begin
|
290
|
+
initialize_xml(input, options)
|
291
|
+
rescue
|
292
|
+
add_error(nil, "Malformed document: #{$!.message}")
|
286
293
|
end
|
287
|
-
|
294
|
+
add_error(nil, "Empty document") if root.nil?
|
295
|
+
add_error(nil, "Syntax errors:\n#{doc_errors}") if !doc_errors.empty?
|
288
296
|
|
289
297
|
# Section 4.2 RDFa Host Language Conformance
|
290
298
|
#
|
@@ -325,13 +333,16 @@ module RDF::RDFa
|
|
325
333
|
# @yieldparam [RDF::Statement] statement
|
326
334
|
# @return [void]
|
327
335
|
def each_statement(&block)
|
328
|
-
if @options[:
|
329
|
-
@options[:
|
336
|
+
if @options[:vocab_expansion]
|
337
|
+
@options[:vocab_expansion] = false
|
330
338
|
expand.each_statement(&block)
|
331
|
-
@options[:
|
339
|
+
@options[:vocab_expansion] = true
|
332
340
|
else
|
333
341
|
@callback = block
|
334
342
|
|
343
|
+
# Process any saved callbacks (processor graph issues)
|
344
|
+
@saved_callbacks.each {|s| @callback.call(s) } if @saved_callbacks
|
345
|
+
|
335
346
|
# Add prefix definitions from host defaults
|
336
347
|
@host_defaults[:uri_mappings].each_pair do |prefix, value|
|
337
348
|
prefix(prefix, value)
|
@@ -396,16 +407,35 @@ module RDF::RDFa
|
|
396
407
|
def add_processor_message(node, message, process_class)
|
397
408
|
puts "#{node_path(node)}: #{message}" if ::RDF::RDFa.debug?
|
398
409
|
@debug << "#{node_path(node)}: #{message}" if @debug.is_a?(Array)
|
399
|
-
if @
|
410
|
+
if @options[:processor_callback] || @options[:rdfagraph].include?(:processor)
|
411
|
+
g = RDF::Graph.new
|
400
412
|
n = RDF::Node.new
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
413
|
+
g << RDF::Statement.new(n, RDF["type"], process_class)
|
414
|
+
g << RDF::Statement.new(n, RDF::DC.description, message)
|
415
|
+
g << RDF::Statement.new(n, RDF::DC.date, RDF::Literal::Date.new(DateTime.now))
|
416
|
+
g << RDF::Statement.new(n, RDF::RDFA.context, base_uri) if base_uri
|
417
|
+
if node.respond_to?(:path)
|
418
|
+
nc = RDF::Node.new
|
419
|
+
g << RDF::Statement.new(n, RDF::RDFA.context, nc)
|
420
|
+
g << RDF::Statement.new(nc, RDF["type"], RDF::PTR.XPathPointer)
|
421
|
+
g << RDF::Statement.new(nc, RDF::PTR.expression, node.path)
|
422
|
+
end
|
423
|
+
|
424
|
+
g.each do |s|
|
425
|
+
# Provide as callback
|
426
|
+
@options[:processor_callback].call(s) if @options[:processor_callback]
|
427
|
+
|
428
|
+
# Yield as result
|
429
|
+
if @options[:rdfagraph].include?(:processor)
|
430
|
+
if @callback
|
431
|
+
@callback.call(s)
|
432
|
+
else
|
433
|
+
# Save messages for later callback
|
434
|
+
@saved_callbacks ||= []
|
435
|
+
@saved_callbacks << s
|
436
|
+
end
|
437
|
+
end
|
438
|
+
end
|
409
439
|
end
|
410
440
|
end
|
411
441
|
|
@@ -420,7 +450,7 @@ module RDF::RDFa
|
|
420
450
|
def add_triple(node, subject, predicate, object)
|
421
451
|
statement = RDF::Statement.new(subject, predicate, object)
|
422
452
|
add_info(node, "statement: #{RDF::NTriples.serialize(statement)}")
|
423
|
-
@callback.call(statement)
|
453
|
+
@callback.call(statement) if @options[:rdfagraph].include?(:output) && statement.valid?
|
424
454
|
end
|
425
455
|
|
426
456
|
# Parsing an RDFa document (this is *not* the recursive method)
|
@@ -452,7 +482,7 @@ module RDF::RDFa
|
|
452
482
|
add_debug("", "parse_whole_doc: traversal complete'")
|
453
483
|
end
|
454
484
|
|
455
|
-
# Parse and process URI mappings, Term mappings and a default vocabulary from @
|
485
|
+
# Parse and process URI mappings, Term mappings and a default vocabulary from @context
|
456
486
|
#
|
457
487
|
# Yields each mapping
|
458
488
|
def load_initial_contexts(initial_contexts)
|
@@ -461,7 +491,7 @@ module RDF::RDFa
|
|
461
491
|
each do |uri|
|
462
492
|
# Don't try to open ourselves!
|
463
493
|
if base_uri == uri
|
464
|
-
add_debug(root) {"load_initial_contexts: skip recursive
|
494
|
+
add_debug(root) {"load_initial_contexts: skip recursive context <#{uri}>"}
|
465
495
|
next
|
466
496
|
end
|
467
497
|
|
@@ -469,22 +499,22 @@ module RDF::RDFa
|
|
469
499
|
begin
|
470
500
|
add_info(root, "load_initial_contexts: load <#{uri}>")
|
471
501
|
RDF::RDFa.debug = false
|
472
|
-
|
502
|
+
context = Context.find(uri)
|
473
503
|
rescue Exception => e
|
474
504
|
RDF::RDFa.debug = old_debug
|
475
|
-
add_error(root, e.message
|
505
|
+
add_error(root, e.message)
|
476
506
|
raise # In case we're not in strict mode, we need to be sure processing stops
|
477
507
|
ensure
|
478
508
|
RDF::RDFa.debug = old_debug
|
479
509
|
end
|
480
510
|
|
481
511
|
# Add URI Mappings to prefixes
|
482
|
-
|
512
|
+
context.prefixes.each_pair do |prefix, value|
|
483
513
|
prefix(prefix, value)
|
484
514
|
end
|
485
|
-
yield :uri_mappings,
|
486
|
-
yield :term_mappings,
|
487
|
-
yield :default_vocabulary,
|
515
|
+
yield :uri_mappings, context.prefixes unless context.prefixes.empty?
|
516
|
+
yield :term_mappings, context.terms unless context.terms.empty?
|
517
|
+
yield :default_vocabulary, context.vocabulary if context.vocabulary
|
488
518
|
end
|
489
519
|
end
|
490
520
|
|
@@ -618,7 +648,7 @@ module RDF::RDFa
|
|
618
648
|
@host_defaults.fetch(:vocabulary, nil)
|
619
649
|
else
|
620
650
|
# Generate a triple indicating that the vocabulary is used
|
621
|
-
add_triple(element, base, RDF::RDFA.
|
651
|
+
add_triple(element, base, RDF::RDFA.usesVocabulary, uri(attrs[:vocab]))
|
622
652
|
|
623
653
|
uri(attrs[:vocab])
|
624
654
|
end
|
@@ -642,12 +672,12 @@ module RDF::RDFa
|
|
642
672
|
:uri_mappings => uri_mappings,
|
643
673
|
:term_mappings => term_mappings,
|
644
674
|
:vocab => default_vocabulary,
|
645
|
-
:restrictions =>
|
675
|
+
:restrictions => TERMorCURIEorAbsIRI.fetch(@version, []))
|
646
676
|
revs = process_uris(element, attrs[:rev], evaluation_context, base,
|
647
677
|
:uri_mappings => uri_mappings,
|
648
678
|
:term_mappings => term_mappings,
|
649
679
|
:vocab => default_vocabulary,
|
650
|
-
:restrictions =>
|
680
|
+
:restrictions => TERMorCURIEorAbsIRI.fetch(@version, []))
|
651
681
|
|
652
682
|
add_debug(element) do
|
653
683
|
"rels: #{rels.join(" ")}, revs: #{revs.join(" ")}"
|
@@ -660,11 +690,11 @@ module RDF::RDFa
|
|
660
690
|
new_subject = if attrs[:about]
|
661
691
|
process_uri(element, attrs[:about], evaluation_context, base,
|
662
692
|
:uri_mappings => uri_mappings,
|
663
|
-
:restrictions =>
|
693
|
+
:restrictions => SafeCURIEorCURIEorIRI.fetch(@version, []))
|
664
694
|
elsif attrs[:resource]
|
665
695
|
process_uri(element, attrs[:resource], evaluation_context, base,
|
666
696
|
:uri_mappings => uri_mappings,
|
667
|
-
:restrictions =>
|
697
|
+
:restrictions => SafeCURIEorCURIEorIRI.fetch(@version, []))
|
668
698
|
elsif attrs[:href] || attrs[:src]
|
669
699
|
process_uri(element, (attrs[:href] || attrs[:src]), evaluation_context, base, :restrictions => [:uri])
|
670
700
|
end
|
@@ -674,7 +704,7 @@ module RDF::RDFa
|
|
674
704
|
new_subject ||= if [:xhtml1, :xhtml5, :html4, :html5].include?(@host_language) && element.name =~ /^(head|body)$/
|
675
705
|
# From XHTML+RDFa 1.1:
|
676
706
|
# if no URI is provided, then first check to see if the element is the head or body element.
|
677
|
-
# If it is, then act as if
|
707
|
+
# If it is, then act as if the new subject is set to the parent object.
|
678
708
|
uri(base)
|
679
709
|
elsif element == root && base
|
680
710
|
# if the element is the root element of the document, then act as if there is an empty @about present,
|
@@ -692,10 +722,10 @@ module RDF::RDFa
|
|
692
722
|
typed_resource = new_subject if attrs[:typeof]
|
693
723
|
else
|
694
724
|
# If the current element contains the @property attribute, but does not contain the @content or the @datatype attribute
|
695
|
-
if attrs[:property] && !(attrs[:content] || attrs[:datatype])
|
725
|
+
if attrs[:property] && !(attrs[:content] || attrs[:datatype])
|
696
726
|
new_subject = process_uri(element, attrs[:about], evaluation_context, base,
|
697
727
|
:uri_mappings => uri_mappings,
|
698
|
-
:restrictions =>
|
728
|
+
:restrictions => SafeCURIEorCURIEorIRI.fetch(@version, [])) if attrs[:about]
|
699
729
|
|
700
730
|
# if the @typeof attribute is present, set typed resource to new subject
|
701
731
|
typed_resource = new_subject if attrs[:typeof]
|
@@ -705,8 +735,8 @@ module RDF::RDFa
|
|
705
735
|
new_subject ||= if [:xhtml1, :xhtml5, :html4, :html5].include?(@host_language) && element.name =~ /^(head|body)$/
|
706
736
|
# From XHTML+RDFa 1.1:
|
707
737
|
# if no URI is provided, then first check to see if the element is the head or body element.
|
708
|
-
# If it is, then act as if
|
709
|
-
|
738
|
+
# If it is, then act as if the new subject is set to the parent object.
|
739
|
+
evaluation_context.parent_object
|
710
740
|
elsif element == root && base
|
711
741
|
# if the element is the root element of the document, then act as if there is an empty @about present,
|
712
742
|
# and process it according to the rule for @about, above;
|
@@ -720,7 +750,7 @@ module RDF::RDFa
|
|
720
750
|
typed_resource ||= if attrs[:resource]
|
721
751
|
process_uri(element, attrs[:resource], evaluation_context, base,
|
722
752
|
:uri_mappings => uri_mappings,
|
723
|
-
:restrictions =>
|
753
|
+
:restrictions => SafeCURIEorCURIEorIRI.fetch(@version, []))
|
724
754
|
elsif attrs[:href] || attrs[:src]
|
725
755
|
process_uri(element, (attrs[:href] || attrs[:src]), evaluation_context, base, :restrictions => [:uri])
|
726
756
|
else
|
@@ -737,11 +767,11 @@ module RDF::RDFa
|
|
737
767
|
new_subject = if attrs[:about]
|
738
768
|
process_uri(element, attrs[:about], evaluation_context, base,
|
739
769
|
:uri_mappings => uri_mappings,
|
740
|
-
:restrictions =>
|
770
|
+
:restrictions => SafeCURIEorCURIEorIRI.fetch(@version, []))
|
741
771
|
elsif attrs[:resource]
|
742
772
|
process_uri(element, attrs[:resource], evaluation_context, base,
|
743
773
|
:uri_mappings => uri_mappings,
|
744
|
-
:restrictions =>
|
774
|
+
:restrictions => SafeCURIEorCURIEorIRI.fetch(@version, []))
|
745
775
|
elsif attrs[:href] || attrs[:src]
|
746
776
|
process_uri(element, (attrs[:href] || attrs[:src]), evaluation_context, base, :restrictions => [:uri])
|
747
777
|
end
|
@@ -751,8 +781,8 @@ module RDF::RDFa
|
|
751
781
|
new_subject ||= if [:xhtml1, :xhtml5, :html4, :html5].include?(@host_language) && element.name =~ /^(head|body)$/
|
752
782
|
# From XHTML+RDFa 1.1:
|
753
783
|
# if no URI is provided, then first check to see if the element is the head or body element.
|
754
|
-
# If it is, then act as if
|
755
|
-
|
784
|
+
# If it is, then act as if the new subject is set to the parent object.
|
785
|
+
evaluation_context.parent_object
|
756
786
|
elsif element == root && base
|
757
787
|
# if the element is the root element of the document, then act as if there is an empty @about present,
|
758
788
|
# and process it according to the rule for @about, above;
|
@@ -782,7 +812,7 @@ module RDF::RDFa
|
|
782
812
|
# establish both a value for new subject and a value for current object resource:
|
783
813
|
new_subject = process_uri(element, attrs[:about], evaluation_context, base,
|
784
814
|
:uri_mappings => uri_mappings,
|
785
|
-
:restrictions =>
|
815
|
+
:restrictions => SafeCURIEorCURIEorIRI.fetch(@version, []))
|
786
816
|
new_subject ||= process_uri(element, attrs[:src], evaluation_context, base,
|
787
817
|
:uri_mappings => uri_mappings,
|
788
818
|
:restrictions => [:uri]) if @version == :"rdfa1.0"
|
@@ -796,8 +826,8 @@ module RDF::RDFa
|
|
796
826
|
elsif [:xhtml1, :xhtml5, :html4, :html5].include?(@host_language) && element.name =~ /^(head|body)$/
|
797
827
|
# From XHTML+RDFa 1.1:
|
798
828
|
# if no URI is provided, then first check to see if the element is the head or body element.
|
799
|
-
# If it is, then act as if
|
800
|
-
|
829
|
+
# If it is, then act as if the new subject is set to the parent object.
|
830
|
+
evaluation_context.parent_object
|
801
831
|
elsif attrs[:typeof] && @version == :"rdfa1.0"
|
802
832
|
RDF::Node.new
|
803
833
|
else
|
@@ -810,7 +840,7 @@ module RDF::RDFa
|
|
810
840
|
current_object_resource = if attrs[:resource]
|
811
841
|
process_uri(element, attrs[:resource], evaluation_context, base,
|
812
842
|
:uri_mappings => uri_mappings,
|
813
|
-
:restrictions =>
|
843
|
+
:restrictions => SafeCURIEorCURIEorIRI.fetch(@version, []))
|
814
844
|
elsif attrs[:href]
|
815
845
|
process_uri(element, attrs[:href], evaluation_context, base,
|
816
846
|
:restrictions => [:uri])
|
@@ -841,12 +871,12 @@ module RDF::RDFa
|
|
841
871
|
|
842
872
|
# Process @typeof if there is a subject [Step 7]
|
843
873
|
if typed_resource
|
844
|
-
# Typeof is
|
874
|
+
# Typeof is TERMorCURIEorAbsIRIs
|
845
875
|
types = process_uris(element, attrs[:typeof], evaluation_context, base,
|
846
876
|
:uri_mappings => uri_mappings,
|
847
877
|
:term_mappings => term_mappings,
|
848
878
|
:vocab => default_vocabulary,
|
849
|
-
:restrictions =>
|
879
|
+
:restrictions => TERMorCURIEorAbsIRI.fetch(@version, []))
|
850
880
|
add_debug(element, "[Step 7] typeof: #{attrs[:typeof]}")
|
851
881
|
types.each do |one_type|
|
852
882
|
add_triple(element, typed_resource, RDF["type"], one_type)
|
@@ -927,7 +957,7 @@ module RDF::RDFa
|
|
927
957
|
:uri_mappings => uri_mappings,
|
928
958
|
:term_mappings => term_mappings,
|
929
959
|
:vocab => default_vocabulary,
|
930
|
-
:restrictions =>
|
960
|
+
:restrictions => TERMorCURIEorAbsIRI.fetch(@version, []))
|
931
961
|
|
932
962
|
properties.reject! do |p|
|
933
963
|
if p.is_a?(RDF::URI)
|
@@ -942,12 +972,12 @@ module RDF::RDFa
|
|
942
972
|
:uri_mappings => uri_mappings,
|
943
973
|
:term_mappings => term_mappings,
|
944
974
|
:vocab => default_vocabulary,
|
945
|
-
:restrictions =>
|
975
|
+
:restrictions => TERMorCURIEorAbsIRI.fetch(@version, [])) unless attrs[:datatype].to_s.empty?
|
946
976
|
begin
|
947
977
|
current_property_value = if datatype && datatype != RDF.XMLLiteral
|
948
978
|
# typed literal
|
949
979
|
add_debug(element, "[Step 11] typed literal (#{datatype})")
|
950
|
-
RDF::Literal.new(attrs[:content] || element.inner_text.to_s, :datatype => datatype, :language => language, :validate => validate?, :canonicalize => canonicalize?)
|
980
|
+
RDF::Literal.new(attrs[:datetime] || attrs[:value] || attrs[:content] || element.inner_text.to_s, :datatype => datatype, :language => language, :validate => validate?, :canonicalize => canonicalize?)
|
951
981
|
elsif @version == :"rdfa1.1"
|
952
982
|
if datatype == RDF.XMLLiteral
|
953
983
|
# XML Literal
|
@@ -980,16 +1010,16 @@ module RDF::RDFa
|
|
980
1010
|
v.match(dt::GRAMMAR)
|
981
1011
|
end || RDF::Literal
|
982
1012
|
add_debug(element) {"[Step 11(1.1)] <time> literal: #{datatype} #{v.inspect}"}
|
983
|
-
datatype.new(v)
|
984
|
-
elsif attrs[:content]
|
985
|
-
# plain literal
|
986
|
-
add_debug(element, "[Step 11(1.1)] plain literal (content)")
|
987
|
-
RDF::Literal.new(attrs[:content], :language => language, :validate => validate?, :canonicalize => canonicalize?)
|
1013
|
+
datatype.new(v, :language => language)
|
988
1014
|
elsif element.name.to_s == 'data' && attrs[:value]
|
989
1015
|
# HTML5 support
|
990
1016
|
# plain literal
|
991
1017
|
add_debug(element, "[Step 11(1.1)] plain literal (value)")
|
992
1018
|
RDF::Literal.new(attrs[:value], :language => language, :validate => validate?, :canonicalize => canonicalize?)
|
1019
|
+
elsif attrs[:content]
|
1020
|
+
# plain literal
|
1021
|
+
add_debug(element, "[Step 11(1.1)] plain literal (content)")
|
1022
|
+
RDF::Literal.new(attrs[:content], :language => language, :validate => validate?, :canonicalize => canonicalize?)
|
993
1023
|
elsif (attrs[:resource] || attrs[:href] || attrs[:src] || attrs[:data]) &&
|
994
1024
|
!(attrs[:rel] || attrs[:rev]) &&
|
995
1025
|
evaluation_context.incomplete_triples.empty? &&
|
@@ -998,7 +1028,7 @@ module RDF::RDFa
|
|
998
1028
|
add_debug(element, "[Step 11(1.1)] IRI literal (resource)")
|
999
1029
|
process_uri(element, attrs[:resource], evaluation_context, base,
|
1000
1030
|
:uri_mappings => uri_mappings,
|
1001
|
-
:restrictions =>
|
1031
|
+
:restrictions => SafeCURIEorCURIEorIRI.fetch(@version, []))
|
1002
1032
|
else
|
1003
1033
|
add_debug(element, "[Step 11(1.1)] IRI literal (href/src/data)")
|
1004
1034
|
process_uri(element, (attrs[:href] || attrs[:src] || attrs[:data]), evaluation_context, base, :restrictions => [:uri])
|
@@ -1141,7 +1171,7 @@ module RDF::RDFa
|
|
1141
1171
|
end
|
1142
1172
|
end
|
1143
1173
|
|
1144
|
-
# space-separated
|
1174
|
+
# space-separated TERMorCURIEorAbsIRI or SafeCURIEorCURIEorIRI
|
1145
1175
|
def process_uris(element, value, evaluation_context, base, options)
|
1146
1176
|
return [] if value.to_s.empty?
|
1147
1177
|
add_debug(element) {"process_uris: #{value}"}
|
@@ -1153,23 +1183,27 @@ module RDF::RDFa
|
|
1153
1183
|
restrictions = options[:restrictions]
|
1154
1184
|
add_debug(element) {"process_uri: #{value}, restrictions = #{restrictions.inspect}"}
|
1155
1185
|
options = {:uri_mappings => {}}.merge(options)
|
1156
|
-
if !options[:term_mappings] && options[:uri_mappings] && value.to_s.match(/^\[(.*)\]$/)
|
1157
|
-
#
|
1186
|
+
if !options[:term_mappings] && options[:uri_mappings] && restrictions.include?(:safe_curie) && value.to_s.match(/^\[(.*)\]$/)
|
1187
|
+
# SafeCURIEorCURIEorIRI
|
1158
1188
|
# When the value is surrounded by square brackets, then the content within the brackets is
|
1159
1189
|
# evaluated as a CURIE according to the CURIE Syntax definition. If it is not a valid CURIE, the
|
1160
1190
|
# value must be ignored.
|
1161
1191
|
uri = curie_to_resource_or_bnode(element, $1, options[:uri_mappings], evaluation_context.parent_subject, restrictions)
|
1162
|
-
|
1192
|
+
if uri
|
1193
|
+
add_debug(element) {"process_uri: #{value} => safeCURIE => <#{uri}>"}
|
1194
|
+
else
|
1195
|
+
add_warning(element, "#{value} not matched as a safeCURIE")
|
1196
|
+
end
|
1163
1197
|
uri
|
1164
|
-
elsif options[:term_mappings] &&
|
1165
|
-
#
|
1198
|
+
elsif options[:term_mappings] && TERM_REGEXP.match(value.to_s) && restrictions.include?(:term)
|
1199
|
+
# TERMorCURIEorAbsIRI
|
1166
1200
|
# If the value is an NCName, then it is evaluated as a term according to General Use of Terms in
|
1167
1201
|
# Attributes. Note that this step may mean that the value is to be ignored.
|
1168
1202
|
uri = process_term(element, value.to_s, options)
|
1169
1203
|
add_debug(element) {"process_uri: #{value} => term => <#{uri}>"}
|
1170
1204
|
uri
|
1171
1205
|
else
|
1172
|
-
#
|
1206
|
+
# SafeCURIEorCURIEorIRI or TERMorCURIEorAbsIRI
|
1173
1207
|
# Otherwise, the value is evaluated as a CURIE.
|
1174
1208
|
# If it is a valid CURIE, the resulting URI is used; otherwise, the value will be processed as a URI.
|
1175
1209
|
uri = curie_to_resource_or_bnode(element, value, options[:uri_mappings], evaluation_context.parent_subject, restrictions)
|
@@ -1184,17 +1218,17 @@ module RDF::RDFa
|
|
1184
1218
|
uri = uri(value)
|
1185
1219
|
unless uri.absolute?
|
1186
1220
|
uri = nil
|
1187
|
-
|
1221
|
+
add_warning(element, "Malformed IRI #{uri.inspect}")
|
1188
1222
|
end
|
1189
1223
|
else
|
1190
1224
|
uri = uri(base, Addressable::URI.parse(value))
|
1191
1225
|
end
|
1192
1226
|
rescue Addressable::URI::InvalidURIError => e
|
1193
|
-
add_warning(element, "Malformed
|
1227
|
+
add_warning(element, "Malformed IRI #{value}")
|
1194
1228
|
rescue RDF::ReaderError => e
|
1195
1229
|
add_debug(element, e.message)
|
1196
1230
|
if value.to_s =~ /^\(^\w\):/
|
1197
|
-
add_warning(element, "Undefined prefix #{$1}"
|
1231
|
+
add_warning(element, "Undefined prefix #{$1}")
|
1198
1232
|
else
|
1199
1233
|
add_warning(element, "Relative URI #{value}")
|
1200
1234
|
end
|
@@ -1207,30 +1241,28 @@ module RDF::RDFa
|
|
1207
1241
|
|
1208
1242
|
# [7.4.3] General Use of Terms in Attributes
|
1209
1243
|
def process_term(element, value, options)
|
1210
|
-
if options[:
|
1244
|
+
if options[:vocab]
|
1245
|
+
# If there is a local default vocabulary, the IRI is obtained by concatenating that value and the term
|
1246
|
+
return uri(options[:vocab] + value)
|
1247
|
+
elsif options[:term_mappings].is_a?(Hash)
|
1211
1248
|
# If the term is in the local term mappings, use the associated URI (case sensitive).
|
1212
1249
|
return uri(options[:term_mappings][value.to_s.to_sym]) if options[:term_mappings].has_key?(value.to_s.to_sym)
|
1213
|
-
|
1250
|
+
|
1214
1251
|
# Otherwise, check for case-insensitive match
|
1215
1252
|
options[:term_mappings].each_pair do |term, uri|
|
1216
1253
|
return uri(uri) if term.to_s.downcase == value.to_s.downcase
|
1217
1254
|
end
|
1218
1255
|
end
|
1219
|
-
|
1220
|
-
if
|
1221
|
-
|
1222
|
-
|
1223
|
-
else
|
1224
|
-
# Finally, if there is no local default vocabulary, the term has no associated URI and must be ignored.
|
1225
|
-
add_warning(element, "Term #{value} is not defined", RDF::RDFA.UnresolvedTerm)
|
1226
|
-
nil
|
1227
|
-
end
|
1256
|
+
|
1257
|
+
# Finally, if there is no local default vocabulary, the term has no associated URI and must be ignored.
|
1258
|
+
add_warning(element, "Term #{value} is not defined")
|
1259
|
+
nil
|
1228
1260
|
end
|
1229
1261
|
|
1230
1262
|
# From section 6. CURIE Syntax Definition
|
1231
1263
|
def curie_to_resource_or_bnode(element, curie, uri_mappings, subject, restrictions)
|
1232
1264
|
# URI mappings for CURIEs default to XHV, rather than the default doc namespace
|
1233
|
-
prefix, reference = curie.to_s.split(":")
|
1265
|
+
prefix, reference = curie.to_s.split(":", 2)
|
1234
1266
|
|
1235
1267
|
# consider the bnode situation
|
1236
1268
|
if prefix == "_" && restrictions.include?(:bnode)
|
@@ -1253,7 +1285,7 @@ module RDF::RDFa
|
|
1253
1285
|
if ns
|
1254
1286
|
uri(ns + reference.to_s)
|
1255
1287
|
else
|
1256
|
-
add_debug(element) {"curie_to_resource_or_bnode No namespace mapping for #{prefix}"}
|
1288
|
+
add_debug(element) {"curie_to_resource_or_bnode No namespace mapping for #{prefix.inspect}"}
|
1257
1289
|
nil
|
1258
1290
|
end
|
1259
1291
|
end
|