java - converting resultset to RDF/XML in Jena -


i'm trying convert resultset in xml/rdf format code:

resultset result = rmparliament.selectquery(select); system.out.println(resultsetformatter.astext(result)); resultsetformatter.outputasrdf(system.out, "rdf/xml", result); 

the second line of code verify correct behaviour of query (it works!), in console following output:

<rdf:rdf     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"     xmlns:xsd="http://www.w3.org/2001/xmlschema#"     xmlns:rs="http://www.w3.org/2001/sw/dataaccess/tests/result-set#" >   <rdf:description rdf:nodeid="a0">     <rs:size rdf:datatype="http://www.w3.org/2001/xmlschema#int">0</rs:size>     <rs:resultvariable>value</rs:resultvariable>     <rs:resultvariable>property</rs:resultvariable>     <rs:resultvariable>name</rs:resultvariable>     <rdf:type rdf:resource="http://www.w3.org/2001/sw/dataaccess/tests/result-set#resultset"/>  </rdf:description> </rdf:rdf> 

is doesn't contain data, what's wrong code?

the problem print debugging consumes results, leaving resultset @ end. there no more results available when try output rdf/xml.

you can fix making resultset rewindable:

resultsetrewindable result =     resultsetfactory.makerewindable( rmparliament.selectquery(select) ); system.out.println(resultsetformatter.astext(result)); result.reset(); // start resultsetformatter.outputasrdf(system.out, "rdf/xml", result); 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -