Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSL substitution

Status
Not open for further replies.

Astor

Programmer
Jul 3, 2002
12
ES
Hi everyone,

I have a simple problem yet seems more complicated than it should really be. I'm creating an XSL to display my XML.

I have the following string

<MANAGERS>GS/ML/CSFB</MANAGERS>

This is what I want to display
GS / ML / CSFB
In other words, I need to add a white space between each &quot;/&quot;.

The problem is that since it comes in the same string, I can't find a way to manipulate it (a simple substitution would do).

Any thoughts?
Thanks.
 
One way...

<xsl:variable name=&quot;unformatted_data&quot; select=&quot;record/item/value/MANAGERS&quot;/>
<xsl:variable name=&quot;formatted_data&quot; select=&quot;concat(substring($unformatted_data, 1, 2), ' / ',substring($unformatted_data, 4, 2), ' / ',substring($unformatted_data, 7, 4))&quot;/>
 
Thanks for the reponse, but the managers names are not always the same amount of character. Those were just examples.

I'm getting a list of managers that could either be:
GS/ML/CSFB
or
CSFB/LEHMAN/ML
or
...

I'm really perplexed that you cannot do a simple substitution in XSL. which involves 1 char for 3 characters (two white spaces and 1 foward slash) It does shows some big holes in the language.
 
>> It does shows some big holes in the language.

That's why the latest spec supports functions, does your engine support that feature? If so that's probably what you need to do.

-pete
 
>>I'm really perplexed that you cannot do a simple substitution in XSL. which involves 1 char for 3 characters (two white spaces and 1 foward slash) It does shows some big holes in the language.


Any true developer (programmer) is resourceful. Therefore use a language like Perl to transform your file to the &quot;proper format&quot;, don't blame your problems on XSL.


 
And to continue loosecannon1's point, one might argue that the better time to address that particular formatting issue is when the XML data is generated since that would be handled by a more suitable language/tool.

-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top