ruby-rdf / rdf-rdfxml

Ruby RDF/XML reader/writer for RDF.rb.
http://rubygems.org/gems/rdf-rdfxml
The Unlicense
17 stars 7 forks source link

Rendering is broken with haml 5.0 #38

Closed abrisse closed 7 years ago

abrisse commented 7 years ago

rdf/rdfxml does not work anymore when using haml 5. It produces invalid XML.

script.rb

require 'rdf/rdfxml'

RDF::NTriples::Reader.open('file.nt') do |reader|
  puts reader.dump(:rdfxml)
end

file.nt

<http://www.acme.com/resource/channel> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.acme.com/ontology#channel> .
<http://www.acme.com/resource/07e6faeb-66b0-5e35-81ec-99fb714287a1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.acme.com/ontology#Item> .
<http://www.acme.com/resource/07e6faeb-66b0-5e35-81ec-99fb714287a1> <http://www.acme.com/ontology#broadcastShow> <http://www.acme.com/resource/channel> .
<http://www.acme.com/resource/07e6faeb-66b0-5e35-81ec-99fb714287a1> <http://www.acme.com/ontology#broadcastShow2> <http://www.acme.com/resource/channel> .
<http://www.acme.com/resource/5c78728e-b162-4b9c-a684-855c1c3e504c> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.acme.com/ontology#Message> .

output with rdf 2.2 (haml 5) (invalid XML)

gem 'haml', '~> 5.0'
<?xml version='1.0' encoding='utf-8' ?>
<rdf:RDF xmlns:ns0='http://www.acme.com/ontology#' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
<ns0:Item rdf:about='http://www.acme.com/resource/07e6faeb-66b0-5e35-81ec-99fb714287a1'>
<ns0:broadcastShow>
<ns0:channel rdf:about='http://www.acme.com/resource/channel'>
</ns0:channel>

</ns0:broadcastShow>

<ns0:broadcastShow2 rdf:resource='http://www.acme.com/resource/channel'>

</ns0:Item>

<ns0:Message rdf:about='http://www.acme.com/resource/5c78728e-b162-4b9c-a684-855c1c3e504c'>
</ns0:Message>

</rdf:RDF>

output with rdf 2.2 (haml 4) (valid XML)

gem 'haml', '~> 4.0'
<?xml version='1.0' encoding='utf-8' ?>
<rdf:RDF xmlns:ns0='http://www.acme.com/ontology#' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
  <ns0:Item rdf:about='http://www.acme.com/resource/07e6faeb-66b0-5e35-81ec-99fb714287a1'>
    <ns0:broadcastShow>
      <ns0:channel rdf:about='http://www.acme.com/resource/channel'>
      </ns0:channel>
    </ns0:broadcastShow>
    <ns0:broadcastShow2 rdf:resource='http://www.acme.com/resource/channel' />
  </ns0:Item>
  <ns0:Message rdf:about='http://www.acme.com/resource/5c78728e-b162-4b9c-a684-855c1c3e504c'>
  </ns0:Message>

</rdf:RDF>
gkellogg commented 7 years ago

Please verify that this is fixed on the develop branch, and I'll release it.

abrisse commented 7 years ago

Awesome. That fixes the closing tag problem, but the indentation is still broken.

abrisse commented 7 years ago

It seems that haml 5 removes the ugly option that allowed to indent the content. :(

Otherwise the closing tags work on the master branch when running:

reader.dump(:rdfxml, haml_options: { format: :xhtml})

Is that OK if I create a PR for the master branch that always set that option?

abrisse commented 7 years ago

I mean a PR on the rdf-rdfa gem on the RDF::RDFa::Writer#hamlify function that instiate the HAML engine

gkellogg commented 7 years ago

Released fix using closing tags in 2.1.0.