<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

 <xsl:param name="output">wml</xsl:param>
 <xsl:param name='rate'>4.05</xsl:param>

 <xsl:decimal-format name='pl'
  decimal-separator='.'
  grouping-separator='&#xa0;'/>
 <xsl:variable name="fmt">pl</xsl:variable>
 <xsl:variable name="currency">#&#xa0;### zł</xsl:variable>

 <xsl:output encoding="iso-8859-1" indent="yes"/>

 <xsl:template match="/Output">
  <xsl:choose>

   <xsl:when test="$output=&apos;wml&apos;">
    <xsl:variable name="Total" select="count(Entry)"/>
    <xsl:text disable-output-escaping="yes">
     &lt;!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
      "http://www.wapforum.org/DTD/wml_1.1.xml">
    </xsl:text>
    <wml>
     <xsl:for-each select="Entry">
      <xsl:element name="card">
       <xsl:attribute name="id">ID_<xsl:value-of select="position()"/></xsl:attribute>
       <xsl:attribute name="title">(<xsl:value-of select="position()"/> z <xsl:value-of select="$Total"/>)</xsl:attribute>
       <xsl:if test="position()!=1">
        <do type="accept" label="Wstecz"><prev/></do>
       </xsl:if>
       <xsl:if test="$Total!=position()">
        <do type="prev" label="Dalej">
         <xsl:element name="go">
          <xsl:attribute name="href">#ID_<xsl:value-of select="position()+1"/></xsl:attribute>
         </xsl:element>
        </do>
       </xsl:if>
       <p><small><b><xsl:value-of select="Title"/></b>-
        (<xsl:value-of select="format-number((Price*$rate), $currency, $fmt)"/>)
        <xsl:value-of select="Summary"/></small>
       </p>
      </xsl:element> 
     </xsl:for-each>
    </wml>
   </xsl:when>

   <xsl:when test="$output=&apos;html&apos;">
    <HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8"></META></HEAD>
     <BODY BGCOLOR="ivory">
      <H3>Specjalne Oferty Dostępne Już Teraz!</H3>
      <TABLE BORDER="1" WIDTH="100%" CELLPADDING="7" CELLSPACING="3">
       <xsl:for-each select="Entry">
        <TR>
         <TD VALIGN="TOP"><B><xsl:value-of select="Title"/></B></TD>
         <TD VALIGN="TOP"><xsl:value-of select="Summary"/></TD>
         <TD VALIGN="TOP" WIDTH="60"><xsl:value-of select="format-number((Price*$rate), $currency, $fmt)"/></TD>
        </TR>
       </xsl:for-each>
      </TABLE>
     </BODY>
    </HTML>
   </xsl:when>

   <xsl:otherwise>
    <xsl:message terminate="yes">
     Error: invalid output parameter:
     The output parameter must be 'wml' or 'html'.
    </xsl:message>
   </xsl:otherwise>

  </xsl:choose>
 </xsl:template>

</xsl:stylesheet>

