[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: determine the number of payment methods and specif

Subject: Re: 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:38:32 -0500
Re:  determine the number of payment methods and specif
Caroline,

Just to gloss something I just wrote, in order to make it clear:

At 10:26 AM 11/4/2008, I wrote:
If you want to fix the order of the children of 'paymentMethods', you can do:

<xsl:template match="paymentMethods">
  <ul>
    <xsl:apply-templates select="directDebit"/>
    <xsl:apply-templates select="creditCard"/>
    <xsl:apply-templates select="invoice"/>
  </ul>
</xsl:template>

The deal here is that if you have no 'creditCard' element in your 'paymentMethods', for example, then none will be selected and no template will be applied, hence no 'li' element will be generated for it. This handles all the conditional processing needed, in effect testing whether the 'creditCard' element is present (and creating nothing for it if it isn't).


This is why, using the apply-templates approach to your problem, you don't have to do any explicit testing to see whether all three elements are present, or only two (and which two), or only one (and which one), or none at all.

Also, because the order of their appearance has been fixed (if they are present at all), the possible permutations in assigning the value to the li/@class in the result are also reduced -- which is lucky for you, since those values are themselves sensitive to the order.

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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.