|
Subject: RE: [xsl] trying to drop leading/trailing WS text nodes from verb atim From: "Robert P. J. Day" <rpjday@xxxxxxxxxxxxxx> Date: Wed, 3 Sep 2003 08:17:12 -0400 (EDT) |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] trying to drop leading/tr, Robert P. J. Day | Thread | Re: [xsl] trying to drop leading/tr, David Carlisle |
| Re: [xsl] trying to drop leading/tr, David Carlisle | Date | Re: [xsl] trying to drop leading/tr, Robert P. J. Day |
| Month |