Sun 19 Jun 2005

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).
<?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>&#x0A;&#x0A;</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
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!

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 RichardLink to My First XSLT
Comments, trackbacks.

Google
Web holygoat.co.uk
  • richard is: