Skip to content

Instantly share code, notes, and snippets.

@osima
Created January 19, 2011 06:23
Show Gist options
  • Select an option

  • Save osima/785777 to your computer and use it in GitHub Desktop.

Select an option

Save osima/785777 to your computer and use it in GitHub Desktop.
xslで nbsp や u2029 を扱う方法
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" encoding="UTF-8" />
<xsl:variable name="br"><xsl:text>
</xsl:text></xsl:variable> <!-- u2029 -->
<xsl:variable name="nbsp"><xsl:text>&#160;</xsl:text></xsl:variable> <!-- nbsp -->
<!-- br to u2029 -->
<xsl:template match="br">
<xsl:value-of select="$br"/>
</xsl:template>
<!-- blockquote -->
<xsl:template match="blockquote">
<blockquote>
<p aid:pstyle="blockquote">
<Image>
<xsl:attribute name="href" >icons/<xsl:value-of select="@class" />.ai</xsl:attribute>
<xsl:attribute name="position"><xsl:text>inline</xsl:text></xsl:attribute>
</Image>
</p>
<xsl:apply-templates select="@*|node()" />
</blockquote>
<p aid:pstyle="dummy">
</p>
</xsl:template>
<!-- step -->
<xsl:template match="step">
<p aid:pstyle="step">
<Image>
<xsl:attribute name="href">step/stepNum0<xsl:value-of select="@number" />.ai</xsl:attribute>
<xsl:attribute name="position"><xsl:text>inline</xsl:text></xsl:attribute>
</Image>
<span aid:cstyle="nbsp"><xsl:text><xsl:value-of select="$nbsp"/></xsl:text></span>
<xsl:apply-templates select="@*|node()" />
</p>
</xsl:template>
<xsl:template match="@*|node()" >
<xsl:copy><xsl:apply-templates select="@*|node()" /></xsl:copy>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment