1

Am I right that something wrong with RDF::Writer while working with rdf:resource type of object?

require 'rdf/rdfxml'

output = RDF::Writer.for(:rdfxml).buffer do |writer|
  subject = RDF::Node.new
  writer << [subject, RDF.type, RDF::FOAF.Person]
  writer << [subject, RDF::FOAF.name, "J. Random Hacker"]
  writer << [subject, RDF::FOAF.mbox, RDF::URI("mailto:jhacker@example.org")]
  writer << [subject, RDF::FOAF.nick, "jhacker"]
end
puts output.dump()

Output looks like:

<?xml version='1.0' encoding='utf-8' ?>
<rdf:RDF xmlns:ns0='http://xmlns.com/foaf/0.1/' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
<ns0:Person>
<ns0:mbox rdf:resource='mailto:jhacker@example.org'>
<ns0:name>J. Random Hacker</ns0:name>
<ns0:nick>jhacker</ns0:nick>
</ns0:Person>
</rdf:RDF>

Am I right that unclosed tag <ns0:mbox rdf:resource='mailto:jhacker@example.org'> is wrong? How should I close this tag?

mateuscb
  • 10,150
  • 3
  • 52
  • 76
  • 1
    There's definitely something wrong; it doesn't look like well-formed XML. Does the Ruby RDF library not use a standard XML library? How are you viewing the output? Is there any possibility that something is being displayed incorrectly in the output? – Joshua Taylor Oct 27 '14 at 00:09
  • @joshua-tailor, you approved that xml result is wrong, thanks, and I don't want to show negative attitude, but why are you answering me? It looks like you are not using ruby, right? So why are you asking about library deps and how am I getting output, etc? I've searched for people, who faced this problem too. Of cource it's not connected with output, it's just simple test console app (the whole here). I guess it's connected with usage of haml module in sources (that's why I placed haml tag, but I'm bad at ruby yet, so can't fix it by myself). – yetanotherandreyev Oct 27 '14 at 22:08
  • Anyway, ruby rdf library developer [answered](https://github.com/ruby-rdf/rdf-rdfxml/issues/32#issuecomment-60471463), so I switched to turtle format and will update info about xml part when get some news. But thank you for your attention, really, I don't want to be ungentle, just expected some patches or workarounds from people who already faced this problem too :) – yetanotherandreyev Oct 27 '14 at 22:09
  • I was answering because Stack Overflow is for lots of users, not just you and me, which means that a question like Does the Ruby RDF library not use a standard XML library?" is something that lots of people can answer, and you did tag the question with [tag:haml], after all. The other point about output is that you didn't mention *how* the output was being displayed. Some presentations (e.g., if you were viewing it in a web browser) could render something incorrectly. – Joshua Taylor Oct 27 '14 at 23:15
  • And I'm not sure what you mean by "it looks like you are not using Ruby, right?". I've used RDF.rb before, and [answered some questions about it, too](http://stackoverflow.com/search?q=user%3A1281433+%5Bruby%5D+%5Brdf%5D+is%3Aanswer). – Joshua Taylor Oct 27 '14 at 23:16

1 Answers1

0

This is apparently a bug, and there's an issue on GitHub:

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
  • @yetanotherandreyev I realize that you reported this, but GitHub lists it as three days ago, while the question is only two days ago. It would have made sense to mention this in the question. – Joshua Taylor Oct 27 '14 at 23:25