xsl-list
[Top] [All Lists]

Re: [xsl] normalize-space()?

2006-10-31 12:55:58
Luke Jones wrote:
<xsl:template match="covers">
        [<xsl:apply-templates select="normalize-space(covers)" />]
</xsl:template>

Currently this doesn't pull anything from the covers tag, all I get is
empty [].

One thing puzzles me here. Do you really want to match a node that looks like this:

covers/covers

Likely, you want to match the node 'covers/*' or similar (not sure). Are there templates that need to be applied? I assume so, because you add the comma from some place. If indeed the xpath is incorrect, try this:

<xsl:template match="covers">
   [<xsl:apply-templates select="normalize-space(*)" />]
</xsl:template>


When I leave out the select portion of the expression I get [ LB 101, LR
1332 ].  What I want is [LB 101, LR 1332]. Is the normalize-space
function the way to go to achieve this?

You are doing it the right thing. However, be aware that normalize-space() also "folds" all other space nodes. That means that the following:

<node>  this   is     text
with spaces   </node>

becomes:

<node>this is a text with spaces</node>

It that is what you want, it will work.

Cheers,
-- Abel Braaksma
  http://www.nuntia.com

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