I want to convert the RDF/XML file into a table of 3 columns, namely "Subject" "Predicate" and "Object", these are known as RDF triples.
the RDF/XML file is as shown below:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:h="http://www.w3.org/1999/xhtml">
<rdf:Description rdf:about="http://www.w3.org/TR/2004/REC-rdf-mt-20040210/">
<dc:title xmlns:dc="http://purl.org/dc/elements/1.1/">RDF Semantics - W3C Recommendation 10 February 2004</dc:title>
</rdf:Description>
<rdf:Description rdf:about="http://www.w3.org/TR/2004/REC-rdf-mt-20040210/">
<dc:creator rdf:resource="#a1" xmlns:dc="http://purl.org/dc/elements/1.1/" />
</rdf:Description>
<rdf:Description rdf:about="#a1">
<rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person" />
</rdf:Description>
<rdf:Description rdf:about="#a1">
<foaf:name xmlns:foaf="http://xmlns.com/foaf/0.1/">Patrick Hayes</foaf:name>
</rdf:Description>
<rdf:Description rdf:about="#a1">
<foaf:homepage rdf:resource="http://www.ihmc.us/users/user.php?UserID=42" xmlns:foaf="http://xmlns.com/foaf/0.1/" />
</rdf:Description>
</rdf:RDF>
and the XSLT I have created:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
<xsl:template match="/">
<html>
<body>
<table border="1">
<tr bgcolor="#5d7b9d" >
<th style="color: white">Subject</th>
<th style="color: white">Predicate</th>
<th style="color: white">Object</th>
</tr>
<xsl:for-each select="rdf:RDF/rdf:Description">
<tr>
<td><xsl:value-of select="@rdf:about"/></td>
<xsl:for-each select="*">
<td><xsl:value-of select="name()"/></td>
<td><xsl:value-of select="@rdf:resource"/>
<xsl:value-of select="//*/rdf:Description"/>
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
via the XSLT, I was able to produce correct results for Subject, Predicate, but not for Object, because some objects are the literal encapsulated within XML elements. I tried using the xsl:value-of select="//*/rdf:Description"/ but it just returns all the literals of the document. Please help, thanks.