My First XSLT
(Well, my first usage in anger, anyway.)Faced with an XHTML version of the SPARQL spec, and a desire to get the latest EBNF grammar for processing, I actually used the most suitable tool for the job (probably badly, but that's not the point).
The 0 other people in the world who want an EBNF grammar for SPARQL, and don't already have a plain text version, can feel free to use that!<?xml version = "1.0"?>
<xsl:stylesheet version = "1.0"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:apply-templates
select="html:html/html:body/html:div"/>
</xsl:template>
<xsl:template match="text()"/>
<xsl:template
match="html:div[@class='grammarTable']">
<xsl:for-each
select="html:table/html:tbody/html:tr">
<xsl:value-of
select="html:td/html:code[@class = 'gRuleHead']"/>
::= <xsl:value-of
select="html:td/html:code[@class = 'gRuleBody']"/>
<xsl:text>

</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Time to go and get ready for dinner. Mmm. Eating out twice in one day — how indulgent!
Posted at 2005-06-19 10:10:26 by Richard • Link to My First XSLT
Comments, trackbacks.
