Re: [xsl] Replacing strings in XSL

Subject: Re: [xsl] Replacing strings in XSL
From: Mukul Gandhi <mukul_gandhi@xxxxxxxxx>
Date: Sat, 19 Mar 2005 00:08:31 -0800 (PST)
This can be achieved with the translate function..

For e.g. if the XML is -
<?xml version="1.0" encoding="UTF-8"?>
<root>
  <MANUFACTURER>LG Electronics Inc</MANUFACTURER>
</root>

and XSL is -
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  
  <xsl:output method="html" indent="yes" />
  
  <xsl:template match="/root">  
    <p><xsl:value-of select="translate(MANUFACTURER,'
', '&#160;')" /></p>
  </xsl:template>
  
</xsl:stylesheet>

The output of transform is -
<p>LG&nbsp;Electronics&nbsp;Inc</p>

Hope this is what you needed.

Regards,
Mukul

--- preetig_2 <preetig_2@xxxxxxxxx> wrote:
> Hi Jay,
> 
> My XML has a tag somewhat like this,
> 
> <MANUFACTURER>LG Electronics Inc</MANUFACTURER> 
> 
> The XSL has to replace the white spaces with &nbsp;
> For e.g: LG&nbsp;Electronics&nbsp;Inc
> 
> Hope that helps, please let me know if you have nay
> questions.
> 
> Thanks,
> Preeti 
> 
> 
> > I'm sure it is, but exactly how you'd want to go
> > about it is likely to 
> > depend on the details of what you are trying to
> do.
> > How about sending us 
> > snippets (small but complete enough to show the
> > problem) of your XML 
> > source, your stylesheet so far, and your desired
> > output. It's pretty hard 
> > to answer questions in a vacuum (at least for me).
> > 
> > Jay Bryant
> > Bryant Communicaton Services
> > (presently consulting at Synergistic Solution
> > Technologies)
> > 
> > 
> > 
> > 
> > preetig_2 <preetig_2@xxxxxxxxx> 
> > 03/18/2005 03:07 PM
> > Please respond to
> > xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > 
> > 
> > To
> > xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > cc
> > 
> > Subject
> > [xsl] Replacing strings in XSL
> > 
> > 
> > 
> > 
> > 
> > 
> > Hi ,
> > 
> > I am trying to replace white space with &nbsp; .
> > Please let me know if its doable in XSL.
> > 
> > Thanks,
> > Preeti
> > 
> 
> 
> 
> 		
> __________________________________ 
> Do you Yahoo!? 
> Yahoo! Small Business - Try our new resources site!
> http://smallbusiness.yahoo.com/resources/ 
> 
> 

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Current Thread