Re: [xsl] determine the number of payment methods and specify order depending on page type being viewed

Subject: Re: [xsl] determine the number of payment methods and specify order depending on page type being viewed
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 03 Nov 2008 17:03:27 -0500
Caroline,

Please forgive us if we can't address your problems instantly.

What you are trying to do isn't beyond the reach of an expert in the language, but you are looking at several problems at once, which need to be disentangled.

I'm afraid I can't do that at this moment, but I can make a suggestion that would help myself (if I should have more free time another day) or another reader to interpret what you are trying to do and help you work it out. Would it be possible for you to rewrite your code using literal result element syntax instead of explicit xsl:element and xsl:attribute instructions for everything?

An example of what I mean -- would you be able to rewrite

<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>

as this:


<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>

... and similarly throughout the rest of your code sample?

(You will notice I have also dropped your variables $ddPayment, $ccPayment, and $iPayment, which make the code more obscure without adding anything at present. These can always be restored later, if wanted.)

As you can see, the LRE syntax is more more concise and legible. This would make it possible to recognize the patterns in your logic.

This is doubly important for you since recognizing, abstracting and simplifying the patterns in your logic is the essence of the problem here. What you will find is that like any programming language, XSLT makes it possible to factor out repetition and distill that logic to its simplest most comprehensible form.

But only if you can see those patterns first -- and we can't.

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