Subject: Re: [xsl] determine the number of payment methods and specify order depending on page type being viewed From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Tue, 04 Nov 2008 10:26:42 -0500 |
Sorry...first time in posting here...
ok, so here's an amended version of the XSL:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:html="http://www.w3.org/1999/xhtml"> ... <xsl:template name="checkOutProgressStep"> <xsl:param name="label"/> <xsl:variable name="noOfNodes" select="count(/order/paymentMethods/*)" />
<xsl:choose>
<xsl:when test="$noOfNodes = '3'"><!-- check for 3 elements -->
<xsl:choose>
<xsl:when test="$label = 'directDebit'">
<li class="doubleLine current">Payment by <br/>Direct Debit</li>
<li class="doubleLine">Payment by <br/>Credit Card</li>
<li class="doubleLine">Payment by <br/>Invoice</li>
</xsl:when>
<xsl:when test="$label = 'creditCard'">
<li class="doubleLine completed">Payment by <br/>Direct Debit</li>
<li class="doubleLine current">Payment by <br/>Credit Card</li>
<li class="doubleLine">Payment by <br/>Invoice</li>
</xsl:when>
<xsl:when test="$label = 'invoice'">
<li class="doubleLine completed">Payment by <br/>Direct Debit</li>
<li class="doubleLine completed">Payment by <br/>Credit Card</li>
<li class="doubleLine current">Payment by <br/>Invoice</li>
</xsl:when>
</xsl:choose>
</xsl:when>
</xsl:choose> </xsl:template> ... </xsl:stylesheet>
You'll notice that for the current payment method (specified in the xsl:when test="..."), the class "current" is added. If a payment method exists before the current one, then this will have a class "completed", whereas any subsequent to the current matching payment will have no extra class.
The XML file comes through as : <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="InvoiceForm.xslt"?>
<order> <!-- for navigation --> <paymentMethods> <!-- shopping cart had credit card and invoice payments; credit card payment is already completed --> <creditCard /> <invoice /> </paymentMethods> ... </order>
So, each page would have label set as creditCard - for CC payment directDebit - for DD payment invoice - for invoice payment.
Within the XML, the paymentMethods area can have one, two or three nodes available (no more or less).
The problem that I have (besides not knowing that much), is that if all three payment methods are applicable, then they need to be in the order:
DD payment CC payment I payment
DD payment should always be first, and I payment last.
If the label is set to creditCard (for example), then that indicates the page is a Credit Card page. If this is the case, then the class applied to the relevant list item will be class="doubleLine current". If there are 3 payment methods for the xml, then DD payment should have a class set as class="doubleLine completed" and Invoice should be class="doubleLine".
So not only do I need to determine the number of payment methods present, but I need to specify a type of order to them, and apply the relevant class, depending on the page type being viewed.
<xsl:template match="paymentMethods"> <ul> <xsl:apply-templates select="directDebit"/> <xsl:apply-templates select="creditCard"/> <xsl:apply-templates select="invoice"/> </ul> </xsl:template>
<xsl:template match="directDebit"> <li class="?">Payment by <br/>Direct Debit</li> </xsl:template>
<xsl:template match="creditCard"> <li class="?">Payment by <br/>Credit Card</li> </xsl:template>
<xsl:template match="invoice"> <li class="?">Payment by <br/>Invoice</li> </xsl:template>
<xsl:template match="directDebit"> <xsl:variable name="status"> <xsl:choose> <xsl:when test="$label = 'directDebit'">current</xsl:when> <xsl:otherwise>completed</xsl:otherwise> </xsl:choose> </xsl:variable> <li class="doubleLine {$status}">Payment by <br/>Direct Debit</li> </xsl:template>
<xsl:template match="creditCard"> <xsl:variable name="status"> <xsl:choose> <xsl:when test="$label = 'directDebit'>completed</xsl:when> <xsl:when test="$label = 'creditCard'>current</xsl:when> <xsl:otherwise/> </xsl:choose> </xsl:variable> <li class="doubleLine {$status}">Payment by <br/>Credit Card</li> </xsl:template>
<xsl:template match="invoice"> <xsl:variable name="status"> <xsl:choose> <xsl:when test="$label = 'invoice'>current</xsl:when> <xsl:otherwise/> </xsl:choose> </xsl:variable> <li class="doubleLine {$status}">Payment by <br/>Invoice</li> </xsl:template>
<xsl:variable name="status"> <xsl:if test="$label = 'directDebit'"> current</xsl:if> </xsl:variable> <li class="doubleLine{$status}">Payment by <br/>Direct Debit</li>
<ul> <li class="doubleLine completed">Payment by <br/>Direct Debit</li> <li class="doubleLine">Payment by <br/>Invoice</li> </ul>
Cheers, Wendell
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] determine the number of p, Caroline Umali | Thread | RE: [xsl] determine the number of p, Scott Trenda |
Re: [xsl] typing the input from wit, Colin Paul Adams | Date | RE: [xsl] determine the number of p, Scott Trenda |
Month |