Last active
August 29, 2015 14:06
-
-
Save andrewminton/95c0f39117b4012f6297 to your computer and use it in GitHub Desktop.
This file contains 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
<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> |
This file contains 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
<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="dosomething"> | |
<xsl:with-param name="error" select="1"/> | |
<xsl:with-param name="count" select="position()"/> | |
<!-- any any other initial data needed to be passed --> | |
<xsl:value-of select="$count"/> | |
</xsl:call-template> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="dosomething"> | |
<xsl:param name="error"/> | |
<xsl:param name="count"/> | |
<!-- and others as required --> | |
<xsl:choose> | |
<xsl:when test="$error = 1"> | |
<!-- output the last result, or nothing --> | |
<xsl:value-of select="$error"/> | |
</xsl:when> | |
<xsl:otherwise> | |
<!-- output whatever is needed here --> | |
<xsl:call-template name="dosomething"> | |
<xsl:with-param name="error" select="$error"/> | |
<xsl:with-param name="count" select="position()"/> | |
<!-- any any other modified data needed to be passed --> | |
</xsl:call-template> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment