rdf-rdfxml 0.3.2.1 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/.yardopts CHANGED
@@ -1,4 +1,4 @@
1
- --title "RDF::RDFXML - RDF/XML Support for RDF.rb"
1
+ --title "RDF::RDFXML - RDF/XML reader/writer for RDF.rb"
2
2
  --output-dir doc/yard
3
3
  --protected
4
4
  --no-private
@@ -10,3 +10,4 @@ History.rdoc
10
10
  AUTHORS
11
11
  CONTRIBUTORS
12
12
  VERSION
13
+ UNLICENSE
data/History.rdoc CHANGED
@@ -1,3 +1,8 @@
1
+ === 0.3.3
2
+ * Change licensing to UNLICENSE.
3
+ * Only generate prefix definitions for prefixes actually used within a serialization.
4
+ * Make sure that only valid QNames are generated in writer.
5
+
1
6
  === 0.3.2.1
2
7
  * Fix collection serialization bug
3
8
  * Assert :xml as a format type (by creating RDF::RDFXML::XML as a sub-class of Format that uses RDFXML::Reader/Writer)
data/README ADDED
@@ -0,0 +1,95 @@
1
+ # RDF::RDFXML reader/writer
2
+
3
+ [RDF/XML][RDF/XML] parser for [RDF.rb][RDF.rb].
4
+
5
+ ## DESCRIPTION
6
+
7
+ RDF::RDFXML is an [RDF/XML][RDF/XML] reader/writer for Ruby using the [RDF.rb][RDF.rb] library suite.
8
+
9
+ ## FEATURES
10
+ RDF::RDFXML parses [RDF/XML][RDF/XML] into statements or triples and serializes triples, statements or graphs.
11
+
12
+ Fully compliant [RDF/XML][RDF/XML] parser and serializer.
13
+
14
+ Install with `gem install rdf-rdfxml`
15
+
16
+ ## Usage:
17
+ Instantiate a parser and parse source, specifying type and base-URL
18
+
19
+ RDF::RDFXML::Reader.open("./etc/doap.xml") do |reader|
20
+ reader.each_statement do |statement|
21
+ puts statement.inspect
22
+ end
23
+ end
24
+
25
+ ## Dependencies
26
+ * [RDF.rb](http://rubygems.org/gems/rdf) (>= 0.3.1)
27
+ * [Nokogiri](http://rubygems.org/gems/nokogiri) (>= 1.4.4)
28
+
29
+ ## Documentation
30
+ Full documentation available on [RubyForge](http://rdf.rubyforge.org/rdfxml)
31
+
32
+ ### Principle Classes
33
+ * {RDF::RDFXML}
34
+ * {RDF::RDFXML::Format}
35
+ * {RDF::RDFXML::Reader}
36
+ * {RDF::RDFXML::Writer}
37
+
38
+ ### Additional vocabularies
39
+ * {RDF::XML}
40
+
41
+ ### Patches
42
+ * {Array}
43
+ * {RDF::Graph}
44
+ * {RDF::Literal::XML}
45
+ * {Nokogiri::XML::Node}
46
+
47
+ ## TODO
48
+ * Add support for LibXML and REXML bindings, and use the best available
49
+ * Consider a SAX-based parser for improved performance
50
+
51
+ ## Resources
52
+ * [RDF.rb][RDF.rb]
53
+ * [RDF/XML][RDF/XML]
54
+ * [Distiller](http://distiller.kellogg-assoc)
55
+ * [Documentation](http://rdf.rubyforge.org/rdfxml)
56
+ * [History](file:file.History.html)
57
+ * [RDF Tests](http://www.w3.org/2000/10/rdf-tests/rdfcore/allTestCases.html)
58
+
59
+ ## Author
60
+ * [Gregg Kellogg](http://github.com/gkellogg) - <http://kellogg-assoc.com/>
61
+
62
+ ## Contributors
63
+ * [Nicholas Humfrey](http://github.com/njh)
64
+
65
+ ## Contributing
66
+
67
+ * Do your best to adhere to the existing coding conventions and idioms.
68
+ * Don't use hard tabs, and don't leave trailing whitespace on any line.
69
+ * Do document every method you add using [YARD][] annotations. Read the
70
+ [tutorial][YARD-GS] or just look at the existing code for examples.
71
+ * Don't touch the `.gemspec`, `VERSION` or `AUTHORS` files. If you need to
72
+ change them, do so on your private branch only.
73
+ * Do feel free to add yourself to the `CREDITS` file and the corresponding
74
+ list in the the `README`. Alphabetical order applies.
75
+ * Do note that in order for us to merge any non-trivial changes (as a rule
76
+ of thumb, additions larger than about 15 lines of code), we need an
77
+ explicit [public domain dedication][PDD] on record from you.
78
+
79
+ ## License
80
+
81
+ This is free and unencumbered public domain software. For more information,
82
+ see <http://unlicense.org/> or the accompanying {file:UNLICENSE} file.
83
+
84
+ ## FEEDBACK
85
+
86
+ * gregg@kellogg-assoc.com
87
+ * <http://rubygems.org/rdf-rdfxml>
88
+ * <http://github.com/gkellogg/rdf-rdfxml>
89
+ * <http://lists.w3.org/Archives/Public/public-rdf-ruby/>
90
+
91
+ [RDF.rb]: http://rdf.rubyforge.org/
92
+ [RDF/XML]: http://www.w3.org/TR/REC-rdf-syntax/ "RDF/XML Syntax Specification"
93
+ [YARD]: http://yardoc.org/
94
+ [YARD-GS]: http://rubydoc.info/docs/yard/file/docs/GettingStarted.md
95
+ [PDD]: http://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
data/README.md CHANGED
@@ -1,17 +1,17 @@
1
1
  # RDF::RDFXML reader/writer
2
2
 
3
- RDF/XML parser for RDF.rb.
3
+ [RDF/XML][RDF/XML] parser for [RDF.rb][RDF.rb].
4
4
 
5
5
  ## DESCRIPTION
6
6
 
7
- RDF::RDFXML is an RDF/XML reader/writer for Ruby using the RDF.rb library suite.
7
+ RDF::RDFXML is an [RDF/XML][RDF/XML] reader/writer for Ruby using the [RDF.rb][RDF.rb] library suite.
8
8
 
9
9
  ## FEATURES
10
- RDF::RDFXML parses RDF/XML into statements or triples and serializes triples, statements or graphs.
10
+ RDF::RDFXML parses [RDF/XML][RDF/XML] into statements or triples and serializes triples, statements or graphs.
11
11
 
12
- Fully compliant RDF/XML parser and serializer.
12
+ Fully compliant [RDF/XML][RDF/XML] parser and serializer.
13
13
 
14
- Install with 'gem install rdf-rdfxml'
14
+ Install with `gem install rdf-rdfxml`
15
15
 
16
16
  ## Usage:
17
17
  Instantiate a parser and parse source, specifying type and base-URL
@@ -49,19 +49,33 @@ Full documentation available on [RubyForge](http://rdf.rubyforge.org/rdfxml)
49
49
  * Consider a SAX-based parser for improved performance
50
50
 
51
51
  ## Resources
52
- * [RDF.rb](http://rdf.rubyforge.org/)
52
+ * [RDF.rb][RDF.rb]
53
+ * [RDF/XML][RDF/XML]
53
54
  * [Distiller](http://distiller.kellogg-assoc)
54
- * [Documentation](http://rdf.rubyforge.org/rdfa)
55
+ * [Documentation](http://rdf.rubyforge.org/rdfxml)
55
56
  * [History](file:file.History.html)
56
- * [XHTML+RDFXML 1.1 Core](http://www.w3.org/TR/2010/WD-xhtml-rdfa-20100422/)
57
57
  * [RDF Tests](http://www.w3.org/2000/10/rdf-tests/rdfcore/allTestCases.html)
58
58
 
59
- ## AUTHOR
59
+ ## Author
60
60
  * [Gregg Kellogg](http://github.com/gkellogg) - <http://kellogg-assoc.com/>
61
61
 
62
- ## CONTRIBUTORS
62
+ ## Contributors
63
63
  * [Nicholas Humfrey](http://github.com/njh)
64
64
 
65
+ ## Contributing
66
+
67
+ * Do your best to adhere to the existing coding conventions and idioms.
68
+ * Don't use hard tabs, and don't leave trailing whitespace on any line.
69
+ * Do document every method you add using [YARD][] annotations. Read the
70
+ [tutorial][YARD-GS] or just look at the existing code for examples.
71
+ * Don't touch the `.gemspec`, `VERSION` or `AUTHORS` files. If you need to
72
+ change them, do so on your private branch only.
73
+ * Do feel free to add yourself to the `CREDITS` file and the corresponding
74
+ list in the the `README`. Alphabetical order applies.
75
+ * Do note that in order for us to merge any non-trivial changes (as a rule
76
+ of thumb, additions larger than about 15 lines of code), we need an
77
+ explicit [public domain dedication][PDD] on record from you.
78
+
65
79
  ## License
66
80
 
67
81
  This is free and unencumbered public domain software. For more information,
@@ -72,4 +86,10 @@ see <http://unlicense.org/> or the accompanying {file:UNLICENSE} file.
72
86
  * gregg@kellogg-assoc.com
73
87
  * <http://rubygems.org/rdf-rdfxml>
74
88
  * <http://github.com/gkellogg/rdf-rdfxml>
75
- * <http://lists.w3.org/Archives/Public/public-rdf-ruby/>
89
+ * <http://lists.w3.org/Archives/Public/public-rdf-ruby/>
90
+
91
+ [RDF.rb]: http://rdf.rubyforge.org/
92
+ [RDF/XML]: http://www.w3.org/TR/REC-rdf-syntax/ "RDF/XML Syntax Specification"
93
+ [YARD]: http://yardoc.org/
94
+ [YARD-GS]: http://rubydoc.info/docs/yard/file/docs/GettingStarted.md
95
+ [PDD]: http://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
data/Rakefile CHANGED
@@ -7,19 +7,19 @@ begin
7
7
  Jeweler::Tasks.new do |gemspec|
8
8
  gemspec.name = "rdf-rdfxml"
9
9
  gemspec.summary = "RDF/XML reader/writer for RDF.rb."
10
- gemspec.description = %q(RDF::RDFXML is an RDF/XML reader and writer for Ruby using the RDF.rb library suite.)
10
+ gemspec.description = %q(RDF::RDFXML is an RDF/XML reader and writer for the RDF.rb library suite.)
11
11
  gemspec.email = "gregg@kellogg-assoc.com"
12
12
  gemspec.homepage = "http://github.com/gkellogg/rdf-rdfxml"
13
13
  gemspec.authors = ["Gregg Kellogg"]
14
- gemspec.add_dependency('rdf', '>= 0.3.1')
14
+ gemspec.add_dependency('rdf', '>= 0.3.3')
15
15
  gemspec.add_dependency('nokogiri', '>= 1.4.4')
16
16
  gemspec.add_development_dependency('open-uri-cached')
17
17
  gemspec.add_development_dependency('spira', '>= 0.0.12')
18
18
  gemspec.add_development_dependency('rspec', '>= 2.5.0')
19
- gemspec.add_development_dependency('rdf-spec', '>= 0.3.1')
19
+ gemspec.add_development_dependency('rdf-spec', '>= 0.3.3')
20
20
  gemspec.add_development_dependency('rdf-isomorphic', '>= 0.3.4')
21
21
  gemspec.add_development_dependency('yard', '>= 0.6.4')
22
- gemspec.extra_rdoc_files = %w(README.md History.rdoc AUTHORS CONTRIBUTORS)
22
+ gemspec.extra_rdoc_files = %w(README.md History.rdoc AUTHORS CONTRIBUTORS UNLICENSE)
23
23
  end
24
24
  Jeweler::GemcutterTasks.new
25
25
  rescue LoadError
@@ -40,9 +40,7 @@ RSpec::Core::RakeTask.new("doc:spec") do |spec|
40
40
  spec.rspec_opts = ["--format", "html", "-o", "doc/spec.html"]
41
41
  end
42
42
 
43
- YARD::Rake::YardocTask.new do |t|
44
- t.files = %w(lib/**/*.rb README.md History.txt AUTHORS CONTRIBUTORS) # optional
45
- end
43
+ YARD::Rake::YardocTask.new
46
44
 
47
45
  desc "Generate RDF Core Manifest.yml"
48
46
  namespace :spec do
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.2.1
1
+ 0.3.3
@@ -33,7 +33,7 @@ module RDF::RDFXML
33
33
  # This allows the following:
34
34
  #
35
35
  # @example Obtaining an RDFXML format class
36
- # RDF::Format.for(:xml) # RDF::RDFXML::XML::Format
36
+ # RDF::Format.for(:xml) # RDF::RDFXML::XML
37
37
  # RDF::Format.for(:xml).reader # RDF::RDFXML::Reader
38
38
  # RDF::Format.for(:xml).writer # RDF::RDFXML::Writer
39
39
  class XML < RDF::Format
@@ -13,19 +13,6 @@ module RDF::RDFXML
13
13
  CORE_SYNTAX_TERMS = %w(RDF ID about parseType resource nodeID datatype).map {|n| "http://www.w3.org/1999/02/22-rdf-syntax-ns##{n}"}
14
14
  OLD_TERMS = %w(aboutEach aboutEachPrefix bagID).map {|n| "http://www.w3.org/1999/02/22-rdf-syntax-ns##{n}"}
15
15
 
16
- NC_REGEXP = Regexp.new(
17
- %{^
18
- (?!\\\\u0301) # &#x301; is a non-spacing acute accent.
19
- # It is legal within an XML Name, but not as the first character.
20
- ( [a-zA-Z_]
21
- | \\\\u[0-9a-fA-F]
22
- )
23
- ( [0-9a-zA-Z_\.-]
24
- | \\\\u([0-9a-fA-F]{4})
25
- )*
26
- $},
27
- Regexp::EXTENDED)
28
-
29
16
  # The Recursive Baggage
30
17
  class EvaluationContext # :nodoc:
31
18
  attr_reader :base
@@ -87,7 +87,7 @@ module RDF::RDFXML
87
87
  super do
88
88
  @graph = RDF::Graph.new
89
89
  @uri_to_qname = {}
90
- prefix(nil, @options[:default_namespace]) if @options[:default_namespace]
90
+ @uri_to_prefix = {}
91
91
  block.call(self) if block_given?
92
92
  end
93
93
  end
@@ -138,7 +138,8 @@ module RDF::RDFXML
138
138
 
139
139
  doc = Nokogiri::XML::Document.new
140
140
 
141
- add_debug "\nserialize: graph: #{@graph.size}"
141
+ add_debug "\nserialize: graph of size #{@graph.size}"
142
+ add_debug "options: #{@options.inspect}"
142
143
 
143
144
  preprocess
144
145
 
@@ -165,32 +166,46 @@ module RDF::RDFXML
165
166
  end
166
167
  end
167
168
 
169
+ add_debug "doc:\n #{doc.to_xml(:encoding => "UTF-8", :indent => 2)}"
168
170
  doc.write_xml_to(@output, :encoding => "UTF-8", :indent => 2)
169
171
  end
170
172
 
171
173
  # Return a QName for the URI, or nil. Adds namespace of QName to defined prefixes
172
- # @param [URI,#to_s] uri
173
- # @return [Array<Symbol,Symbol>, nil] Prefix, Suffix pair or nil, if none found
174
- def get_qname(uri)
175
- uri = RDF::URI.intern(uri.to_s) unless uri.is_a?(URI)
176
-
177
- unless @uri_to_qname.has_key?(uri)
178
- # Find in defined prefixes
179
- prefixes.each_pair do |prefix, vocab|
180
- if uri.to_s.index(vocab.to_s) == 0
181
- local_name = uri.to_s[(vocab.to_s.length)..-1]
182
- add_debug "get_qname(ns): #{prefix}:#{local_name}"
183
- return @uri_to_qname[uri] = [prefix, local_name.to_sym]
184
- end
185
- end
186
-
187
- # Use a default vocabulary
188
- if @options[:standard_prefixes] && vocab = RDF::Vocabulary.detect {|v| uri.to_s.index(v.to_uri.to_s) == 0}
189
- prefix = vocab.__name__.to_s.split('::').last.downcase
190
- prefixes[prefix.to_sym] = vocab.to_uri
191
- suffix = uri.to_s[vocab.to_uri.to_s.size..-1]
192
- return @uri_to_qname[uri] = [prefix.to_sym, suffix.empty? ? nil : suffix.to_sym] if prefix && suffix
193
- end
174
+ # @param [URI,#to_s] resource
175
+ # @param [Hash<Symbol => Object>] options
176
+ # @option [Boolean] :with_default (false) If a default mapping exists, use it, otherwise if a prefixed mapping exists, use it
177
+ # @return [String, nil] value to use to identify URI
178
+ def get_qname(resource, options = {})
179
+ case resource
180
+ when RDF::Node
181
+ add_debug "qname(#{resource.inspect}): #{resource}"
182
+ return resource.to_s
183
+ when RDF::URI
184
+ uri = resource.to_s
185
+ else
186
+ add_debug "qname(#{resource.inspect}): nil"
187
+ return nil
188
+ end
189
+
190
+ qname = case
191
+ when options[:with_default] && prefix(nil) && uri.index(prefix(nil)) == 0
192
+ # Don't cache
193
+ add_debug "qname(#{resource.inspect}): #{uri.sub(prefix(nil), '').inspect} (default)"
194
+ return uri.sub(prefix(nil), '')
195
+ when @uri_to_qname.has_key?(uri)
196
+ add_debug "qname(#{resource.inspect}): #{@uri_to_qname[uri].inspect} (cached)"
197
+ return @uri_to_qname[uri]
198
+ when u = @uri_to_prefix.keys.detect {|u| uri.index(u.to_s) == 0 && NC_REGEXP.match(uri[u.to_s.length..-1])}
199
+ # Use a defined prefix
200
+ prefix = @uri_to_prefix[u]
201
+ prefix(prefix, u) # Define for output
202
+ uri.sub(u.to_s, "#{prefix}:")
203
+ when @options[:standard_prefixes] && vocab = RDF::Vocabulary.detect {|v| uri.index(v.to_uri.to_s) == 0 && NC_REGEXP.match(uri[v.to_uri.to_s.length..-1])}
204
+ prefix = vocab.__name__.to_s.split('::').last.downcase
205
+ @uri_to_prefix[vocab.to_uri.to_s] = prefix
206
+ prefix(prefix, vocab.to_uri) # Define for output
207
+ uri.sub(vocab.to_uri.to_s, "#{prefix}:")
208
+ else
194
209
 
195
210
  # No vocabulary found, invent one
196
211
  # Add bindings for predicates not already having bindings
@@ -200,20 +215,20 @@ module RDF::RDFXML
200
215
  # in order to break a URI into a namespace name and a local name, split it after the last XML non-NCName
201
216
  # character, ensuring that the first character of the name is a Letter or '_'. If the URI ends in a
202
217
  # non-NCName character then throw a "this graph cannot be serialized in RDF/XML" exception or error.
203
- separation = uri.to_s.rindex(%r{[^a-zA-Z_0-9-][a-zA-Z_][a-z0-9A-Z_-]*$})
218
+ separation = uri.rindex(%r{[^a-zA-Z_0-9-][a-zA-Z_][a-z0-9A-Z_-]*$})
204
219
  return @uri_to_qname[uri] = nil unless separation
205
220
  base_uri = uri.to_s[0..separation]
206
221
  suffix = uri.to_s[separation+1..-1]
207
222
  @gen_prefix = @gen_prefix ? @gen_prefix.succ : "ns0"
208
- add_debug "create prefix definition for #{uri}"
223
+ @uri_to_prefix[base_uri] = @gen_prefix
209
224
  prefix(@gen_prefix, base_uri)
210
- add_debug "get_qname(tmp_ns): #{@gen_prefix}:#{suffix}"
211
- return @uri_to_qname[uri] = [@gen_prefix.to_sym, suffix.to_sym]
225
+ "#{@gen_prefix}:#{suffix}"
212
226
  end
213
227
 
214
- @uri_to_qname[uri]
215
- rescue Addressable::URI::InvalidURIError
216
- @uri_to_qname[uri] = nil
228
+ add_debug "qname(#{resource.inspect}): #{qname.inspect}"
229
+ @uri_to_qname[uri] = qname
230
+ rescue Addressable::URI::InvalidURIError => e
231
+ raise RDF::WriterError, "Invalid URI #{uri.inspect}: #{e.message}"
217
232
  end
218
233
 
219
234
  protected
@@ -261,6 +276,19 @@ module RDF::RDFXML
261
276
 
262
277
  # Perform any preprocessing of statements required
263
278
  def preprocess
279
+ default_namespace = @options[:default_namespace] || prefix(nil)
280
+
281
+ # Load defined prefixes
282
+ (@options[:prefixes] || {}).each_pair do |k, v|
283
+ @uri_to_prefix[v.to_s] = k
284
+ end
285
+ @options[:prefixes] = {} # Will define actual used when matched
286
+
287
+ if default_namespace
288
+ add_debug("preprocess: default_namespace: #{default_namespace}")
289
+ prefix(nil, default_namespace)
290
+ end
291
+
264
292
  @graph.each {|statement| preprocess_statement(statement)}
265
293
  end
266
294
 
@@ -307,11 +335,10 @@ module RDF::RDFXML
307
335
  end
308
336
 
309
337
  rdf_type, *rest = properties.fetch(RDF.type.to_s, [])
310
- qname = get_qname_string(rdf_type, :with_default => true)
311
- add_debug "=> qname: #{qname.inspect}"
338
+ qname = get_qname(rdf_type, :with_default => true)
312
339
  if rdf_type.is_a?(RDF::Node)
313
340
  # Must serialize with an element
314
- rdf_type = nil
341
+ qname = rdf_type = nil
315
342
  elsif rest.empty?
316
343
  properties.delete(RDF.type.to_s)
317
344
  else
@@ -319,7 +346,6 @@ module RDF::RDFXML
319
346
  end
320
347
  prop_list = order_properties(properties)
321
348
  add_debug "=> property order: #{prop_list.to_sentence}"
322
-
323
349
 
324
350
  if qname
325
351
  rdf_type = nil
@@ -374,7 +400,7 @@ module RDF::RDFXML
374
400
  def predicate(prop, object, node, is_unique)
375
401
  as_attr = predicate_as_attribute?(prop, object) && is_unique
376
402
 
377
- qname = get_qname_string(prop, :with_default => !as_attr)
403
+ qname = get_qname(prop, :with_default => !as_attr)
378
404
  raise RDF::WriterError, "No qname generated for <#{prop}>" unless qname
379
405
 
380
406
  add_debug "predicate: #{qname}, as_attr: #{as_attr}, object: #{object.inspect}, done: #{is_done?(object)}, subject: #{@subjects.include?(object)}"
@@ -475,8 +501,8 @@ module RDF::RDFXML
475
501
  def order_properties(properties)
476
502
  properties.keys.each do |k|
477
503
  properties[k] = properties[k].sort do |a, b|
478
- a_li = a.is_a?(RDF::URI) && get_qname(a) && get_qname(a).last.to_s =~ /^_\d+$/ ? a.to_i : a.to_s
479
- b_li = b.is_a?(RDF::URI) && get_qname(b) && get_qname(b).last.to_s =~ /^_\d+$/ ? b.to_i : b.to_s
504
+ a_li = a.is_a?(RDF::URI) && get_qname(a) && get_qname(a).to_s =~ /:_\d+$/ ? a.to_i : a.to_s
505
+ b_li = b.is_a?(RDF::URI) && get_qname(b) && get_qname(b).to_s =~ /:_\d+$/ ? b.to_i : b.to_s
480
506
 
481
507
  a_li <=> b_li
482
508
  end
@@ -525,24 +551,9 @@ module RDF::RDFXML
525
551
  #
526
552
  # @param [String] message::
527
553
  def add_debug(message)
528
- STDERR.puts (" " * @depth) + message if ::RDF::RDFXML.debug?
529
- @debug << message if @debug.is_a?(Array)
530
- end
531
-
532
- # Return string representation of QName pair
533
- #
534
- # @option [Boolean] :with_default (false) If a default mapping exists, use it, otherwise if a prefixed mapping exists, use it
535
- def get_qname_string(uri, options = {})
536
- if qname = get_qname(uri)
537
- if options[:with_default]
538
- qname[0] = nil if !qname.first.nil? && prefix(qname.first).to_s == prefix(nil).to_s
539
- elsif qname.first.nil?
540
- prefix = nil
541
- prefixes.each_pair {|k, v| prefix = k if !k.nil? && v.to_s == prefix(nil).to_s}
542
- qname[0] = prefix if prefix
543
- end
544
- qname.first == nil ? qname.last.to_s : qname.map(&:to_s).join(":")
545
- end
554
+ msg = "#{indent}#{message}"
555
+ STDERR.puts msg if ::RDF::RDFXML.debug?
556
+ @debug << msg if @debug.is_a?(Array)
546
557
  end
547
558
  end
548
559
  end
data/lib/rdf/rdfxml.rb CHANGED
@@ -29,7 +29,21 @@ module RDF
29
29
  autoload :Writer, 'rdf/rdfxml/writer'
30
30
  autoload :VERSION, 'rdf/rdfxml/version'
31
31
  autoload :XML, 'rdf/rdfxml/vocab'
32
-
32
+
33
+ # Regexp matching an NCName.
34
+ NC_REGEXP = Regexp.new(
35
+ %{^
36
+ (?!\\\\u0301) # &#x301; is a non-spacing acute accent.
37
+ # It is legal within an XML Name, but not as the first character.
38
+ ( [a-zA-Z_]
39
+ | \\\\u[0-9a-fA-F]
40
+ )
41
+ ( [0-9a-zA-Z_\.-]
42
+ | \\\\u([0-9a-fA-F]{4})
43
+ )*
44
+ $},
45
+ Regexp::EXTENDED)
46
+
33
47
  def self.debug?; @debug; end
34
48
  def self.debug=(value); @debug = value; end
35
49
  end
data/rdf-rdfxml.gemspec CHANGED
@@ -5,24 +5,26 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rdf-rdfxml}
8
- s.version = "0.3.2.1"
8
+ s.version = "0.3.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Gregg Kellogg"]
12
- s.date = %q{2011-02-18}
13
- s.description = %q{RDF::RDFXML is an RDF/XML reader and writer for Ruby using the RDF.rb library suite.}
12
+ s.date = %q{2011-04-25}
13
+ s.description = %q{RDF::RDFXML is an RDF/XML reader and writer for the RDF.rb library suite.}
14
14
  s.email = %q{gregg@kellogg-assoc.com}
15
15
  s.extra_rdoc_files = [
16
16
  "AUTHORS",
17
17
  "CONTRIBUTORS",
18
18
  "History.rdoc",
19
- "README.md"
19
+ "README.md",
20
+ "UNLICENSE"
20
21
  ]
21
22
  s.files = [
22
23
  ".yardopts",
23
24
  "AUTHORS",
24
25
  "CONTRIBUTORS",
25
26
  "History.rdoc",
27
+ "README",
26
28
  "README.md",
27
29
  "Rakefile",
28
30
  "UNLICENSE",
@@ -58,7 +60,7 @@ Gem::Specification.new do |s|
58
60
  ]
59
61
  s.homepage = %q{http://github.com/gkellogg/rdf-rdfxml}
60
62
  s.require_paths = ["lib"]
61
- s.rubygems_version = %q{1.5.0}
63
+ s.rubygems_version = %q{1.6.2}
62
64
  s.summary = %q{RDF/XML reader/writer for RDF.rb.}
63
65
  s.test_files = [
64
66
  "spec/format_spec.rb",
@@ -75,31 +77,31 @@ Gem::Specification.new do |s|
75
77
  s.specification_version = 3
76
78
 
77
79
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
78
- s.add_runtime_dependency(%q<rdf>, [">= 0.3.1"])
80
+ s.add_runtime_dependency(%q<rdf>, [">= 0.3.3"])
79
81
  s.add_runtime_dependency(%q<nokogiri>, [">= 1.4.4"])
80
82
  s.add_development_dependency(%q<open-uri-cached>, [">= 0"])
81
83
  s.add_development_dependency(%q<spira>, [">= 0.0.12"])
82
84
  s.add_development_dependency(%q<rspec>, [">= 2.5.0"])
83
- s.add_development_dependency(%q<rdf-spec>, [">= 0.3.1"])
85
+ s.add_development_dependency(%q<rdf-spec>, [">= 0.3.3"])
84
86
  s.add_development_dependency(%q<rdf-isomorphic>, [">= 0.3.4"])
85
87
  s.add_development_dependency(%q<yard>, [">= 0.6.4"])
86
88
  else
87
- s.add_dependency(%q<rdf>, [">= 0.3.1"])
89
+ s.add_dependency(%q<rdf>, [">= 0.3.3"])
88
90
  s.add_dependency(%q<nokogiri>, [">= 1.4.4"])
89
91
  s.add_dependency(%q<open-uri-cached>, [">= 0"])
90
92
  s.add_dependency(%q<spira>, [">= 0.0.12"])
91
93
  s.add_dependency(%q<rspec>, [">= 2.5.0"])
92
- s.add_dependency(%q<rdf-spec>, [">= 0.3.1"])
94
+ s.add_dependency(%q<rdf-spec>, [">= 0.3.3"])
93
95
  s.add_dependency(%q<rdf-isomorphic>, [">= 0.3.4"])
94
96
  s.add_dependency(%q<yard>, [">= 0.6.4"])
95
97
  end
96
98
  else
97
- s.add_dependency(%q<rdf>, [">= 0.3.1"])
99
+ s.add_dependency(%q<rdf>, [">= 0.3.3"])
98
100
  s.add_dependency(%q<nokogiri>, [">= 1.4.4"])
99
101
  s.add_dependency(%q<open-uri-cached>, [">= 0"])
100
102
  s.add_dependency(%q<spira>, [">= 0.0.12"])
101
103
  s.add_dependency(%q<rspec>, [">= 2.5.0"])
102
- s.add_dependency(%q<rdf-spec>, [">= 0.3.1"])
104
+ s.add_dependency(%q<rdf-spec>, [">= 0.3.3"])
103
105
  s.add_dependency(%q<rdf-isomorphic>, [">= 0.3.4"])
104
106
  s.add_dependency(%q<yard>, [">= 0.6.4"])
105
107
  end
data/script/tc CHANGED
@@ -2,7 +2,7 @@
2
2
  require 'rubygems'
3
3
  $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", 'lib')))
4
4
  require 'rdf/rdfxml'
5
- require File.expand_path(File.join(File.dirname(__FILE__), "..", 'spec', 'rdfa_helper'))
5
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", 'spec', 'rdf_helper'))
6
6
  require 'getoptlong'
7
7
 
8
8
  def run_tc(tc)
data/spec/format_spec.rb CHANGED
@@ -4,15 +4,15 @@ require File.join(File.dirname(__FILE__), 'spec_helper')
4
4
  describe RDF::RDFXML::Format do
5
5
  context "discovery" do
6
6
  {
7
- "rdf" => RDF::Format.for(:rdf),
8
- "rdfxml" => RDF::Format.for(:rdfxml),
9
- "etc/foaf.xml" => RDF::Format.for("etc/foaf.xml"),
10
- "etc/foaf.rdf" => RDF::Format.for("etc/foaf.rdf"),
11
- "foaf.xml" => RDF::Format.for(:file_name => "foaf.xml"),
12
- "foaf.rdf" => RDF::Format.for(:file_name => "foaf.xml"),
13
- ".xml" => RDF::Format.for(:file_extension => "xml"),
14
- ".rdf" => RDF::Format.for(:file_extension => "rdf"),
15
- "application/xml" => RDF::Format.for(:content_type => "application/xml"),
7
+ "rdf" => RDF::Format.for(:rdf),
8
+ "rdfxml" => RDF::Format.for(:rdfxml),
9
+ "etc/foaf.xml" => RDF::Format.for("etc/foaf.xml"),
10
+ "etc/foaf.rdf" => RDF::Format.for("etc/foaf.rdf"),
11
+ "foaf.xml" => RDF::Format.for(:file_name => "foaf.xml"),
12
+ "foaf.rdf" => RDF::Format.for(:file_name => "foaf.xml"),
13
+ ".xml" => RDF::Format.for(:file_extension => "xml"),
14
+ ".rdf" => RDF::Format.for(:file_extension => "rdf"),
15
+ "application/xml" => RDF::Format.for(:content_type => "application/xml"),
16
16
  "application/rdf+xml" => RDF::Format.for(:content_type => "application/rdf+xml"),
17
17
  }.each_pair do |label, format|
18
18
  it "should discover '#{label}'" do