[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Transform RDF to CSV files


Subject: Re: [xsl] Transform RDF to CSV files
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Mon, 19 Mar 2007 22:20:36 +0100

oknam park wrote:

I have experienced transforming XML files to CSV by XSLT. But, have no ideas how to transform RDF to CSV.



Well, in short, RDF is XML, so you can use your experience with XML to transform it to CSV.


Of course, there is no such thing as RDF to CSV, because RDF is a layered hierarchical format, and CSV is flat non-hierarchical, not even relational. So, just replying "do xyz to transform RDF to CSV" won't get you there.

Here's a small example of an RDF file from xml.com: http://www.xml.com/pub/a/2001/01/24/rdf.html


<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:ex="http://www.example.org/">
<rdf:Description rdf:about="http://www.example.org/vincent_donofrio">
<ex:starred_in>
<ex:tv_show rdf:about="http://www.example.org/law_and_order_ci" />
</ex:starred_in>
</rdf:Description>
<rdf:Description rdf:about="http://www.example.org/the_thirteenth_floor">
<ex:similar_plot_as rdf:resource="http://www.example.org/the_matrix" />
</rdf:Description>
</rdf:RDF>



Now, to get the rdf:Description node, you can write something like this:


<xsl:template match="rdf:Description">
  <xsl:sequence select="@rdf:about">
  <xsl:text>,</xsl:text>
</xsl:template>

But that is only one column. You will have to find out for yourself what data for what requirements goes into what column. Then we can help you to sort out what kind of XPaths you can use to process the RDF feeds or documents into those CSV fields.

Cheers,
-- Abel Braaksma
  http://www.nuntia.nl


Current Thread
Keywords
xml