First Arc Selecting Stylesheet
I've just shocked myself by running my first arc selecting stylesheet. I'm shocked because all I've changed is the parsing mechanism for nodepaths so that arc selecting nodepaths are allowed. I thought I'd have to change a lot more than just that…! Anyway, here's the first stylesheet:
<rt:stylesheet xmlns:rt="http://purl.org/vocab/2003/rdft/">
<rt:root-template>
<html>
<body>
<rt:apply-templates rt:select="~node()" />
</body>
</html>
</rt:root-template>
<rt:template rt:pattern="node()">
<p><rt:value-of rt:select="label()" /> has arcs:</p>
<ul>
<rt:for-each rt:select="node()/resource()">
<li><rt:value-of rt:select="label()" /></li>
</rt:for-each>
</ul>
</rt:template>
</rt:stylesheet>
I ran it against this RDF…
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<rdf:Description rdf:about="http://1.example.com/">
<dc:creator>Fred Flintstone</dc:creator>
</rdf:Description>
<rdf:Description rdf:about="http://2.example.com/">
<dc:publisher rdf:resource="mailto:publisher@example.com" />
<dc:creator rdf:resource="mailto:webmaster@2.example.com" />
</rdf:Description>
<rdf:Description rdf:about="http://3.example.com/">
<dc:publisher rdf:resource="mailto:publisher@example.com" />
<dc:creator rdf:resource="mailto:webmaster@3.example.com" rdf:value="webmaster"/>
</rdf:Description>
</rdf:RDF>
…and here's the result (tidied up for clarity)…
<html>
<body>
<p>http://1.example.com/ has arcs:</p>
<ul>
<li>http://purl.org/dc/elements/1.1/creator</li>
</ul>
<p>Fred Flintstone has arcs:</p>
<ul/>
<p>http://2.example.com/ has arcs:</p>
<ul>
<li>http://purl.org/dc/elements/1.1/publisher</li>
<li>http://purl.org/dc/elements/1.1/creator</li>
</ul>
<p>mailto:publisher@example.com has arcs:</p>
<ul/>
<p>mailto:webmaster@2.example.com has arcs:</p>
<ul/>
<p>http://3.example.com/ has arcs:</p>
<ul>
<li>http://purl.org/dc/elements/1.1/publisher</li>
<li>http://purl.org/dc/elements/1.1/creator</li>
</ul>
<p>mailto:webmaster@3.example.com has arcs:</p>
<ul>
<li>http://www.w3.org/1999/02/22-rdf-syntax-ns#value</li>
</ul>
<p>webmaster has arcs:</p>
<ul/>
</body>
</html>
Comments
No comments yet.
Leave a comment
Sorry, the comment form is closed at this time.
