Skip to content

Instantly share code, notes, and snippets.

@designermonkey
Forked from s-e/master.xml
Created March 6, 2013 13:25
Show Gist options
  • Save designermonkey/5099280 to your computer and use it in GitHub Desktop.
Save designermonkey/5099280 to your computer and use it in GitHub Desktop.

Revisions

  1. designermonkey revised this gist Mar 6, 2013. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion master.xsl
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,14 @@
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common">

    <xsl:variable name="user-type" select="'trade'" />
    <xsl:output method="xml"
    doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
    omit-xml-declaration="yes"
    encoding="UTF-8"
    indent="yes"/>

    <xsl:param name="user-type" select="'trade'" />

    <xsl:template match="/">
    <xsl:variable name="offer-merged-products">
  2. designermonkey revised this gist Mar 6, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions master.xsl
    Original file line number Diff line number Diff line change
    @@ -18,12 +18,12 @@
    <xsl:choose>
    <xsl:when test="$user-type = 'trade'">
    <xsl:apply-templates select="exsl:node-set($offer-merged-products)/product" mode="display">
    <xsl:sort select="exsl:node-set($offer-merged-products)/trade-price" data-type="number" order="descending" />
    <xsl:sort select="exsl:node-set($offer-merged-products)/product/trade-price" data-type="number" order="descending" />
    </xsl:apply-templates>
    </xsl:when>
    <xsl:when test="$user-type = 'public'">
    <xsl:apply-templates select="exsl:node-set($offer-merged-products)/product" mode="display">
    <xsl:sort select="exsl:node-set($offer-merged-products)/public-price" data-type="number" order="descending" />
    <xsl:sort select="exsl:node-set($offer-merged-products)/product/public-price" data-type="number" order="descending" />
    </xsl:apply-templates>
    </xsl:when>
    <xsl:otherwise>
  3. designermonkey revised this gist Mar 6, 2013. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions master.xsl
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common">

    <xsl:param name="user-type" select="'trade'" />
    <xsl:variable name="user-type" select="'trade'" />

    <xsl:template match="/">
    <xsl:variable name="offer-merged-products">
    @@ -18,7 +18,7 @@
    <xsl:choose>
    <xsl:when test="$user-type = 'trade'">
    <xsl:apply-templates select="exsl:node-set($offer-merged-products)/product" mode="display">
    <xsl:sort select="exsl:node-set($offer-combined-products)/trade-price" data-type="number" order="descending" />
    <xsl:sort select="exsl:node-set($offer-merged-products)/trade-price" data-type="number" order="descending" />
    </xsl:apply-templates>
    </xsl:when>
    <xsl:when test="$user-type = 'public'">
    @@ -42,7 +42,7 @@
    <xsl:choose>
    <xsl:when test="$offers-node/entry[product/item/@id=$current-product-id]">
    <public-price>
    <xsl:value-of select="$offers-node/entry[product/item/@id=$current-product-id]/public-offer-price" />
    <xsl:value-of select="$offers-node/entry[product/item/@id=$current-product-id]/public-offer-price" />
    </public-price>
    <trade-price>
    <xsl:value-of select="$offers-node/entry[product/item/@id=$current-product-id]/trade-offer-price" />
  4. designermonkey revised this gist Mar 6, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion master.xsl
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common">

    <xsl:variable name="user-type" select="'trade'" />
    <xsl:param name="user-type" select="'trade'" />

    <xsl:template match="/">
    <xsl:variable name="offer-merged-products">
  5. designermonkey revised this gist Mar 6, 2013. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions master.xsl
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,5 @@
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:exsl="http://exslt.org/common">
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common">

    <xsl:variable name="user-type" select="'trade'" />

  6. designermonkey revised this gist Mar 6, 2013. 1 changed file with 74 additions and 72 deletions.
    146 changes: 74 additions & 72 deletions master.xsl
    Original file line number Diff line number Diff line change
    @@ -1,75 +1,77 @@
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:exsl="http://exslt.org/common">

    <xsl:template match="/">
    <xsl:variable name="offer-merged-products">
    <xsl:apply-templates select="data/products/entry" mode="merge-prices" />
    </xsl:variable>
    <table>
    <thead>
    <tr>
    <th>Product</th>
    <th>Price</th>
    </tr>
    </thead>
    <tbody>
    <xsl:choose>
    <xsl:when test="$user-type = 'trade'">
    <xsl:apply-templates select="exsl:node-set($offer-merged-products)/product" mode="display">
    <xsl:sort select="exsl:node-set($offer-combined-products)/trade-price" data-type="number" order="descending" />
    </xsl:apply-templates>
    </xsl:when>
    <xsl:when test="$user-type = 'public'">
    <xsl:apply-templates select="exsl:node-set($offer-merged-products)/product" mode="display">
    <xsl:sort select="exsl:node-set($offer-merged-products)/public-price" data-type="number" order="descending" />
    </xsl:apply-templates>
    </xsl:when>
    <xsl:otherwise>
    <tr class="error"><td colspan="2">Unknown user type!</td></tr>
    </xsl:otherwise>
    </xsl:choose>
    </tbody>
    </table>
    </xsl:template>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:exsl="http://exslt.org/common">

    <xsl:template match="data/products/entry" mode="merge-prices">
    <xsl:variable name="current-product-id" select="@id" />
    <xsl:variable name="offers-node" select="/data/offers" />
    <product>
    <name><xsl:value-of select="name"/></name>
    <xsl:choose>
    <xsl:when test="$offers-node/entry[product/item/@id=$current-product-id]">
    <public-price>
    <xsl:value-of select="$offers-node/entry[product/item/@id=$current-product-id]/public-offer-price" />
    </public-price>
    <trade-price>
    <xsl:value-of select="$offers-node/entry[product/item/@id=$current-product-id]/trade-offer-price" />
    </trade-price>
    </xsl:when>
    <xsl:otherwise>
    <public-price><xsl:value-of select="public-price" /></public-price>
    <trade-price><xsl:value-of select="trade-price" /></trade-price>
    </xsl:otherwise>
    </xsl:choose>
    </product>
    </xsl:template>
    <xsl:variable name="user-type" select="'trade'" />

    <xsl:template match="/">
    <xsl:variable name="offer-merged-products">
    <xsl:apply-templates select="data/products/entry" mode="merge-prices" />
    </xsl:variable>
    <table>
    <thead>
    <tr>
    <th>Product</th>
    <th>Price</th>
    </tr>
    </thead>
    <tbody>
    <xsl:choose>
    <xsl:when test="$user-type = 'trade'">
    <xsl:apply-templates select="exsl:node-set($offer-merged-products)/product" mode="display">
    <xsl:sort select="exsl:node-set($offer-combined-products)/trade-price" data-type="number" order="descending" />
    </xsl:apply-templates>
    </xsl:when>
    <xsl:when test="$user-type = 'public'">
    <xsl:apply-templates select="exsl:node-set($offer-merged-products)/product" mode="display">
    <xsl:sort select="exsl:node-set($offer-merged-products)/public-price" data-type="number" order="descending" />
    </xsl:apply-templates>
    </xsl:when>
    <xsl:otherwise>
    <tr class="error"><td colspan="2">Unknown user type!</td></tr>
    </xsl:otherwise>
    </xsl:choose>
    </tbody>
    </table>
    </xsl:template>

    <xsl:template match="product" mode="display">
    <tr>
    <td><xsl:value-of select="name"/></td>
    <td>
    <xsl:choose>
    <xsl:when test="$user-type = 'trade'">
    <xsl:value-of select="trade-price"/>
    </xsl:when>
    <xsl:when test="$user-type = 'public'">
    <xsl:value-of select="public-price"/>
    </xsl:when>
    <xsl:otherwise />
    </xsl:choose>
    </td>
    </tr>
    </xsl:template>
    </xsl:stylesheet>
    <xsl:template match="data/products/entry" mode="merge-prices">
    <xsl:variable name="current-product-id" select="@id" />
    <xsl:variable name="offers-node" select="/data/offers" />
    <product>
    <name><xsl:value-of select="name"/></name>
    <xsl:choose>
    <xsl:when test="$offers-node/entry[product/item/@id=$current-product-id]">
    <public-price>
    <xsl:value-of select="$offers-node/entry[product/item/@id=$current-product-id]/public-offer-price" />
    </public-price>
    <trade-price>
    <xsl:value-of select="$offers-node/entry[product/item/@id=$current-product-id]/trade-offer-price" />
    </trade-price>
    </xsl:when>
    <xsl:otherwise>
    <public-price><xsl:value-of select="public-price" /></public-price>
    <trade-price><xsl:value-of select="trade-price" /></trade-price>
    </xsl:otherwise>
    </xsl:choose>
    </product>
    </xsl:template>

    <xsl:template match="product" mode="display">
    <tr>
    <td><xsl:value-of select="name"/></td>
    <td>
    <xsl:choose>
    <xsl:when test="$user-type = 'trade'">
    <xsl:value-of select="trade-price"/>
    </xsl:when>
    <xsl:when test="$user-type = 'public'">
    <xsl:value-of select="public-price"/>
    </xsl:when>
    <xsl:otherwise />
    </xsl:choose>
    </td>
    </tr>
    </xsl:template>
    </xsl:stylesheet>
  7. designermonkey revised this gist Mar 6, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions master.xsl
    Original file line number Diff line number Diff line change
    @@ -35,8 +35,8 @@
    </xsl:template>

    <xsl:template match="data/products/entry" mode="merge-prices">
    <xsl:variable name="$current-product-id" select="@id" />
    <xsl:variable name="$offers-node" select="/data/offers" />
    <xsl:variable name="current-product-id" select="@id" />
    <xsl:variable name="offers-node" select="/data/offers" />
    <product>
    <name><xsl:value-of select="name"/></name>
    <xsl:choose>
  8. @s-e s-e revised this gist Mar 6, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion master.xsl
    Original file line number Diff line number Diff line change
    @@ -27,7 +27,7 @@
    </xsl:apply-templates>
    </xsl:when>
    <xsl:otherwise>
    <tr class="error"><td colspan=2>Unknown user type!</td></tr>
    <tr class="error"><td colspan="2">Unknown user type!</td></tr>
    </xsl:otherwise>
    </xsl:choose>
    </tbody>
  9. @s-e s-e created this gist Mar 6, 2013.
    78 changes: 78 additions & 0 deletions master.xml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,78 @@
    <?xml version="1.0" encoding="UTF-8"?>
    <data>
    <products>
    <entry id="1">
    <name>Test</name>
    <public-price>10.00</public-price>
    <trade-price>8.00</trade-price>
    </entry>
    <entry id="2">
    <name>Test</name>
    <public-price>10.00</public-price>
    <trade-price>8.00</trade-price>
    </entry>
    <entry id="3">
    <name>Test</name>
    <public-price>10.00</public-price>
    <trade-price>8.00</trade-price>
    </entry>
    <entry id="4">
    <name>Test</name>
    <public-price>10.00</public-price>
    <trade-price>8.00</trade-price>
    </entry>
    <entry id="5">
    <name>Test</name>
    <public-price>10.00</public-price>
    <trade-price>8.00</trade-price>
    </entry>
    </products>

    <prices>
    <entry id="6">
    <product>
    <item id="1">Test</item>
    </product>
    <public-price>15.00</public-price>
    <trade-price>14.00</trade-price>
    </entry>
    <entry id="7">
    <product>
    <item id="2">Test</item>
    </product>
    <public-price>12.00</public-price>
    <trade-price>11.00</trade-price>
    </entry>
    <entry id="8">
    <product>
    <item id="3">Test</item>
    </product>
    <public-price>18.00</public-price>
    <trade-price>15.00</trade-price>
    </entry>
    </prices>

    <offers>
    <entry id="9">
    <product>
    <item id="1">Test</item>
    </product>
    <public-offer-price>5.00</public-offer-price>
    <trade-offer-price>4.00</trade-offer-price>
    </entry>
    <entry id="10">
    <product>
    <item id="3">Test</item>
    </product>
    <public-offer-price>6.00</public-offer-price>
    <trade-offer-price>5.00</trade-offer-price>
    </entry>
    <entry id="11">
    <product>
    <item id="4">Test</item>
    </product>
    <public-offer-price>7.00</public-offer-price>
    <trade-offer-price>6.00</trade-offer-price>
    </entry>
    </offers>
    </data>
    75 changes: 75 additions & 0 deletions master.xsl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,75 @@
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:exsl="http://exslt.org/common">

    <xsl:template match="/">
    <xsl:variable name="offer-merged-products">
    <xsl:apply-templates select="data/products/entry" mode="merge-prices" />
    </xsl:variable>
    <table>
    <thead>
    <tr>
    <th>Product</th>
    <th>Price</th>
    </tr>
    </thead>
    <tbody>
    <xsl:choose>
    <xsl:when test="$user-type = 'trade'">
    <xsl:apply-templates select="exsl:node-set($offer-merged-products)/product" mode="display">
    <xsl:sort select="exsl:node-set($offer-combined-products)/trade-price" data-type="number" order="descending" />
    </xsl:apply-templates>
    </xsl:when>
    <xsl:when test="$user-type = 'public'">
    <xsl:apply-templates select="exsl:node-set($offer-merged-products)/product" mode="display">
    <xsl:sort select="exsl:node-set($offer-merged-products)/public-price" data-type="number" order="descending" />
    </xsl:apply-templates>
    </xsl:when>
    <xsl:otherwise>
    <tr class="error"><td colspan=2>Unknown user type!</td></tr>
    </xsl:otherwise>
    </xsl:choose>
    </tbody>
    </table>
    </xsl:template>

    <xsl:template match="data/products/entry" mode="merge-prices">
    <xsl:variable name="$current-product-id" select="@id" />
    <xsl:variable name="$offers-node" select="/data/offers" />
    <product>
    <name><xsl:value-of select="name"/></name>
    <xsl:choose>
    <xsl:when test="$offers-node/entry[product/item/@id=$current-product-id]">
    <public-price>
    <xsl:value-of select="$offers-node/entry[product/item/@id=$current-product-id]/public-offer-price" />
    </public-price>
    <trade-price>
    <xsl:value-of select="$offers-node/entry[product/item/@id=$current-product-id]/trade-offer-price" />
    </trade-price>
    </xsl:when>
    <xsl:otherwise>
    <public-price><xsl:value-of select="public-price" /></public-price>
    <trade-price><xsl:value-of select="trade-price" /></trade-price>
    </xsl:otherwise>
    </xsl:choose>
    </product>
    </xsl:template>

    <xsl:template match="product" mode="display">
    <tr>
    <td><xsl:value-of select="name"/></td>
    <td>
    <xsl:choose>
    <xsl:when test="$user-type = 'trade'">
    <xsl:value-of select="trade-price"/>
    </xsl:when>
    <xsl:when test="$user-type = 'public'">
    <xsl:value-of select="public-price"/>
    </xsl:when>
    <xsl:otherwise />
    </xsl:choose>
    </td>
    </tr>
    </xsl:template>
    </xsl:stylesheet>