xsl-list
[Top] [All Lists]

RE: [xsl] Multiple String Replacements [with a twist]

2007-03-27 16:13:46
If you can use XSLT 2.0, then xsl:analyze-string is the perfect answer to
this problem.

It's possible but tedious to do it with XSLT 1.0 using recursive templates.
It's difficult to tell you what you're doing wrong since you haven't shown
us your code.

Michael Kay
http://www.saxonica.com/ 

-----Original Message-----
From: Ignacio Garcia del Campo [mailto:igarc001(_at_)hotmail(_dot_)com] 
Sent: 27 March 2007 19:56
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Multiple String Replacements [with a twist]

Hello all,

I just started working with XSLT and I find my self stuck on 
this issue.

I want to replace multiple strings for some for most of my 
elements and by looking at some discussions and some code by 
Jeni Tennison I can replace all instances of my strings by a 
simple replacement. However, what I actually want to do, is 
to replace the strings by links.

My replacements look like this:

<foo:string_replacements>

  <foo:search>

     <foo:find>XML</foo:find>

     <foo:replace><a href="xml.com">XML-SITE</a></foo:replace>

  </foo:search>

</foo:string_replacements>

If I use <xlst:copy-of select="foo:search[xx]/replace" /> the 
HTML shows the link correctly, but since I am doing multiple 
substitions of multiple strings I use recursion, and the 
function where the strings are exchanged fails to correctly 
place the anchor code on the output.

I get XML replaced by XML-SITE but the anchor information is 
lost in the process.

I have tried using CDATA sections, but then as you might 
expect I get the escaped string and that's not good either.

Does anyone know how to solve this problem?

I have been using something similar to this: 
http://sources.redhat.com/ml/xsl-list/2000-06/msg00200.html, 
but I need the links to be working.



Thanks.



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>