Created
June 29, 2017 14:43
-
-
Save andrewminton/e1862d3d45142f3ffda8b2d1a324483b 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> | |
<event-storage> | |
<group id="event"> | |
<item id="International Bat Night - Bangers, Burgers & Bats!"> | |
<item id="event-id">5632</item> | |
<item id="adult-ticket"> | |
<item id="quantity-chosen">4</item> | |
<item id="ticket-name">Adult Ticket</item> | |
<item id="ticket-id">5630</item> | |
<item id="ticket-price">20</item> | |
<item id="total">80</item> | |
</item> | |
<item id="child-ticket-over-7s-only"> | |
<item id="quantity-chosen">2</item> | |
<item id="ticket-name">Child ticket (over 7's only)</item> | |
<item id="ticket-id">5631</item> | |
<item id="ticket-price">8.50</item> | |
<item id="total">17</item> | |
</item> | |
</item> | |
<item id="Introduction to Bushcraft"> | |
<item id="event-id">5629</item> | |
<item id="introduction-to-bushcraft"> | |
<item id="quantity-chosen">4</item> | |
<item id="ticket-name">Introduction to Bushcraft</item> | |
<item id="ticket-id">5628</item> | |
<item id="ticket-price">80</item> | |
<item id="total">320</item> | |
</item> | |
</item> | |
</group> | |
</event-storage> | |
</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" /> | |
<xsl:template match="data"> | |
<xsl:apply-templates select="//data/event-storage/group/item/item[@id !='event-id']" mode="tickets"/> | |
</xsl:template> | |
<xsl:template match="//data/event-storage/group/item/item" mode="tickets"> | |
<xsl:call-template name="selects"> | |
<xsl:with-param name="num">1</xsl:with-param> | |
<xsl:with-param name="count"> | |
<xsl:value-of select="item[@id ='quantity-chosen']"/> | |
</xsl:with-param> | |
</xsl:call-template> | |
</xsl:template> | |
<xsl:template name="selects"> | |
<xsl:param name="num"/> | |
<xsl:param name="count"/> | |
<xsl:if test="$num <= $count"> | |
<xsl:call-template name="tickets"> | |
<xsl:with-param name="number"><xsl:value-of select="$num + 1"/></xsl:with-param> | |
</xsl:call-template> | |
<xsl:call-template name="selects"> | |
<xsl:with-param name="num"> | |
<xsl:value-of select="$num + 1"/> | |
</xsl:with-param> | |
<xsl:with-param name="count"> | |
<xsl:value-of select="$count"/> | |
</xsl:with-param> | |
</xsl:call-template> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template name="tickets"> | |
<div class="ticket"> | |
<input name="tickets-sold[fields][{position()}][ticket]" type="hidden" value="{item[@id='ticket-id']}"/> | |
<input name="tickets-sold[fields][{position()}][event]" type="hidden" value="{../item[@id ='event-id']}"/> | |
<input name="tickets-sold[fields][{position()}][quantity]" type="hidden" value="{item[@id='quantity-chosen']}"/> | |
</div> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment