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

Invalid RDF/XML output #28

Closed GitHubber1 closed 10 years ago

GitHubber1 commented 10 years ago

Hello, I want to use spread2rdf to convert Excel-based data to RDF. With that tool I can successfully create any RDF format (nt, n3, ttl, xml (TriX), json) except for RDF/XML. The programmer of the tool suggested to raise an issue here. The problem is that the output XML is not valid because of missing XML end tags. This is the case for property elements on a node element, e.g. the result of converting this Turtle RDF

@prefix ex: <http://www.example.org#> .
@prefix ex2: <http://www.example2.org#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .

ex:Age a skos:Concept,
     ex:Liver_Factor;
   ex2:datatype "int";
   skos:broader ex:Demographic%20Data;
   skos:inScheme ex:Liver_Factors .

with the command line operation

rdf serialize my-file.ttl --output-format rdfxml -o my-file.rdf

is

<?xml version='1.0' encoding='utf-8' ?>
<rdf:RDF xmlns:ex2='http://www.example2.org#' xmlns:ex='http://www.example.org#' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' xmlns:skos='http://www.w3.org/2004/02/skos/core#'>
  <skos:Concept rdf:about='http://www.example.org#Age'>
    <rdf:type rdf:resource='http://www.example.org#Liver_Factor'></rdf:type>
    <ex2:datatype>int</ex2:datatype>
    <skos:broader rdf:resource='http://www.example.org#Demographic%20Data'>
    <skos:inScheme rdf:resource='http://www.example.org#Liver_Factors'>
  </skos:Concept>
</rdf:RDF>

The skos:broader and skos:inScheme tags are not closed properly. Is anybody else facing this problem? I use Win7 64bit with Ruby 1.9.3.

Thank you for your help, best regards, Andy

marcelotto commented 10 years ago

When I try to convert the turtle data you're giving here, I get valid RDF/XML. What's the output when running the conversion verbosely with

$ rdf serialize my-file.ttl --output-format rdfxml -o my-file.rdf -v
gkellogg commented 10 years ago

It works properly for me on a Mac as well. I haven't tested on Windows, but I don't see why it would be a problem there. Are you using the latest versions of the various gems? Try doing "gem install linkeddata" or "gem update linkeddata" if you already have it. Also, make sure you have the latest version of the haml gem; it should be at least 4.0.0.

GitHubber1 commented 10 years ago

Hey guys,

thank you for your help. I have installed the newest versions of haml and linkeddata ("noting to update"). When I run it verbosely the output XML is still invalid but many warnings appear in the console, amongst others

instance variable @debug not initialized
instance variable @haml_template not initialized
...

I attached a screenshot with all the installed gems. screenshot_installed_gems

Thank you, Andy

gkellogg commented 10 years ago

It's not a problem for instance variables to not be initialized, so I don't think this should be an issue. @haml_template is typically set, if it's not there. There must be some other issue relating to how Haml generates output on Windows.

When I get a chance, I'll boot up Parallels and try for myself. Feel free to investigate further and add any appropriate fixes to your pull request.

GitHubber1 commented 10 years ago

Hello,

thanks to @marcelotto who told me to try haml 4.0.5 instead of 4.1.0beta1, now everything works properly.

Best regards, Andy