Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="utf-8"?>
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:derp1="derp1.amber"
- xmlns:derp2="derp2.amber">
- <xsl:output method="html"/>
- <xsl:template name="map">
- <xsl:param name="funkcja"/>
- <xsl:param name="lista"/>
- <xsl:for-each select="$lista/uczestnik">
- <xsl:copy>
- <xsl:apply-templates select="$funkcja">
- <xsl:with-param name="arg" select="."/>
- </xsl:apply-templates>
- </xsl:copy>
- </xsl:for-each>
- </xsl:template>
- <xsl:template name ="filter">
- <xsl:param name="funkcja"/>
- <xsl:param name="lista"/>
- <xsl:for-each select="$lista">
- <xsl:variable name="fTest">
- <xsl:apply-templates select="$funkcja">
- <xsl:with-param name="arg" select="."/>
- </xsl:apply-templates>
- </xsl:variable>
- <xsl:if test="string($fTest)='true'">
- <xsl:copy-of select="."/>
- </xsl:if>
- </xsl:for-each>
- </xsl:template>
- <xsl:template name="reduce">
- <xsl:param name="funkcja"/>
- <xsl:param name="wPocz"/>
- <xsl:param name="lista"/>
- <xsl:choose>
- <xsl:when test="not($lista)">
- <xsl:copy-of select="$wPocz"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable name="fWynik">
- <xsl:apply-templates select="$funkcja">
- <xsl:with-param name="arg1" select="$wPocz"/>
- <xsl:with-param name="arg2" select="$lista[1]"/>
- </xsl:apply-templates>
- </xsl:variable>
- <xsl:call-template name="reduce">
- <xsl:with-param name="funkcja" select="$funkcja"/>
- <xsl:with-param name="wPocz" select="$fWynik"/>
- <xsl:with-param name="lista" select="$lista[position()>1]"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="*[namespace-uri()='derp1.amber']">
- <xsl:param name="arg"/>
- <tr>
- <td>
- <xsl:value-of select="$arg/nazwa"/>
- </td>
- <td>
- <xsl:value-of select="$arg/zdolnosc"/>
- </td>
- <td>
- <xsl:value-of select="$arg/sms"/>
- </td>
- <td>
- <xsl:value-of select="$arg/ocena"/>
- </td>
- <td>
- <xsl:value-of select="$arg/medialny"/>
- </td>
- </tr>
- </xsl:template>
- <xsl:variable name="funkcjadomap" select="document('')/*/derp1:*[1]" />
- <derp1:derp1/>
- <xsl:template match="/">
- <html>
- <body>
- <h2>Uczestnicy Show</h2>
- <table border="1">
- <tr bgcolor="#9acd32">
- <th>Nazwa</th>
- <th>Zdolność</th>
- <th>Sms</th>
- <th>Ocena</th>
- <th>Medialny</th>
- </tr>
- <xsl:call-template name="map">
- <xsl:with-param name="funkcja" select="$funkcjadomap"/>
- <xsl:with-param name="lista" select="show"/>
- </xsl:call-template>
- </table>
- </body>
- </html>
- </xsl:template>
- </xsl:stylesheet>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement