Skip to content

Commit 35f8f0e

Browse files
committed
Don't use the rdf namespace as default for REXML and check for an empty namespace.
1 parent 38d174b commit 35f8f0e

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

lib/rdf/rdfxml/reader/rexml.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def display_path
117117

118118
# URI of namespace + name
119119
def uri
120-
ns = namespace || RDF::XML.to_s
120+
ns = namespace
121121
ns = ns.href if ns.respond_to?(:href)
122122
RDF::URI.intern(ns + @node.name)
123123
end
@@ -144,10 +144,10 @@ def namespaces
144144
end
145145

146146
def namespace
147-
if @node.namespace
147+
if @node.namespace && !@node.namespace.empty?
148148
Namespace.new(@node.namespace, @node.prefix)
149149
else
150-
Namespace.new(RDF::XML.to_s, 'rdf')
150+
Namespace.new(RDF::XML.to_s, 'xml')
151151
end
152152
end
153153

script/parse

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ logger.formatter = lambda {|severity, datetime, progname, msg| "#{severity}: #{m
5353

5454
parser_options = {
5555
base_uri: nil,
56-
validate: false,
56+
library: :nokogiri,
5757
logger: logger,
58+
validate: false,
5859
}
5960

6061
writer_options = {
@@ -85,6 +86,7 @@ OPT_ARGS = [
8586
["--help", "-?", GetoptLong::NO_ARGUMENT, "print this message"],
8687
["--input-format", GetoptLong::REQUIRED_ARGUMENT, "Format of the input file, defaults to ttl"],
8788
["--info", GetoptLong::NO_ARGUMENT, "Show progress on execution"],
89+
["--library", GetoptLong::REQUIRED_ARGUMENT, "XML library to use (nokogiri or rexml)"],
8890
["--output", "-o", GetoptLong::REQUIRED_ARGUMENT, "Save output to file"],
8991
["--quiet", GetoptLong::NO_ARGUMENT, "Do not show parser output"],
9092
["--stream", GetoptLong::NO_ARGUMENT, "Use streaming writer"],
@@ -124,6 +126,7 @@ opts.each do |opt, arg|
124126
when '--format' then options[:output_format] = arg.to_sym
125127
when "--help" then usage()
126128
when '--input-format' then options[:input_format] = arg.to_sym
129+
when '--library' then parser_options[:library] = arg.to_sym
127130
when '--output' then options[:output] = File.open(arg, "w")
128131
when '--rdfstar' then parser_options[:rdfstar] = true
129132
when '--quiet'

0 commit comments

Comments
 (0)