[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xsl-list
Subject:    Re: [xsl] Recursive string replace in XSLT 2.0
From:       "Rick Quatro rick () rickquatro ! com" <xsl-list-service () lists ! mulberrytech ! com>
Date:       2017-01-06 22:27:37
Message-ID: 20170106172658.33855 () lists ! mulberrytech ! com
[Download RAW message or body]

Hi David,

 

OK, I get it now. Thank you for clarifying.

 

Rick

 

From: David Carlisle d.p.carlisle@gmail.com \
                [mailto:xsl-list-service@lists.mulberrytech.com] 
Sent: Friday, January 06, 2017 4:41 PM
To: xsl-list@lists.mulberrytech.com
Subject: Re: [xsl] Recursive string replace in XSLT 2.0

 

not here

    <xsl:param name="regexes" as="element(regex)*">

Michael meant here, in the template definition

        <xsl:param name="regex"/>



You could declare your top level initialiser to also be a sequence of elements but \
then your initial call would have to be


            <xsl:with-param name="regex" select="$regexes"/>

not

            <xsl:with-param name="regex" select="$regexes/regex"/>

David

 

On 6 January 2017 at 21:37, Rick Quatro rick@rickquatro.com \
<xsl-list-service@lists.mulberrytech.com> wrote:

Thank you Michael. Oddly enough, when I add the as="element(regex)*" the
finds/changes fail. Here is the entire stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="xs"
    version="2.0">

    <xsl:output indent="yes"/>

    <xsl:param name="regexes" as="element(regex)*">
        <regex><find>&quot;(\S)</find><change>&#8220;$1</change></regex>
        <regex><find>(\S)&quot;</find><change>$1&#8221;</change></regex>
    </xsl:param>

    <xsl:template match="/">
        <xsl:apply-templates/>
    </xsl:template>

    <xsl:template match="p">
        <p><xsl:apply-templates/></p>
    </xsl:template>

    <xsl:template match="text()[string-length(normalize-space(.))>0]">
        <xsl:call-template name="applyRegexes">
            <xsl:with-param name="nodeText" select="."/>
            <xsl:with-param name="regex" select="$regexes/regex"/>
         </xsl:call-template>
    </xsl:template>

    <xsl:template name="applyRegexes">
        <xsl:param name="nodeText"/>
        <xsl:param name="regex"/>
        <xsl:choose>
            <xsl:when test="$regex">
                <xsl:variable name="temp">
                    <xsl:value-of
select="replace($nodeText,$regex[1]/find,$regex[1]/change)"/>
                </xsl:variable>
                <xsl:call-template name="applyRegexes">
                    <xsl:with-param name="nodeText" select="$temp"/>
                    <xsl:with-param name="regex"
select="$regex[position()>1]"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$nodeText"/>
            </xsl:otherwise>
        </xsl:choose>
     </xsl:template>

</xsl:stylesheet>

Here is my input:

<?xml version='1.0' encoding='UTF-8'?>
<root>
   <test><p class="Note">&quot;Abcdefghij.&quot;</p></test>
   <test><p class="Note">&quot;defghij.&quot;</p></test>
</root>

Without the as attribute, the finds/changes are applied, but with it, they
don't. Thanks.

--Rick


-----Original Message-----
From: Michael Kay mike@saxonica.com
[mailto:xsl-list-service@lists.mulberrytech.com]
Sent: Friday, January 06, 2017 4:25 PM
To: xsl-list@lists.mulberrytech.com
Subject: Re: [xsl] Recursive string replace in XSLT 2.0

If you don't like head-tail recursion for this kind of problem, there are a
couple of alternatives you might consider.

One is xsl:iterate, which looks something like this:

<xsl:iterate select="$list-of-replacements">
  <xsl:param name="str" as="xs:string"/>
  <xsl:on-completion select="$str"/>
  <xsl:next-iteration>
    <xsl:with-param name="str" select="replace($str, find, change)"/>
  </xsl:next-iteration>
</xsl:iterate>

The other is fold-left:

fold-left($list-of-replacements, $str, function($str, $regex) {
replace($str, $regex/find, $regex/change) } )

Both these require 3.0.

Michael Kay
Saxonica


> On 6 Jan 2017, at 19:41, David Carlisle d.p.carlisle@gmail.com
<xsl-list-service@lists.mulberrytech.com> wrote:
> 
> I'd have written it as a function rather than template, but the main
> issue is you want your parameter to be (always) a sequence of elements
> not sometimes a sequence of elements and sometimes a document node
> with a sequence of child elements.
> 
> <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> exclude-result-prefixes="xs"
> version="2.0">
> 
> <xsl:output indent="yes"/>
> 
> <xsl:param name="regexes">
> <regex><find>a</find><change>x</change></regex>
> <regex><find>b</find><change>y</change></regex>
> <regex><find>c</find><change>z</change></regex>
> </xsl:param>
> 
> <xsl:template match="/">
> <xsl:apply-templates/>
> </xsl:template>
> 
> <xsl:template match="p">
> <p><xsl:apply-templates/></p>
> </xsl:template>
> 
> <xsl:template match="text()"><!--[string-length(.)>0]-->
> <xsl:message select="."></xsl:message>
> <xsl:call-template name="applyRegexes">
> <xsl:with-param name="nodeText" select="."/>
> <xsl:with-param name="regex" select="$regexes/regex"/>
> </xsl:call-template>
> </xsl:template>
> 
> <xsl:template name="applyRegexes">
> <xsl:param name="nodeText"/>
> <xsl:param name="regex"/>
> <xsl:message select="$regex"></xsl:message>
> <xsl:message select="$regex[1]"/>
> <xsl:message select="$regex[position()>1]"/>
> <xsl:choose>
> <xsl:when test="$regex">
> <xsl:call-template name="applyRegexes">
> <xsl:with-param name="nodeText"
> select="replace($nodeText,$regex[1]/find,$regex[1]/change)"/>
> <xsl:with-param name="regex"
> select="$regex[position()>1]"/>
> </xsl:call-template>
> </xsl:when>
> <xsl:otherwise>
> <xsl:value-of select="$nodeText"/>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:template>
> 
> </xsl:stylesheet>
> 

 

XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>  

EasyUnsubscribe <-list/612310>  (by email <> ) 
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/651070
or by email: xsl-list-unsub@lists.mulberrytech.com
--~--


[Attachment #3 (text/html)]

<html xmlns:v="urn:schemas-microsoft-com:vml" \
xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" \
xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type \
content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 12 \
(filtered medium)"><style><!-- /* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
	{mso-style-priority:99;
	mso-style-link:"Balloon Text Char";
	margin:0in;
	margin-bottom:.0001pt;
	font-size:8.0pt;
	font-family:"Tahoma","sans-serif";}
span.gmail-im
	{mso-style-name:gmail-im;}
span.gmail-
	{mso-style-name:gmail-;}
span.hoenzb
	{mso-style-name:hoenzb;}
span.im
	{mso-style-name:im;}
span.EmailStyle21
	{mso-style-type:personal-reply;
	font-family:"Calibri","sans-serif";
	color:#1F497D;}
span.BalloonTextChar
	{mso-style-name:"Balloon Text Char";
	mso-style-priority:99;
	mso-style-link:"Balloon Text";
	font-family:"Tahoma","sans-serif";}
.MsoChpDefault
	{mso-style-type:export-only;}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div \
class=WordSection1><p class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hi \
David,<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>OK, I get \
it now. Thank you for clarifying.<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Rick<o:p></o:p></span></p><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><div \
style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p \
class=MsoNormal><b><span \
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span \
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> David Carlisle \
d.p.carlisle@gmail.com [mailto:xsl-list-service@lists.mulberrytech.com] \
<br><b>Sent:</b> Friday, January 06, 2017 4:41 PM<br><b>To:</b> \
xsl-list@lists.mulberrytech.com<br><b>Subject:</b> Re: [xsl] Recursive string replace \
in XSLT 2.0<o:p></o:p></span></p></div><p \
class=MsoNormal><o:p>&nbsp;</o:p></p><div><div><div><div><div><p class=MsoNormal \
style='margin-bottom:12.0pt'>not here<br><br>&nbsp; &nbsp; &lt;xsl:param \
name=&quot;regexes&quot; as=&quot;element(regex)*&quot;&gt;<o:p></o:p></p></div><p \
class=MsoNormal style='margin-bottom:12.0pt'>Michael meant here, in the template \
definition<br><br><span class=gmail-im>&nbsp; &nbsp; &nbsp; &nbsp; &lt;xsl:param \
name=&quot;regex&quot;/&gt;</span><br><br><o:p></o:p></p></div><p class=MsoNormal \
style='margin-bottom:12.0pt'><span class=gmail-im>You could declare your top level \
initialiser to also be a sequence of elements but then your initial call would have \
to be</span><br><br><br><span class=gmail-im>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &lt;xsl:with-param name=&quot;regex&quot; \
select=&quot;$regexes&quot;/&gt;</span><o:p></o:p></p></div><p class=MsoNormal \
style='margin-bottom:12.0pt'><span class=gmail->not</span><br><br><span \
class=gmail-im>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;xsl:with-param \
name=&quot;regex&quot; \
select=&quot;$regexes/regex&quot;/&gt;</span><o:p></o:p></p></div><p class=MsoNormal \
style='margin-bottom:12.0pt'><span \
class=gmail-im>David</span><o:p></o:p></p></div><div><p \
class=MsoNormal><o:p>&nbsp;</o:p></p><div><p class=MsoNormal>On 6 January 2017 at \
21:37, Rick Quatro <a href="mailto:rick@rickquatro.com">rick@rickquatro.com</a> \
&lt;<a href="mailto:xsl-list-service@lists.mulberrytech.com" \
target="_blank">xsl-list-service@lists.mulberrytech.com</a>&gt; \
wrote:<o:p></o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'>Thank you \
Michael. Oddly enough, when I add the as=&quot;element(regex)*&quot; \
the<br>finds/changes fail. Here is the entire stylesheet:<br><br>&lt;?xml \
version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;xsl:stylesheet \
xmlns:xsl=&quot;<a href="http://www.w3.org/1999/XSL/Transform" \
target="_blank">http://www.w3.org/1999/XSL/Transform</a>&quot;<br>&nbsp; &nbsp; \
xmlns:xs=&quot;<a href="http://www.w3.org/2001/XMLSchema" \
target="_blank">http://www.w3.org/2001/XMLSchema</a>&quot;<br>&nbsp; &nbsp; \
exclude-result-prefixes=&quot;xs&quot;<br>&nbsp; &nbsp; \
version=&quot;2.0&quot;&gt;<br><br>&nbsp; &nbsp; &lt;xsl:output \
indent=&quot;yes&quot;/&gt;<br><br>&nbsp; &nbsp; &lt;xsl:param \
name=&quot;regexes&quot; as=&quot;element(regex)*&quot;&gt;<br>&nbsp; &nbsp; &nbsp; \
&nbsp; &lt;regex&gt;&lt;find&gt;&amp;quot;(\S)&lt;/find&gt;&lt;change&gt;&amp;#8220;$1&lt;/change&gt;&lt;/regex&gt;<br>&nbsp; \
&nbsp; &nbsp; &nbsp; \
&lt;regex&gt;&lt;find&gt;(\S)&amp;quot;&lt;/find&gt;&lt;change&gt;$1&amp;#8221;&lt;/change&gt;&lt;/regex&gt;<br>&nbsp; \
&nbsp; &lt;/xsl:param&gt;<br><br>&nbsp; &nbsp; &lt;xsl:template \
match=&quot;/&quot;&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; \
&lt;xsl:apply-templates/&gt;<br>&nbsp; &nbsp; &lt;/xsl:template&gt;<br><br>&nbsp; \
&nbsp; &lt;xsl:template match=&quot;p&quot;&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; \
&lt;p&gt;&lt;xsl:apply-templates/&gt;&lt;/p&gt;<br>&nbsp; &nbsp; \
&lt;/xsl:template&gt;<br><br>&nbsp; &nbsp; &lt;xsl:template \
match=&quot;text()[string-length(normalize-space(.))&gt;0]&quot;&gt;<br>&nbsp; &nbsp; \
&nbsp; &nbsp; &lt;xsl:call-template name=&quot;applyRegexes&quot;&gt;<br>&nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;xsl:with-param name=&quot;nodeText&quot; \
select=&quot;.&quot;/&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&lt;xsl:with-param name=&quot;regex&quot; \
select=&quot;$regexes/regex&quot;/&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;&lt;/xsl:call-template&gt;<br>&nbsp; &nbsp; &lt;/xsl:template&gt;<br><br>&nbsp; \
&nbsp; &lt;xsl:template name=&quot;applyRegexes&quot;&gt;<br>&nbsp; &nbsp; &nbsp; \
&nbsp; &lt;xsl:param name=&quot;nodeText&quot;/&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; \
&lt;xsl:param name=&quot;regex&quot;/&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; \
&lt;xsl:choose&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;xsl:when \
test=&quot;$regex&quot;&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &lt;xsl:variable name=&quot;temp&quot;&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&lt;xsl:value-of<br>select=&quot;replace($nodeText,$regex[1]/find,$regex[1]/change)&quot;/&gt;<br>&nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/xsl:variable&gt;<br>&nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;xsl:call-template \
name=&quot;applyRegexes&quot;&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &lt;xsl:with-param name=&quot;nodeText&quot; \
select=&quot;$temp&quot;/&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &lt;xsl:with-param \
name=&quot;regex&quot;<br>select=&quot;$regex[position()&gt;1]&quot;/&gt;<br>&nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/xsl:call-template&gt;<br>&nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/xsl:when&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &lt;xsl:otherwise&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &lt;xsl:value-of select=&quot;$nodeText&quot;/&gt;<br>&nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/xsl:otherwise&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; \
&lt;/xsl:choose&gt;<br>&nbsp; &nbsp; \
&nbsp;&lt;/xsl:template&gt;<br><br>&lt;/xsl:stylesheet&gt;<br><br>Here is my \
input:<br><br>&lt;?xml version='1.0' encoding='UTF-8'?&gt;<br>&lt;root&gt;<br>&nbsp; \
&nbsp;&lt;test&gt;&lt;p \
class=&quot;Note&quot;&gt;&amp;quot;Abcdefghij.&amp;quot;&lt;/p&gt;&lt;/test&gt;<br>&nbsp; \
&nbsp;&lt;test&gt;&lt;p \
class=&quot;Note&quot;&gt;&amp;quot;defghij.&amp;quot;&lt;/p&gt;&lt;/test&gt;<br>&lt;/root&gt;<br><br>Without \
the as attribute, the finds/changes are applied, but with it, they<br>don't. \
Thanks.<br><span style='color:#888888'><br><span \
class=hoenzb>--Rick</span><br></span><br><br><span class=im>-----Original \
Message-----</span><br><span class=im>From: Michael Kay <a \
href="mailto:mike@saxonica.com">mike@saxonica.com</a></span><br><span \
class=im>[mailto:<a href="mailto:xsl-list-service@lists.mulberrytech.com">xsl-list-service@lists.mulberrytech.com</a>]</span><br><span \
class=im>Sent: Friday, January 06, 2017 4:25 PM</span><br><span class=im>To: <a \
href="mailto:xsl-list@lists.mulberrytech.com">xsl-list@lists.mulberrytech.com</a></span><br><span \
class=im>Subject: Re: [xsl] Recursive string replace in XSLT \
2.0</span><o:p></o:p></p><div><div><p class=MsoNormal style='margin-bottom:12.0pt'>If \
you don't like head-tail recursion for this kind of problem, there are a<br>couple of \
alternatives you might consider.<br><br>One is xsl:iterate, which looks something \
like this:<br><br>&lt;xsl:iterate \
select=&quot;$list-of-replacements&quot;&gt;<br>&nbsp; &lt;xsl:param \
name=&quot;str&quot; as=&quot;xs:string&quot;/&gt;<br>&nbsp; &lt;xsl:on-completion \
select=&quot;$str&quot;/&gt;<br>&nbsp; &lt;xsl:next-iteration&gt;<br>&nbsp; &nbsp; \
&lt;xsl:with-param name=&quot;str&quot; select=&quot;replace($str, find, \
change)&quot;/&gt;<br>&nbsp; \
&lt;/xsl:next-iteration&gt;<br>&lt;/xsl:iterate&gt;<br><br>The other is \
fold-left:<br><br>fold-left($list-of-replacements, $str, function($str, $regex) \
{<br>replace($str, $regex/find, $regex/change) } )<br><br>Both these require \
3.0.<br><br>Michael Kay<br>Saxonica<br><br><br>&gt; On 6 Jan 2017, at 19:41, David \
Carlisle <a href="mailto:d.p.carlisle@gmail.com">d.p.carlisle@gmail.com</a><br>&lt;<a \
href="mailto:xsl-list-service@lists.mulberrytech.com">xsl-list-service@lists.mulberrytech.com</a>&gt; \
wrote:<br>&gt;<br>&gt; I'd have written it as a function rather than template, but \
the main<br>&gt; issue is you want your parameter to be (always) a sequence of \
elements<br>&gt; not sometimes a sequence of elements and sometimes a document \
node<br>&gt; with a sequence of child elements.<br>&gt;<br>&gt; &lt;?xml \
version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;xsl:stylesheet<br>&gt; \
xmlns:xsl=&quot;<a href="http://www.w3.org/1999/XSL/Transform" \
target="_blank">http://www.w3.org/1999/XSL/Transform</a>&quot;<br>&gt;&nbsp; &nbsp; \
xmlns:xs=&quot;<a href="http://www.w3.org/2001/XMLSchema" \
target="_blank">http://www.w3.org/2001/XMLSchema</a>&quot;<br>&gt;&nbsp; &nbsp; \
exclude-result-prefixes=&quot;xs&quot;<br>&gt;&nbsp; &nbsp; \
version=&quot;2.0&quot;&gt;<br>&gt;<br>&gt;&nbsp; &nbsp; &lt;xsl:output \
indent=&quot;yes&quot;/&gt;<br>&gt;<br>&gt;&nbsp; &nbsp; &lt;xsl:param \
name=&quot;regexes&quot;&gt;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; \
&lt;regex&gt;&lt;find&gt;a&lt;/find&gt;&lt;change&gt;x&lt;/change&gt;&lt;/regex&gt;<br>&gt;&nbsp; \
&nbsp; &nbsp; &nbsp; \
&lt;regex&gt;&lt;find&gt;b&lt;/find&gt;&lt;change&gt;y&lt;/change&gt;&lt;/regex&gt;<br>&gt;&nbsp; \
&nbsp; &nbsp; &nbsp; \
&lt;regex&gt;&lt;find&gt;c&lt;/find&gt;&lt;change&gt;z&lt;/change&gt;&lt;/regex&gt;<br>&gt;&nbsp; \
&nbsp; &lt;/xsl:param&gt;<br>&gt;<br>&gt;&nbsp; &nbsp; &lt;xsl:template \
match=&quot;/&quot;&gt;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; \
&lt;xsl:apply-templates/&gt;<br>&gt;&nbsp; &nbsp; \
&lt;/xsl:template&gt;<br>&gt;<br>&gt;&nbsp; &nbsp; &lt;xsl:template \
match=&quot;p&quot;&gt;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; \
&lt;p&gt;&lt;xsl:apply-templates/&gt;&lt;/p&gt;<br>&gt;&nbsp; &nbsp; \
&lt;/xsl:template&gt;<br>&gt;<br>&gt;&nbsp; &nbsp; &lt;xsl:template \
match=&quot;text()&quot;&gt;&lt;!--[string-length(.)&gt;0]--&gt;<br>&gt;&nbsp; &nbsp; \
&nbsp; &nbsp; &lt;xsl:message \
select=&quot;.&quot;&gt;&lt;/xsl:message&gt;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; \
&lt;xsl:call-template name=&quot;applyRegexes&quot;&gt;<br>&gt;&nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &lt;xsl:with-param name=&quot;nodeText&quot; \
select=&quot;.&quot;/&gt;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&lt;xsl:with-param name=&quot;regex&quot; \
select=&quot;$regexes/regex&quot;/&gt;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;&lt;/xsl:call-template&gt;<br>&gt;&nbsp; &nbsp; \
&lt;/xsl:template&gt;<br>&gt;<br>&gt;&nbsp; &nbsp; &lt;xsl:template \
name=&quot;applyRegexes&quot;&gt;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &lt;xsl:param \
name=&quot;nodeText&quot;/&gt;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &lt;xsl:param \
name=&quot;regex&quot;/&gt;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &lt;xsl:message \
select=&quot;$regex&quot;&gt;&lt;/xsl:message&gt;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; \
&lt;xsl:message select=&quot;$regex[1]&quot;/&gt;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; \
&lt;xsl:message select=&quot;$regex[position()&gt;1]&quot;/&gt;<br>&gt;&nbsp; &nbsp; \
&nbsp; &nbsp; &lt;xsl:choose&gt;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&lt;xsl:when test=&quot;$regex&quot;&gt;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &lt;xsl:call-template \
name=&quot;applyRegexes&quot;&gt;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &lt;xsl:with-param name=&quot;nodeText&quot;<br>&gt; \
select=&quot;replace($nodeText,$regex[1]/find,$regex[1]/change)&quot;/&gt;<br>&gt;&nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;xsl:with-param \
name=&quot;regex&quot;<br>&gt; \
select=&quot;$regex[position()&gt;1]&quot;/&gt;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/xsl:call-template&gt;<br>&gt;&nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &lt;/xsl:when&gt;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &lt;xsl:otherwise&gt;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &lt;xsl:value-of select=&quot;$nodeText&quot;/&gt;<br>&gt;&nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &lt;/xsl:otherwise&gt;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; \
&lt;/xsl:choose&gt;<br>&gt;&nbsp; &nbsp; &nbsp;&lt;/xsl:template&gt;<br>&gt;<br>&gt; \
&lt;/xsl:stylesheet&gt;<br>&gt;<o:p></o:p></p></div></div></div><p \
class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><div \
style='border:none;border-top:solid black 1.0pt;padding:4.0pt 0in 0in \
0in;margin-top:5.0pt;margin-bottom:5.0pt'><p class=MsoNormal align=center \
style='text-align:center;background:#DDDDDD'><span \
style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#888888'><a \
href="http://www.mulberrytech.com/xsl/xsl-list">XSL-List info and archive</a> \
<o:p></o:p></span></p><p class=MsoNormal align=center \
style='text-align:center;background:#DDDDDD'><span \
style='font-size:10.0pt;font-family:"Arial","sans-serif";color:#888888'><a \
href="-list/612310">EasyUnsubscribe</a> (<a href="">by email</a>) \
<o:p></o:p></span></p></div></div></div></body></html> <div><!-- begin \
bl.html.trailer --> <div style="border-top:1px solid black; background-color: \
                #dddddd;
color: #888888; font-size: smaller; padding: 5px; text-align: center;
font-family: arial,verdana,arial,sans-serif; margin-top:1em; clear:
both; margin: auto">
<a href="http://www.mulberrytech.com/xsl/xsl-list">
XSL-List info and archive</a>
<div style="text-align:center;">
<a style="color: blue;"
  href="http://lists.mulberrytech.com/unsub/xsl-list/651070"
> EasyUnsubscribe</a>
(<a style="color: blue;"
href="mailto:xsl-list-unsub@lists.mulberrytech.com?subject=remove"
> by email</a>)
</div>
</div>
<!-- end bl.html.trailer --></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic