Created
September 28, 2012 17:10
-
-
Save ctipper/3801033 to your computer and use it in GitHub Desktop.
Create Docbook keywordset from comma-delimited list of keywords. Of general applicability.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- process keywords --> | |
<xsl:template match="keywords"> | |
<xsl:element name="keywordset"> | |
<xsl:call-template name="keyword"> | |
<xsl:with-param name="keyword-names"><xsl:value-of select="."/> | |
</xsl:with-param> | |
</xsl:call-template> | |
</xsl:element> | |
</xsl:template> | |
<xsl:template name="keyword"> | |
<xsl:param name="keyword-names">keywords here, more keywords</xsl:param> | |
<xsl:choose> | |
<xsl:when test="contains($keyword-names,',')"> | |
<xsl:element name="keyword"> | |
<xsl:choose> | |
<xsl:when test="substring($keyword-names,1,1)=' '"> | |
<xsl:value-of select="substring-before( | |
substring-after($keyword-names,' '), | |
',')"/> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="substring-before($keyword-names,',')"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:element> | |
<xsl:call-template name="keyword"> | |
<xsl:with-param name="keyword-names"> | |
<xsl:value-of select="substring-after($keyword-names,',')"/> | |
</xsl:with-param> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:element name="keyword"> | |
<xsl:choose> | |
<xsl:when test="substring($keyword-names,1,1)=' '"> | |
<xsl:value-of select="substring-after($keyword-names,' ')"/> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="$keyword-names"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:element> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment