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

Extra blank lines at the end of the file #33

Closed abrisse closed 9 years ago

abrisse commented 9 years ago

Using rdf-rdfxml 1.1.3, all my exports using the RDF::RDFXML::Writer contain extra lines just between the two-last close tags </> (just above the /rdf:RDF). On a file containing 20K lines, I have almost 2K empty lines.

This regression should have appeared somewhere near the 1.1 release.

gkellogg commented 9 years ago

We should be able to control that in the Haml template. Any example in particular trigger it?

We could probably also have an option to eliminate unnecessary white space by selecting an alternative template.

Also, note that the template to use can be specified as an option.

abrisse commented 9 years ago

Easy to reproduce. The number of extra blank lines is correlated to the depth of the relations contained in the repository to export.

Load these statements with a RDF::RDFXML::Reader and just dump it using the RDF:RDFXML::Writer. (spoil: 2 extra lines will be added).

<?xml version='1.0' encoding='utf-8' ?>
<rdf:RDF xmlns:ns0='http://www.w3.org/XML/1998/namespacenw1:' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
  <ns0:Item rdf:about='http://example.com/1'>
    <ns0:link>
      <ns0:Description rdf:nodeID='g27233140'>
        <ns0:sublink>
          <ns0:Description rdf:nodeID='g27222780'>
            <ns0:label rdf:nodeID='g30028760' />
          </ns0:Description>
        </ns0:sublink>
      </ns0:Description>
    </ns0:link>
  </ns0:Item>
</rdf:RDF>
abrisse commented 9 years ago

@gkellogg: to provide feedback, thanks your commit improved a lot the output by removing all the extra lines, except just one that is still added just before the last tag:

<?xml version='1.0' encoding='utf-8' ?>
<rdf:RDF ...>
  <ns0:USE>
   ...
  </ns0:USE>
# the extra line is here
</rdf:RDF>
gkellogg commented 9 years ago

Yeah, getting rid of that last one is harder using my simplistic approach. The real problem lies somewhere in Haml, I just correct it by removing them from the final result.