Skip to content

Instantly share code, notes, and snippets.

@designermonkey
Created February 26, 2013 11:42
Show Gist options
  • Select an option

  • Save designermonkey/5037890 to your computer and use it in GitHub Desktop.

Select an option

Save designermonkey/5037890 to your computer and use it in GitHub Desktop.
<data>
<store-product-offers>
<section id="14" handle="special-offers">Special Offers</section>
<entry id="127">
<product>
<item id="68" handle="br1-a-line-petticoat" section-handle="products" section-name="Products">BR1 (A-line petticoat)</item>
</product>
<country>
<item id="14" handle="united-states" section-handle="countries" section-name="Countries">United States</item>
</country>
<trade-offer-price handle="5">5</trade-offer-price>
<public-offer-price handle="8">8</public-offer-price>
<start-date iso="2013-02-26T10:20:34+00:00" time="10:20" weekday="2" offset="+0000">2013-02-26</start-date>
<end-date iso="2013-03-26T10:19:34+00:00" time="10:19" weekday="2" offset="+0000">2013-03-26</end-date>
</entry>
</store-product-offers>
</data>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<xsl:variable name="this-id" select="'68'"/>
<xsl:variable name="country-id" select="'14'"/>
<xsl:variable name="special-offer">
<xsl:apply-templates select="data/*[section/@handle = 'special-offers']/entry[(product/item[1]/@id = $this-id) and (country/item/@id = $country-id)]" mode="normal">
<xsl:with-param name="member" select="$member"/>
</xsl:apply-templates>
</xsl:variable>
<xsl:value-of select="$special-offer" />
</xsl:template>
<xsl:template match="*[section/@handle = 'special-offers']/entry" mode="normal">
<xsl:param name="member"/>
<xsl:variable name="this-country-id" select="country/item/@id"/>
<xsl:variable name="currency" select="/data/site-country/entry[@id = $this-country-id]/symbol/text()"/>
<xsl:value-of select="'test'"/>
<xsl:value-of select="$currency"/>
<xsl:choose>
<xsl:when test="$member = 'trade'"><xsl:value-of select="format-number(trade-offer-price/text(), '###,###.00')"/></xsl:when>
<xsl:otherwise><xsl:value-of select="format-number(public-offer-price/text(), '###,###.00')"/></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