All pastes #123703 Raw Edit

Unnamed

public text v1 · immutable
·published 2006-08-09 14:49 UTC
rendered paste body
<?xml version="1.0" encoding="UTF-8"?>
<!-- Author: Sean Wheller sean@inwords.co.za -->

<!-- Modified: Paul Mitchell libertus@libertini.net
      use xsl:copy instead of xsl:element
      add ID to unIDed entries without xsl:if
      removed temporary variables during ID generation
      I don't like title unescaped in the IDs -->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="xml" indent="yes" encoding="UTF-8" version="1.0"/>
    <xsl:template match="/">
        <xsl:apply-templates/>
    </xsl:template>

    <xsl:template match="glossdiv">
        <xsl:copy>
            <xsl:attribute name="id">
                <xsl:value-of select="title"/>
            </xsl:attribute>
            <xsl:apply-templates/>
        </xsl:copy>
    </xsl:template>

    <!-- name[@id] is higher priority than name alone -->
    <xsl:template match="glossentry[@id]|title|glossterm|glossdef">
        <xsl:copy-of select="."/>
    </xsl:template>

    <xsl:template match="glossentry">
        <xsl:copy>
            <xsl:attribute name="id">
                <xsl:value-of select="concat(position(), '-', //glossdiv/title, '-', generate-id())"/>
            </xsl:attribute>
            <xsl:apply-templates/>
        </xsl:copy>
    </xsl:template>

</xsl:stylesheet>