Re: [xsl] removing space in a text node

Subject: Re: [xsl] removing space in a text node
From: Mukul Gandhi <mukul_gandhi@xxxxxxxxx>
Date: Wed, 16 Mar 2005 19:36:02 -0800 (PST)
You have not said what is your desired output.. But
just guessing, you need the output to be exactly same
as input, except you want "to remove the leading space
from in front of the comma that sits between the
descriptiveWord nodes".

Probably you need an identity template.. And a
template to modify the text node. Please note the 2nd
template. It matches a text node which contains a
comma, and whose immediate preceding & immediate
following sibling nodes are descriptiveWord.

<?xml version="1.0"?> 
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">
 
 <xsl:output method="xml" indent="yes" /> 

 <xsl:template match="@* | node()">
  <xsl:copy>
   <xsl:apply-templates select="@* | node()" />
  </xsl:copy> 
 </xsl:template>
 
 <xsl:template
match="text()[contains(.,',')][name(preceding-sibling::*[1])
= 'descriptiveWord'][name(following-sibling::*[1]) =
'descriptiveWord']">
   <xsl:value-of
select="concat(substring-before(.,','),',')" />
 </xsl:template>
 
</xsl:stylesheet>

Regards,
Mukul

--- Peter Charles <petefc@xxxxxxxxxxxxxxxxx> wrote:
> Hello,
> 
> If I have the following structure:
> 
> <field name="c14alias" displayName="Created By">
> 	<descriptiveWord> Malina </descriptiveWord> ,
>       <descriptiveWord> Mark </descriptiveWord>
> </field>
> 
> Is there an easy way to remove the leading space
> from in front of the comma
> that sits between the descriptiveWord nodes?
> 
> Thanks
> 
> Peter
> 
> 


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 

Current Thread