Re: Creating XML from RDF triples?

This can be done with Jena and the command line e.g.
(unix-like)

% java ...  jena.rdfcopy file1.rdf > file1.nt
% java ...  jena.rdfcopy file2.rdf > file2.nt
% cat file1.nt file2.nt > file3.nt
% java ... jena.rdfcopy file3.nt N-TRIPLE RDF/XML-ABBREV > file3.rdf

The first two steps convert the rdf/xml into ntriples, these can be 
merged by concatenation (possibly some worries with bnode ids).
The last step then converts the N-TRIPLES back to rdf/xml (with Jena's 
pretty printer)

Jeremy







Jan Algermissen wrote:

> Hi,
> 
> I plan to use RDF as a means to merge XML documents and have a question that
> maybe someone has worked on already.
> 
> Here is what I want to do:
> 
> Suppose I have two documents like the ones below:
> 
> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>      xmlns:uml="http://example.org/uml/"
>      xmlns="http://www.foo.com/concepts/">
>  
>   <LinuxPC rdf:about="http://www.foo.com/items/677625">
>     <rdf:label>Host Elephant</rdf:label>
>     <uml:hasDeployedSoftware>
>       <WebServer rdf:about="http://www.foo.com/items/766322">
>         <rdf:label>Apache 1.3</rdf:label>
>       </WebServer>
>     </uml:hasDeployedSoftware>
>   </LinuxPC>
>  
> </rdf:RDF>
> 
> the other one (being another description of this PC)
> 
> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>      xmlns:uml="http://example.org/uml/"
>      xmlns="http://www.foo.com/concepts/">
>  
>   <LinuxPC rdf:about="http://www.foo.com/items/677625">
>     <CPUCount>2</CPUCount>
>     <ResponsiblePerson>Jack Admin</ResponsiblePerson>
>     <!-- lots of other attributes here -->
>   </LinuxPC>
>  
> </rdf:RDF>
> 
> The idea is that they come from different sources and that I
> integrate them by merging their RDF graphs.
> 
> My question is if there has already been any work on producing XML
> again from the merged RDF graph or if there are even tools that
> take the DTD/Schema and transform the RDF into XML.
> 
> The result should then look like this (of course):
> 
> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>      xmlns:uml="http://example.org/uml/"
>      xmlns="http://www.foo.com/concepts/">
>  
>   <LinuxPC rdf:about="http://www.foo.com/items/677625">
>     <rdf:label>Host Elephant</rdf:label>
>     <uml:hasDeployedSoftware>
>       <WebServer rdf:about="http://www.foo.com/items/766322">
>         <rdf:label>Apache 1.3</rdf:label>
>       </WebServer>
>     </uml:hasDeployedSoftware>
>     <CPUCount>2</CPUCount>
>     <ResponsiblePerson>Jack Admin</ResponsiblePerson>
>     <!-- lots of other attributes here -->
>   </LinuxPC>
>  
> </rdf:RDF>
> 
> Thanks a lot in advance for any pointers.
> 
> Jan
> 
> 
> 

Received on Thursday, 30 September 2004 13:57:07 UTC