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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSLT capitalization

Status
Not open for further replies.

JontyMC

Programmer
Joined
Nov 26, 2001
Messages
1,276
Location
GB
I need a transformation that will look at an attribute and capitalize it if contains a certain phrase. For instance if there is an attribute "somewhere in the usa" and the phrase is "usa", it will change the attribute to "somewhere in the USA". Any ideas?

Jon
 
Perhaps run some sort of grep-like function using Regular Expressions over the XML input prior the the transform.

Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.

AU.gif
Check out Tek-Tips Australia New Zealand forum1155
NZ.gif
 
Which would mean using
Code:
sed
to actually effect replacement, provided you're a unix user, otherwise neither of these posts will help.
 
If you want to do this in xsl, you could try this:

<xsl:value-of select=&quot;substring-before(@location,'usa')&quot;/>
<xsl:text>USA</xsl:text>
<xsl:value-of select=&quot;substring-after(@location,'usa')&quot;/>

It gets rather complicated if you have to deal with:
&quot;in usa, or sometimes not in usa&quot;
&quot;somewhere UsA&quot;
or if you also need to replace &quot;timbuktu&quot; and &quot;disneyland&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top