Created
September 22, 2017 12:26
-
-
Save anonymous/d31514f67f11725706dea2ff5085a721 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> | |
</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" /> | |
ion="1.0" encoding="utf-8"?> | |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<xsl:output method="xml" /> | |
<xsl:template match="/root"> | |
<root> | |
<xsl:for-each select="item"> | |
<xsl:if test="@znam_avg!=999999"> | |
<td> | |
<xsl:value-of select="@val_avg" /> | |
<xsl:if test="@flag_minus=-1"> | |
<xsl:value-of select="'(-1/'" /> | |
<xsl:call-template name="left-trim"> | |
<xsl:with-param name="string" select="@znam_avg" /> | |
</xsl:call-template> | |
<xsl:value-of select="')'" /> | |
</xsl:if> | |
<xsl:if test="@flag_minus=1"> | |
<xsl:value-of select="'(1/'" /> | |
<xsl:call-template name="left-trim"> | |
<xsl:with-param name="string" select="@znam_avg" /> | |
</xsl:call-template> | |
<xsl:value-of select="')'" /> | |
</xsl:if> | |
</td> | |
</xsl:if> | |
</xsl:for-each> | |
</root> | |
</xsl:template> | |
<!-- trim-left recursive template --> | |
<xsl:template name="left-trim"> | |
<xsl:param name="string" select="''" /> | |
<xsl:variable name="tmp" select="substring($string, 1, 1)" /> | |
<xsl:choose> | |
<xsl:when test="$tmp = ' ' or $tmp = '
'"> | |
<xsl:call-template name="left-trim"> | |
<xsl:with-param name="string" select="substring-after($string, $tmp)" /> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="$string" /> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
</xsl:stylesheet> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment