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

RE: trying to drop leading/trailing WS text nodes from

Subject: RE: trying to drop leading/trailing WS text nodes from verbatim
From: "Robert P. J. Day" <rpjday@xxxxxxxxxxxxxx>
Date: Wed, 3 Sep 2003 08:17:12 -0400 (EDT)
trailing text
On Wed, 3 Sep 2003 David.Pawson@xxxxxxxxxxx wrote:

> Robert, if you try your solution you make conclude, as I did,
> that the spacing offsets the listings nicely, rather
> than 'mixing' them too closely with the surrounding text?
> 
> regards DaveP

  i thought about that, but decided i wanted to use the verbatim
before/after spacing attributes to control that more precisely.
but there was one thing about the posted solution that i found 
curious, and it has to do with programming practice (just note the
overall structure of the test below):

  <xsl:variable name="contsl">
    <xsl:choose>
      <xsl:when test="count($before) = 0">
	<xsl:call-template name="remove-lf-left">
          <xsl:with-param name="astr" select="$conts"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$conts"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>


  note that the above code tests for two possibilities -- that
count($before) = 0, or it doesn't.  fair enough, but from years
of recursive programming, i'm used to putting the trivial condition
at the top, to get it out of the way quickly.  so i could have
just as easily written this as:

    count($before) > 0 --> trivial
    else               --> recursive call

clearly, the solutions are equivalent, but do folks have any
strong opinions on *recommended* practice?

  as i said, i've always been a fan of trying to recognize and
deal with trivial conditions as soon as possible, to make the
code easier to read top-down.

  thoughts?

rday


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.