Skip to content
This repository has been archived by the owner on Dec 21, 2017. It is now read-only.

Commit

Permalink
Now passing rdfms-syntax-incomplete-test001
Browse files Browse the repository at this point in the history
  • Loading branch information
tommorris committed Oct 16, 2008
1 parent ef516c7 commit 5961e2e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 24 deletions.
25 changes: 18 additions & 7 deletions lib/rena/rdfxmlparser.rb
Expand Up @@ -106,16 +106,24 @@ def parse_subject(el)
# we have a BNode with an identifier. First, we need to do syntax checking.
if value =~ /^[a-zA-Z_][a-zA-Z0-9]*$/
# now we check to see if the graph has the value
if @graph.has_bnode_identifier?(value)
# if so, pull it in - no need to recreate objects.
subject = @graph.get_bnode_by_identifier(value)
else
# if not, create a new one.
subject = BNode.new(value)
end
return forge_bnode_from_string(value)
end
end
end

return subject
end

def forge_bnode_from_string(value)
if @graph.has_bnode_identifier?(value)
# if so, pull it in - no need to recreate objects.
subject = @graph.get_bnode_by_identifier(value)
else
# if not, create a new one.
subject = BNode.new(value)
end

return subject
end

def id_check?(id)
Expand All @@ -142,6 +150,9 @@ def parse_descriptions (node, subject = nil)
predicate = url_helper(child.name, child.namespace_node.href, child.base)
object = child.content
#debugger
if el.attributes.get_attribute_ns(SYNTAX_BASE, "nodeID")
@graph.add_triple(subject, predicate, forge_bnode_from_string(el.attributes.get_attribute_ns(SYNTAX_BASE, "nodeID").value))
end
child.each {|contents|
if contents.text? and contents.content.strip.length != 0
object = contents.content
Expand Down
33 changes: 16 additions & 17 deletions spec/parser_spec.rb
Expand Up @@ -190,23 +190,22 @@
graph.graph.to_ntriples.should == "<http://www.w3.org/2000/10/rdf-tests/rdfcore/rdfms-xml-literal-namespaces/test001.rdf#John_Smith> <http://my.example.org/Name> \"<html:h1>\n <b>John</b>\n </html:h1>\"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral> .\n"
end

# it "should pass rdfms-syntax-incomplete-test001" do
# sampledoc = <<-EOF;
# <?xml version="1.0"?>
# <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
# xmlns:eg="http://example.org/">
#
# <rdf:Description rdf:nodeID="a">
# <eg:property rdf:nodeID="a" />
# </rdf:Description>
#
# </rdf:RDF>
# EOF
#
# lambda do
# graph = RdfXmlParser.new(sampledoc)
# end.should_not raise_error
# end
it "should pass rdfms-syntax-incomplete-test001" do
sampledoc = <<-EOF;
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:eg="http://example.org/">
<rdf:Description rdf:nodeID="a">
<eg:property rdf:nodeID="a" />
</rdf:Description>
</rdf:RDF>
EOF

graph = RdfXmlParser.new(sampledoc)
graph.graph.size.should == 1
end
#
# it "should pass rdfms-syntax-incomplete-test002" do
# sampledoc = <<-EOF;
Expand Down

0 comments on commit 5961e2e

Please sign in to comment.