[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Detecting and replacing "Space" in a XML using XSL

Subject: Re: Detecting and replacing "Space" in a XML using XSL
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 11 Sep 2007 11:50:23 -0400
Re:  Detecting and replacing "Space" in a XML using XSL
Buddhi,

No (you are correct), translate() won't work for this purpose.

If using XSLT 2.0, you want the replace() function.

If using XSLT 1.0, this is considerably more difficult, but not impossible. Consult the FAQ at http://www.dpawson.co.uk/xsl/sect2/replace.html.

Cheers,
Wendell

At 11:51 PM 9/10/2007, you wrote:
Hi all,

I have a string element in a xml file, it can consist a word. After
parsing  I am taking letter by letter with some formatting stuff.

Ex.

My original String:
<Value>H A N</Value>

After Parsing : (I have trimmed output for more clearance)

&lt;Body&gt;
&lt;FontFace value="STDFONT.FNT"&gt;&lt;FontSize value="0.2"&gt;H&lt;/FontSize&gt;&lt;/FontFace&gt;
&lt;FontFace value="STDFONT.FNT"&gt;&lt;FontSize
value="0.2"&gt;&lt;/FontSize&gt;&lt;/FontFace&gt;
&lt;FontFace value="STDFONT.FNT"&gt;&lt;FontSize
value="0.2"&gt;A&lt;/FontSize&gt;&lt;/FontFace&gt;
&lt;FontFace value="STDFONT.FNT"&gt;&lt;FontSize
value="0.2"&gt;&lt;/FontSize&gt;&lt;/FontFace&gt;
&lt;FontFace value="STDFONT.FNT"&gt;&lt;FontSize
value="0.2"&gt;N&lt;/FontSize&gt;&lt;/FontFace&gt;
&lt;/Body&gt;


As you see I have spaces on my original string.

I want to translate spaces into '_x0020_' rather than empty space. I
tried using "translate()" but it will put one character because I have
single space.
translate(substring($text,$i,1), '&#x20;', '_x0020_')

The out put I want to get is...
....
&lt;FontFace value="STDFONT.FNT"&gt;&lt;FontSize value="0.2"&gt;_x0020_&lt;/FontSize&gt;&lt;/FontFace&gt;
....


Please help me....

- Regards

- Buddhi from Sri Lanka -


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.