xsl-list
[Top] [All Lists]

RE: [xsl] inline troubles

2006-09-07 14:41:37
Luke,

This is XSLT.

The rule is, whitespace in a template doesn't count, *except* when it's mixed with non-whitespace text, at which point it gets copied into the result just like all the other text. This is what's happening to you.

(If you think about it, actually, no other rule would be quite sane.)

In order to get around the mess this sometimes causes when we nevertheless wish our templates to be formatted legibly (as in your case), we have <xsl:text>...</xsl:text>:

<xsl:template match="name">
  <xsl:value-of select="name" />
  <xsl:text> : </xsl:text>
  <xsl:apply-templates />
</xsl:template>

(But are you sure you want the value of the first name element child of the name element? That seems rather odd.)

Cheers,
Wendell

At 04:30 PM 9/7/2006, you wrote:
Ok, so I've broken this stuff down into templates, and I *think* I'm
understanding how its handling everything.  However, I seem to be
running into a bit of a formatting nightmare.

Say I want to print someones name followed by a : and then a description
about them.

I have something like this in the xsl

<xsl:template match="name">
<xsl:value-of select="name" /> :
<xsl:apply-templates />
</xsl:template>

<xsl:template match="desc">
<xsl:value-of select="para"/>
<xsl:apply-templates/>
</xsl:template>

So by that method, I'm expecting... name: desc (moves to next line)
However, I'm getting a mixed version of... :name (LFCR)
desc

I'm not sure if this is XSLT or maybe because I'm using FOP.  Anyone run
into this before?


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>