Skip to content

Instantly share code, notes, and snippets.

@andrewminton
Last active August 29, 2015 14:06
Show Gist options
  • Save andrewminton/3ce8592d1b7ccd103630 to your computer and use it in GitHub Desktop.
Save andrewminton/3ce8592d1b7ccd103630 to your computer and use it in GitHub Desktop.
<data>
<hello>paste your xml here</hello>
<entry><title message="error"></title></entry>
<entry><title message="error"></title></entry>
<entry><title message="error"></title></entry>
<entry><title message="error"></title></entry>
</data>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<hi>
<xsl:value-of select="data/hello" />
</hi>
<xsl:apply-templates select="entry" mode="errors"/>
</xsl:template>
<xsl:template match="entry" mode="errors">
<xsl:if test="title/@message = 'error'">
<xsl:call-template name="error-check">
<xsl:with-param name="error-count" select="$error-count + 1"/>
<xsl:if test="position() = last()">
<xsl:value-of select="$error-count"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="error-count">
<xsl:param name="error-count" select="0"/>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment