xsl-list
[Top] [All Lists]

[xsl] normalize-space and the identity template

2010-05-04 22:54:49
I have the following xml:

<Company>
      <Title>Federal Civil Trial </Title>
      <Author>by John Doe </Author>
      <Body>Blah blah blah blah blah. </Body>
</Company>

I need to remove the extra spaces that sometimes occur before the end-tags.

I've been messing around with the identity template, and can get that to copy 
my XML intact.

The following trims the spaces before the end-tags nicely.

<xsl:template match="Company/Title">
      <xsl:copy><xsl:value-of select="normalize-space()"/></xsl:copy>
</xsl:template>
<xsl:template match="Company/Author">
      <xsl:copy><xsl:value-of select="normalize-space()"/></xsl:copy>
</xsl:template>

But what I'm wondering is if there's a way to use the identity template to copy 
the whole tree, but still somehow use normalize-space to remove the spaces. 
This would enable me to not have to match each element of the tree individually 
(there are a lot of possible elements).

I can't quite get me head around this one. Any pointers in the right direction 
are appreciated. 

BTW, I'm stuck having to use XSL 1.0 for this project.

~ Keith

Keith Gilbert
Adobe Certified Instructor: ID, IC, AI, PS, AA
Adobe Community Professional
blog.gilbertconsulting.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>