rdf-rdfa 0.2.1 → 0.2.2
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/History.txt +13 -1
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/rdf/rdfa/patches/literal_hacks.rb +21 -10
- data/lib/rdf/rdfa/patches/nokogiri_hacks.rb +16 -0
- data/lib/rdf/rdfa/patches/uri_hacks.rb +6 -1
- data/lib/rdf/rdfa/reader.rb +357 -181
- data/lib/rdf/rdfa/version.rb +1 -1
- data/lib/rdf/rdfa.rb +4 -0
- data/rdf-rdfa.gemspec +11 -6
- data/script/console +3 -3
- data/script/parse +49 -0
- data/script/tc +10 -5
- data/spec/html4-manifest.yml +176 -176
- data/spec/html5-manifest.yml +176 -176
- data/spec/literal_spec.rb +245 -0
- data/spec/matchers.rb +1 -1
- data/spec/rdfa_helper.rb +44 -3
- data/spec/rdfa_reader_spec.rb +32 -67
- data/spec/xhtml-manifest.yml +139 -603
- data/spec/xhtml11-manifest.yml +4707 -0
- metadata +28 -4
data/History.txt
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
=== 0.2.2
|
2
|
+
* Ruby 1.9.2 compatibility
|
3
|
+
* Added script/parse as command-line option for parsing files.
|
4
|
+
* Add back support for RDFa 1.0 as well as RDFa 1.1. Parser checks @version to determine which
|
5
|
+
* Update RDFa processing to WD-rdfa-core-20100803 semantics
|
6
|
+
* Added Processor Graph and required output
|
7
|
+
* Reverse order of processing profiles
|
8
|
+
* Don't process element if any profile fails
|
9
|
+
* XMLLiterals must be explicitly specified as @datatype
|
10
|
+
* TERMorCURIEorAbsURI requires an absolute URI, not document relative
|
11
|
+
* Extract a new default vocabulary from @profile.
|
12
|
+
|
1
13
|
=== 0.2.1
|
2
14
|
* Update for RDF 0.2.1
|
3
15
|
|
@@ -7,7 +19,7 @@
|
|
7
19
|
* Change use of Graph#predicates and Graph#objects to use as enumerables
|
8
20
|
|
9
21
|
=== 0.0.3
|
10
|
-
* Removed
|
22
|
+
* Removed internal graph in Reader and implement each_triple & each_statement to perform parsing
|
11
23
|
|
12
24
|
=== 0.0.2
|
13
25
|
* Remove dependency on Namespace
|
data/Rakefile
CHANGED
@@ -60,7 +60,7 @@ namespace :spec do
|
|
60
60
|
require 'spec/rdfa_helper'
|
61
61
|
require 'fileutils'
|
62
62
|
|
63
|
-
%w(xhtml html4 html5).each do |suite|
|
63
|
+
%w(xhtml xhtml11 html4 html5).each do |suite|
|
64
64
|
yaml = manifest_file = File.join(File.dirname(__FILE__), "spec", "#{suite}-manifest.yml")
|
65
65
|
FileUtils.rm_f(yaml)
|
66
66
|
RdfaHelper::TestCase.to_yaml(suite, yaml)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
@@ -20,10 +20,9 @@ module RDF; class Literal
|
|
20
20
|
##
|
21
21
|
# @param [Object] value
|
22
22
|
# @option options [String] :lexical (nil)
|
23
|
-
# @option options [Hash] :namespaces (
|
24
|
-
# @option options [Hash] :namespaces ({})
|
23
|
+
# @option options [Hash] :namespaces ({}) Use :__default__ or "" to declare default namespace
|
25
24
|
# @option options [Symbol] :language (nil)
|
26
|
-
# @option options [
|
25
|
+
# @option options [:nokogiri, :libxml, or :rexml] :library
|
27
26
|
def initialize(value, options = {})
|
28
27
|
options[:namespaces] ||= {}
|
29
28
|
|
@@ -69,7 +68,8 @@ module RDF; class Literal
|
|
69
68
|
def parse_value(value, options)
|
70
69
|
ns_hash = {}
|
71
70
|
options[:namespaces].each_pair do |prefix, uri|
|
72
|
-
|
71
|
+
prefix = prefix == :__default__ ? "" : prefix.to_s
|
72
|
+
attr = prefix.empty? ? "xmlns" : "xmlns:#{prefix}"
|
73
73
|
ns_hash[attr] = uri.to_s
|
74
74
|
end
|
75
75
|
ns_strs = []
|
@@ -94,10 +94,18 @@ module RDF; class Literal
|
|
94
94
|
|
95
95
|
# Nokogiri implementations
|
96
96
|
if defined?(::Nokogiri)
|
97
|
+
# A somewhat half-hearted attempt at C14N.
|
98
|
+
# Main problem is that it promotes all namespaces to top element, instead of demoting them
|
99
|
+
# to the required element, and does not properly order either namespaces or attributes.
|
100
|
+
#
|
101
|
+
# An open-issue in Nokogiri is to add support for C14N from the underlying libxml2 libraries.
|
97
102
|
def parse_value_nokogiri(value, ns_strs, language)
|
98
|
-
|
99
|
-
|
100
|
-
|
103
|
+
elements = if value.is_a?(Nokogiri::XML::NodeSet)
|
104
|
+
value
|
105
|
+
else
|
106
|
+
# Add inherited namespaces to created root element so that they're inherited to sub-elements
|
107
|
+
Nokogiri::XML::Document.parse("<foo #{ns_strs.join(" ")}>#{value.to_s}</foo>").root.children
|
108
|
+
end
|
101
109
|
|
102
110
|
elements.map do |c|
|
103
111
|
if c.is_a?(Nokogiri::XML::Element)
|
@@ -110,9 +118,9 @@ module RDF; class Literal
|
|
110
118
|
c[prefix] = ns.href.to_s unless c.namespaces[prefix]
|
111
119
|
end
|
112
120
|
|
113
|
-
# Add
|
121
|
+
# Add language
|
114
122
|
if language && c["lang"].to_s.empty?
|
115
|
-
c["xml:lang"] = language
|
123
|
+
c["xml:lang"] = language.to_s
|
116
124
|
end
|
117
125
|
end
|
118
126
|
c
|
@@ -125,6 +133,7 @@ module RDF; class Literal
|
|
125
133
|
end # Nokogiri
|
126
134
|
|
127
135
|
if defined?(::LibXML)
|
136
|
+
# This should use Document#canonicalize if as and when it is available in libxml-ruby
|
128
137
|
def parse_value_libxml(value, ns_strs, language)
|
129
138
|
# Fixme
|
130
139
|
end
|
@@ -135,6 +144,8 @@ module RDF; class Literal
|
|
135
144
|
end # LibXML
|
136
145
|
|
137
146
|
# REXML
|
147
|
+
# This could make use of the XMLCanonicalizer gem (http://rubygems.org/gems/XMLCanonicalizer)
|
148
|
+
# But, it hasn't been touched since 2007 and relies on log4r.
|
138
149
|
def parse_value_rexml(value, ns_strs, language)
|
139
150
|
# Fixme
|
140
151
|
end
|
@@ -143,5 +154,5 @@ module RDF; class Literal
|
|
143
154
|
# Fixme
|
144
155
|
end
|
145
156
|
|
146
|
-
end
|
157
|
+
end # class XML
|
147
158
|
end; end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
class Nokogiri::XML::Node
|
3
|
+
# URI of namespace + node_name
|
4
|
+
def uri
|
5
|
+
ns = self.namespace ? self.namespace.href : RDF::XML.to_s
|
6
|
+
RDF::URI.intern(ns + self.node_name)
|
7
|
+
end
|
8
|
+
|
9
|
+
def display_path
|
10
|
+
@display_path ||= case self
|
11
|
+
when Nokogiri::XML::Document then ""
|
12
|
+
when Nokogiri::XML::Element then parent ? "#{parent.display_path}/#{name}" : name
|
13
|
+
when Nokogiri::XML::Attr then "#{parent.display_path}@#{name}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -10,10 +10,15 @@ module RDF
|
|
10
10
|
def join(*uris)
|
11
11
|
result = @uri
|
12
12
|
uris.each do |uri|
|
13
|
-
# result.path += '/' unless result.path.match(/[\#\/]$/) || uri.to_s[0..0] == "#"
|
14
13
|
result = result.join(uri)
|
15
14
|
end
|
16
15
|
self.class.new(result)
|
17
16
|
end
|
17
|
+
|
18
|
+
class NTriples::Writer
|
19
|
+
def format_uri(uri, options = {})
|
20
|
+
"<%s>" % escaped(uri_for(uri))
|
21
|
+
end
|
22
|
+
end
|
18
23
|
end
|
19
24
|
end
|