Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] XSL help

From: "Caroline Umali" <carolineumali@--------->
To:
Date: 11/3/2008 5:44:00 PM
Hi Guys,

Fairly new to this forum, so please excuse me for repetition.

Here is the scenario for my problem. I have three types of payment
pages for a checkout process.  There is a progress bar at the top of
the page which indicates what stage the user is at in checkout.

I have an HTML out put which I want as follows:
<ul id="progressNav">
<li class="completed">Your Details</li>
<li class="current">Billing Address</li>
<li>Delivery Address</li>
<li>Check Details</li>
<li class="doubleLine">Payment by<br /> Direct Debit</li>
<li class="doubleLine">Payment by<br /> Credit Card</li>
<li class="doubleLine">Payment by<br /> Invoice</li>
<li>Confirmation</li>
</ul>

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>

The XSL extract for this area is:
<?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:variable name="ddPayment">Direct Debit</xsl:variable>
    <xsl:variable name="ccPayment">Credit Card</xsl:variable>
    <xsl:variable name="iPayment">Invoice</xsl:variable>

    <xsl:choose>
        <xsl:when test="$noOfNodes = '3'"><!-- check for 3 elements -->
            <xsl:choose>
                <xsl:when test="$label = 'directDebit'">
                    <xsl:element name="li">
                        <xsl:attribute name="class">doubleLine
current</xsl:attribute>
                        Payment by <br/><xsl:value-of select="$ddPayment" />
                    </xsl:element>
                    <xsl:element name="li">
                        <xsl:attribute name="class">doubleLine</xsl:attribute>
                        Payment by <br/><xsl:value-of select="$ccPayment" />
                    </xsl:element>
                    <xsl:element name="li">
                        <xsl:attribute name="class">doubleLine</xsl:attribute>
                        Payment by <br/><xsl:value-of select="$iPayment" />
                    </xsl:element>
                </xsl:when>

                <xsl:when test="$label = 'creditCard'">
                    <xsl:element name="li">
                        <xsl:attribute name="class">doubleLine</xsl:attribute>
                        Payment by <br/><xsl:value-of select="$ddPayment" />
                    </xsl:element>
                    <xsl:element name="li">
                        <xsl:attribute name="class">doubleLine
current</xsl:attribute>
                        Payment by <br/><xsl:value-of select="$ccPayment" />
                    </xsl:element>
                    <xsl:element name="li">
                        <xsl:attribute name="class">doubleLine</xsl:attribute>
                        Payment by <br/><xsl:value-of select="$iPayment" />
                    </xsl:element>
                </xsl:when>

                <xsl:when test="$label = 'invoice'">
                    <xsl:element name="li">
                        <xsl:attribute name="class">doubleLine</xsl:attribute>
                        Payment by <br/><xsl:value-of select="$ddPayment" />
                    </xsl:element>
                    <xsl:element name="li">
                        <xsl:attribute name="class">doubleLine</xsl:attribute>
                        Payment by <br/><xsl:value-of select="$ccPayment" />
                    </xsl:element>
                    <xsl:element name="li">
                        <xsl:attribute name="class">doubleLine
current</xsl:attribute>
                        Payment by <br/><xsl:value-of select="$iPayment" />
                    </xsl:element>
                </xsl:when>
            </xsl:choose>
        </xsl:when>
    </xsl:choose>
</xsl:template>
...
</xsl:stylesheet>

The parameter $label is set in the base xslt file which has all the
html output, and is specific to the page type (there are 3 page types,
credit card, direct debit and invoice payments).

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.

Any help would be greatly appreciated.

Apologies again if this is somewhat convoluted!


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent