Nearly Round-Tripping
Well, it's nearly there. The PHP implementation now supports the generation of elements given only the URI (as opposed to supplying the namespace and local parts separately) which was the major blocker on getting this working. I've extended the spec to allow NodePaths to be specified in the rt:name attribute of rt:element. They're distinguished from string values by enclosing them in curly brackets {} just like in XSLT. I'll do the same for attributes too. There's still some work to do on the actual XML generation around the namespace prefixes but it's essentially all there. The stylesheet itself would be cleaner with some conditional logic in there - that will come soon too.
Here's the stylesheet:
<rt:stylesheet xmlns:rt="http://purl.org/vocab/2003/rdft/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>
<rt:output rt:method="xml" rt:indent="yes"/>
<rt:root-template>
<rdf:RDF>
<rt:for-each rt:select="~subject()">
<rdf:Description>
<rt:attribute rt:name="about" rt:namespace="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rt:value-of rt:select="label()" />
</rt:attribute>
<rt:for-each rt:select="node()/resource()">
<rt:element rt:name="{label()}">
<rt:for-each rt:select="resource()/resource()">
<rt:attribute rt:name="resource" rt:namespace="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rt:value-of rt:select="label()" />
</rt:attribute>
</rt:for-each>
<rt:for-each rt:select="resource()/literal()">
<rt:value-of rt:select="label()" />
</rt:for-each>
</rt:element>
</rt:for-each>
</rdf:Description>
</rt:for-each>
</rdf:RDF>
</rt:root-template>
</rt:stylesheet>
(more…) 
recent comments