Stylesheet (enter XML)
<?xml version="1.0"?> <rt:stylesheet xmlns:rt="http://purl.org/vocab/2003/rdft/"> <!-- Here's an example of declaring a macro for nodepaths --> <rt:macro-set rt:prefix="foaf"> <rt:macro rt:name="Person" rt:value="resource('http://xmlns.com/foaf/0.1/Person')" /> </rt:macro-set> <!-- Here's another macro with a different prefix --> <rt:macro-set rt:prefix="rdf"> <rt:macro rt:name="type" rt:value="resource('http://www.w3.org/1999/02/22-rdf-syntax-ns#type')/*" /> </rt:macro-set> <!-- Yet another macro, showing that they can refer to other macros --> <rt:macro-set rt:prefix="match"> <rt:macro rt:name="AnyPerson" rt:value="resource()[rdf:type = foaf:Person]" /> </rt:macro-set> <!-- The root-template is always called first by the processor --> <rt:root-template> <h1>RDFT Demo</h1> <!-- select all people in this graph the select pattern begins with a slash which means that it acts globally across the whole input graph we could use our AnyPerson macro above but I want to show more of how the nodepath works --> <rt:apply-templates rt:select="/resource()[rdf:type = foaf:Person]" /> </rt:root-template> <!-- This template uses our macro above to make it more obvious what it is doing --> <rt:template rt:pattern="match:AnyPerson"> <h2> <rt:value-of rt:select="node()/resource('http://xmlns.com/foaf/0.1/name')/literal()" /> </h2> <p>Knows the following people:</p> <ul> <rt:for-each rt:select="node()/resource('http://xmlns.com/foaf/0.1/knows')/resource()"> <li><rt:value-of rt:select="node()/resource('http://xmlns.com/foaf/0.1/name')/literal()" /></li> </rt:for-each> </ul> </rt:template> </rt:stylesheet>
Source RDF (enter RDF/XML or the URI of some RDF/XML)
<?xml version="1.0"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:foaf="http://xmlns.com/foaf/0.1/"> <foaf:Person> <foaf:name>Fred Flintstone</foaf:name> <foaf:knows rdf:resource="#barney" /> </foaf:Person> <foaf:Person rdf:ID="barney"> <foaf:name>Barney Rubble</foaf:name> </foaf:Person> </rdf:RDF>
Raw Output
Rendered Output