Re: Find/replace algorithm

"BR Chrisman [email protected]" <[email protected]> Thu, 25 Mar 2021 00:03:38 -0000
Newsgroups gmane.text.xml.xsl.general.mulberrytech
Message-ID <[email protected]>
--000000000000813ea505be51245b
Content-Type: text/plain; charset="UTF-8"

that 'lookup' document could be transformed into a transform that applies
the changes mentioned.. that's how I'd resolve the issue myself...

- brian

On Wed, Mar 24, 2021 at 1:28 PM [email protected] <
[email protected]> wrote:

> Hello All,
>
>
>
> I have a fairly large XML file similar to this:
>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <products>
>
>     <product>ACME Wid Assbly</product>
>
>     <product>Ford Eng Rebuild Kit</product>
>
> </products>
>
>
>
> I want to do an identity transform except that I want to do some find and
> replace on some of the words. For example
>
>
>
> Wid = Widget
>
> Assbly = Assembly
>
> Eng = Engine
>
>
>
> I am thinking of creating a lookup XML file to drive the find/replace
> actions:
>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <lookup>
>
>     <entry find="\bWid\b" replace="Widget"/>
>
>     <entry find="\bAssbly\b" replace="Assembly"/>
>
>     <entry find="\bEng\b" replace="Engine"/>
>
> </lookup>
>
>
>
> I am having trouble figuring out a good XSLT 2 or 3 algorithm for actually
> doing the replacements. Any suggestions or pointers would be appreciated.
> Thank you very much.
>
>
>
> Rick
>
>
>
> Rick Quatro
>
> Carmen Publishing Inc.
>
> 585-729-6746
>
> [email protected]
>
> http://www.frameexpert.com/store
>
>
>
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/965995> (by
> email <>)
>
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/3329386
or by email: [email protected]
--~--

--000000000000813ea505be51245b
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">that &#39;lookup&#39; document could be transformed into a=
 transform that applies the changes mentioned.. that&#39;s how I&#39;d reso=
lve the issue myself...=C2=A0<div><br></div><div>- brian</div></div><br><di=
v class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Wed, Mar 2=
4, 2021 at 1:28 PM <a href=3D"mailto:[email protected]">[email protected]=
om</a> &lt;<a href=3D"mailto:[email protected]">xsl-l=
[email protected]</a>&gt; wrote:<br></div><blockquote clas=
s=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid r=
gb(204,204,204);padding-left:1ex"><div lang=3D"EN-US" style=3D"overflow-wra=
p: break-word;"><div class=3D"gmail-m_-274270821317637516WordSection1"><p c=
lass=3D"MsoNormal">Hello All,<u></u><u></u></p><p class=3D"MsoNormal"><u></=
u>=C2=A0<u></u></p><p class=3D"MsoNormal">I have a fairly large XML file si=
milar to this:<u></u><u></u></p><p class=3D"MsoNormal"><u></u>=C2=A0<u></u>=
</p><p class=3D"MsoNormal">&lt;?xml version=3D&quot;1.0&quot; encoding=3D&q=
uot;UTF-8&quot;?&gt;<u></u><u></u></p><p class=3D"MsoNormal">&lt;products&g=
t;<u></u><u></u></p><p class=3D"MsoNormal">=C2=A0=C2=A0=C2=A0 &lt;product&g=
t;ACME Wid Assbly&lt;/product&gt;<u></u><u></u></p><p class=3D"MsoNormal">=
=C2=A0=C2=A0=C2=A0 &lt;product&gt;Ford Eng Rebuild Kit&lt;/product&gt;<u></=
u><u></u></p><p class=3D"MsoNormal">&lt;/products&gt;<u></u><u></u></p><p c=
lass=3D"MsoNormal"><u></u>=C2=A0<u></u></p><p class=3D"MsoNormal">I want to=
 do an identity transform except that I want to do some find and replace on=
 some of the words. For example<u></u><u></u></p><p class=3D"MsoNormal"><u>=
</u>=C2=A0<u></u></p><p class=3D"MsoNormal">Wid =3D Widget<u></u><u></u></p=
><p class=3D"MsoNormal">Assbly =3D Assembly<u></u><u></u></p><p class=3D"Ms=
oNormal">Eng =3D Engine<u></u><u></u></p><p class=3D"MsoNormal"><u></u>=C2=
=A0<u></u></p><p class=3D"MsoNormal">I am thinking of creating a lookup XML=
 file to drive the find/replace actions:<u></u><u></u></p><p class=3D"MsoNo=
rmal"><u></u>=C2=A0<u></u></p><p class=3D"MsoNormal">&lt;?xml version=3D&qu=
ot;1.0&quot; encoding=3D&quot;UTF-8&quot;?&gt;<u></u><u></u></p><p class=3D=
"MsoNormal">&lt;lookup&gt;<u></u><u></u></p><p class=3D"MsoNormal">=C2=A0=
=C2=A0=C2=A0 &lt;entry find=3D&quot;\bWid\b&quot; replace=3D&quot;Widget&qu=
ot;/&gt;<u></u><u></u></p><p class=3D"MsoNormal">=C2=A0=C2=A0=C2=A0 &lt;ent=
ry find=3D&quot;\bAssbly\b&quot; replace=3D&quot;Assembly&quot;/&gt;<u></u>=
<u></u></p><p class=3D"MsoNormal">=C2=A0=C2=A0=C2=A0 &lt;entry find=3D&quot=
;\bEng\b&quot; replace=3D&quot;Engine&quot;/&gt;<u></u><u></u></p><p class=
=3D"MsoNormal">&lt;/lookup&gt;<u></u><u></u></p><p class=3D"MsoNormal"><u><=
/u>=C2=A0<u></u></p><p class=3D"MsoNormal">I am having trouble figuring out=
 a good XSLT 2 or 3 algorithm for actually doing the replacements. Any sugg=
estions or pointers would be appreciated. Thank you very much.<u></u><u></u=
></p><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p><p class=3D"MsoNormal">=
Rick<u></u><u></u></p><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p><p cla=
ss=3D"MsoNormal">Rick Quatro<u></u><u></u></p><p class=3D"MsoNormal">Carmen=
 Publishing Inc.<u></u><u></u></p><p class=3D"MsoNormal">585-729-6746<u></u=
><u></u></p><p class=3D"MsoNormal"><a href=3D"mailto:[email protected]" =
target=3D"_blank">[email protected]</a><u></u><u></u></p><p class=3D"Mso=
Normal"><a href=3D"http://www.frameexpert.com/store" target=3D"_blank">http=
://www.frameexpert.com/store</a><u></u><u></u></p><p class=3D"MsoNormal"><u=
></u>=C2=A0<u></u></p><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p></div>=
</div>
<div>
<div style=3D"border-top:1px solid black;background-color:rgb(221,221,221);=
color:rgb(136,136,136);font-size:smaller;padding:5px;text-align:center;font=
-family:arial,verdana,arial,sans-serif;clear:both;margin:auto">
<a href=3D"http://www.mulberrytech.com/xsl/xsl-list" target=3D"_blank">
XSL-List info and archive</a>
<div style=3D"text-align:center">
<a style=3D"color:blue" href=3D"http://lists.mulberrytech.com/unsub/xsl-lis=
t/965995" target=3D"_blank">EasyUnsubscribe</a>
(<a style=3D"color:blue" href=3D"" target=3D"_blank">by email</a>)
</div>
</div>
</div>
</blockquote></div>
<div><!-- begin bl.html.trailer -->
<div style=3D"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=3D"http://www.mulberrytech.com/xsl/xsl-list">
XSL-List info and archive</a>
<div style=3D"text-align:center;">
<a style=3D"color: blue;"
  href=3D"http://lists.mulberrytech.com/unsub/xsl-list/3329386"
>EasyUnsubscribe</a>
(<a style=3D"color: blue;"
href=3D"mailto:[email protected]?subject=3Dremove"
>by email</a>)
</div>
</div>
<!-- end bl.html.trailer --></div>

--000000000000813ea505be51245b--