rdf_context 0.4.3 → 0.4.4
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 +5 -0
- data/VERSION +1 -1
- data/bin/{reddy → rdf_context} +1 -1
- data/lib/rdf_context/graph.rb +11 -0
- data/lib/rdf_context/nokogiri_hacks.rb +1 -1
- data/lib/rdf_context/rdfxmlparser.rb +1 -2
- data/lib/rdf_context/uriref.rb +19 -8
- metadata +5 -5
data/History.txt
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.4
|
data/bin/{reddy → rdf_context}
RENAMED
data/lib/rdf_context/graph.rb
CHANGED
@@ -119,6 +119,17 @@ module RdfContext
|
|
119
119
|
)
|
120
120
|
rdf_attrs = extended_bindings.values.inject({}) { |hash, ns| hash.merge(ns.xmlns_attr => ns.uri.to_s)}
|
121
121
|
uri_bindings = extended_bindings.values.inject({}) { |hash, ns| hash.merge(ns.uri.to_s => ns.prefix)}
|
122
|
+
|
123
|
+
# Add bindings for predicates not already having bindings
|
124
|
+
tmp_ns = "ns0"
|
125
|
+
predicates.each do |p|
|
126
|
+
unless uri_bindings.has_key?(p.base)
|
127
|
+
uri_bindings[p.base] = tmp_ns
|
128
|
+
rdf_attrs["xmlns:#{tmp_ns}"] = p.base
|
129
|
+
tmp_ns = tmp_ns.succ
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
122
133
|
xml.instruct!
|
123
134
|
xml.rdf(:RDF, rdf_attrs) do
|
124
135
|
# Add statements for each subject
|
@@ -2,7 +2,7 @@ require 'nokogiri'
|
|
2
2
|
class Nokogiri::XML::Node
|
3
3
|
# URI of namespace + node_name
|
4
4
|
def uri
|
5
|
-
ns = self.namespace ? self.namespace.href : XML_NS.uri.to_s
|
5
|
+
ns = self.namespace ? self.namespace.href : RdfContext::XML_NS.uri.to_s
|
6
6
|
RdfContext::URIRef.new(ns + self.node_name)
|
7
7
|
end
|
8
8
|
end
|
@@ -484,8 +484,7 @@ module RdfContext
|
|
484
484
|
raise InvalidPredicate.new(warn) if @strict
|
485
485
|
return false
|
486
486
|
end
|
487
|
-
!CORE_SYNTAX_TERMS.include?(attr.uri.to_s) &&
|
488
|
-
attr.namespace.href != XML_NS.uri.to_s
|
487
|
+
!CORE_SYNTAX_TERMS.include?(attr.uri.to_s) && attr.namespace && attr.namespace.href != XML_NS.uri.to_s
|
489
488
|
end
|
490
489
|
|
491
490
|
# Check Node Element name
|
data/lib/rdf_context/uriref.rb
CHANGED
@@ -36,13 +36,25 @@ module RdfContext
|
|
36
36
|
return URIRef.new(input_uri, self.to_s)
|
37
37
|
end
|
38
38
|
|
39
|
+
# short_name of URI for creating QNames.
|
40
|
+
# "#{base]{#short_name}}" == uri
|
39
41
|
def short_name
|
40
|
-
if @uri.fragment()
|
41
|
-
|
42
|
+
@short_name ||= if @uri.fragment()
|
43
|
+
@uri.fragment()
|
42
44
|
elsif @uri.path.split("/").last.class == String and @uri.path.split("/").last.length > 0
|
43
|
-
|
45
|
+
@uri.path.split("/").last
|
44
46
|
else
|
45
|
-
|
47
|
+
false
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# base of URI for creating QNames.
|
52
|
+
# "#{base]{#short_name}}" == uri
|
53
|
+
def base
|
54
|
+
@base ||= begin
|
55
|
+
uri_base = @uri.to_s
|
56
|
+
sn = short_name.to_s
|
57
|
+
uri_base[0, uri_base.length - sn.length]
|
46
58
|
end
|
47
59
|
end
|
48
60
|
|
@@ -64,13 +76,12 @@ module RdfContext
|
|
64
76
|
|
65
77
|
# Output URI as QName using URI binding
|
66
78
|
def to_qname(uri_binding = {})
|
67
|
-
|
68
|
-
|
69
|
-
uri_base = uri_base[0, uri_base.length - sn.length]
|
79
|
+
sn = self.short_name
|
80
|
+
uri_base = self.base
|
70
81
|
if uri_binding.has_key?(uri_base)
|
71
82
|
"#{uri_binding[uri_base]}:#{sn}"
|
72
83
|
else
|
73
|
-
raise ParserException, "Couldn't find QName for #{@uri}"
|
84
|
+
raise ParserException, "Couldn't find QName for #{@uri}, base: #{uri_base}"
|
74
85
|
end
|
75
86
|
end
|
76
87
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdf_context
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregg Kellogg
|
@@ -9,8 +9,8 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
13
|
-
default_executable:
|
12
|
+
date: 2010-01-03 00:00:00 -08:00
|
13
|
+
default_executable: rdf_context
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: addressable
|
@@ -85,7 +85,7 @@ dependencies:
|
|
85
85
|
description: " RdfContext parses RDF/XML, RDFa and N3-rdf into a Graph object. It also serializes RDF/XML and N-Triples from the Graph.\n\n * Fully compliant RDF/XML parser.\n * Fully compliant XHTML/RDFa 1.0 parser.\n * N3-rdf parser\n * N-Triples and RDF/XML serializer\n * Graph serializes into RDF/XML and N-Triples.\n * ConjunctiveGraph, named Graphs and contextual storage modules.\n \n Install with 'gem install rdf_context'\n"
|
86
86
|
email: gregg@kellogg-assoc.com
|
87
87
|
executables:
|
88
|
-
-
|
88
|
+
- rdf_context
|
89
89
|
extensions: []
|
90
90
|
|
91
91
|
extra_rdoc_files:
|
@@ -100,7 +100,7 @@ files:
|
|
100
100
|
- README.rdoc
|
101
101
|
- Rakefile
|
102
102
|
- VERSION
|
103
|
-
- bin/
|
103
|
+
- bin/rdf_context
|
104
104
|
- lib/rdf_context.rb
|
105
105
|
- lib/rdf_context/bnode.rb
|
106
106
|
- lib/rdf_context/conjunctive_graph.rb
|