Skip to content

Instantly share code, notes, and snippets.

@frogcat
Created October 30, 2015 07:40
Show Gist options
  • Save frogcat/b356d8917e000ea94bd5 to your computer and use it in GitHub Desktop.
Save frogcat/b356d8917e000ea94bd5 to your computer and use it in GitHub Desktop.
SPARQL1.1Query の関数定義を抜いて Qiita の Markdown に整形するためのスタイルシート
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:h="http://www.w3.org/1999/xhtml">
<xsl:output method="text" />
<xsl:template match="/">
<xsl:apply-templates select="//*[@id='SparqlOps']/../.." />
</xsl:template>
<xsl:template match="*">
<xsl:apply-templates select="*" />
</xsl:template>
<xsl:template match="h:div[not(.//h:pre)]" />
<xsl:template match="h:h4">
<xsl:value-of select="string('# ')" />
<xsl:value-of select="string('[')" />
<xsl:value-of select="substring-after(string(.),' ')" />
<xsl:value-of select="string(']')" />
<xsl:value-of select="string('(')" />
<xsl:value-of select="string('http://www.w3.org/TR/sparql11-query/#')" />
<xsl:value-of select="h:a/@name" />
<xsl:value-of select="string(')')" />
<xsl:value-of select="string('&#10;')" />
<xsl:value-of select="string('&#10;')" />
<xsl:apply-templates select="*" />
</xsl:template>
<xsl:template match="h:div[h:h5 and .//@class='prototype']">
<xsl:value-of select="string('```:')" />
<xsl:value-of select="translate(substring-after(string(h:h5),' '),' ','_')" />
<xsl:value-of select="string('&#10;')" />
<xsl:apply-templates select="*" />
<xsl:value-of select="string('```&#10;')" />
<xsl:value-of select="string('&#10;')" />
</xsl:template>
<xsl:template match="h:pre[@class='prototype']">
<xsl:value-of select="string(.)" />
<xsl:value-of select="string('&#10;')" />
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment