Dang. Hard problem. I have been using <xsl:templatename="string-replace-all">
template from http://geekswithblogs.net/Erik/archive/2008/04/01/120915.aspx to patch some old code that is tied to XSLT 1.0. It worked fine for a search and replace for one string,
but now I have two possible string search and replaces and it is not working.
The problem is in the same XML element now, I also must search and replace <sup>®</sup> with something that makes sense, named a
Member
137 Points
846 Posts
Replacing two possible strings in XSLT 1.0.
Aug 02, 2013 06:43 PM|codeaholic|LINK
Dang. Hard problem. I have been using <xsl:template name="string-replace-all"> template from http://geekswithblogs.net/Erik/archive/2008/04/01/120915.aspx to patch some old code that is tied to XSLT 1.0. It worked fine for a search and replace for one string, but now I have two possible string search and replaces and it is not working.
The problem is in the same XML element now, I also must search and replace <sup>®</sup> with something that makes sense, named a
or (R)
Anyone know how to do this...help ?
This is my code:
All-Star
15648 Points
2151 Posts
Re: Replacing two possible strings in XSLT 1.0.
Aug 06, 2013 05:07 AM|Happy Chen - MSFT|LINK
hi codeaholic,
A very simple solution (that will work as long as your string value doesn't have spaces):
1.translate ":' into " "
2.normalize-space() to collapse multiple whitespace characters into a single space " "
3.translate single spaces " " into ","
A more robust solution would be to use a recursive template:
</xsl:call-template>
Member
137 Points
846 Posts
Re: Replacing two possible strings in XSLT 1.0.
Aug 06, 2013 10:10 AM|codeaholic|LINK
I already have a recursive Template. The problem is using it "twice". Not sure how to do it. It only seems to work once.
Anyway, I just gave up on this and went to asp.net code and modified the xml document in memory wither search and replace.