Find/replace algorithm

"[email protected]" <[email protected]> Wed, 24 Mar 2021 20:28:39 -0000
Newsgroups gmane.text.xml.xsl.general.mulberrytech
Message-ID <[email protected]>
This is a multipart message in MIME format.

------=_NextPart_000_0484_01D720CA.ACEBB4D0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit

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] <mailto:[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/3329386
or by email: [email protected]
--~--

------=_NextPart_000_0484_01D720CA.ACEBB4D0
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40"><head><meta http-equiv=3DContent-Type content=
=3D"text/html; charset=3Dus-ascii"><meta name=3DGenerator content=3D"Micros=
oft Word 15 (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;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Calibri",sans-serif;
	color:windowtext;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-family:"Calibri",sans-serif;}
@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=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]--></head><body lang=3DEN-US link=3D"#0563C1=
" vlink=3D"#954F72" style=3D'word-wrap:break-word'><div class=3DWordSection=
1><p class=3DMsoNormal>Hello All,<o:p></o:p></p><p class=3DMsoNormal><o:p>&=
nbsp;</o:p></p><p class=3DMsoNormal>I have a fairly large XML file similar =
to this:<o:p></o:p></p><p class=3DMsoNormal><o:p>&nbsp;</o:p></p><p class=
=3DMsoNormal>&lt;?xml version=3D&quot;1.0&quot; encoding=3D&quot;UTF-8&quot=
;?&gt;<o:p></o:p></p><p class=3DMsoNormal>&lt;products&gt;<o:p></o:p></p><p=
 class=3DMsoNormal>&nbsp;&nbsp;&nbsp; &lt;product&gt;ACME Wid Assbly&lt;/pr=
oduct&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp; &lt;product=
&gt;Ford Eng Rebuild Kit&lt;/product&gt;<o:p></o:p></p><p class=3DMsoNormal=
>&lt;/products&gt;<o:p></o:p></p><p class=3DMsoNormal><o:p>&nbsp;</o:p></p>=
<p class=3DMsoNormal>I want to do an identity transform except that I want =
to do some find and replace on some of the words. For example<o:p></o:p></p=
><p class=3DMsoNormal><o:p>&nbsp;</o:p></p><p class=3DMsoNormal>Wid =3D Wid=
get<o:p></o:p></p><p class=3DMsoNormal>Assbly =3D Assembly<o:p></o:p></p><p=
 class=3DMsoNormal>Eng =3D Engine<o:p></o:p></p><p class=3DMsoNormal><o:p>&=
nbsp;</o:p></p><p class=3DMsoNormal>I am thinking of creating a lookup XML =
file to drive the find/replace actions:<o:p></o:p></p><p class=3DMsoNormal>=
<o:p>&nbsp;</o:p></p><p class=3DMsoNormal>&lt;?xml version=3D&quot;1.0&quot=
; encoding=3D&quot;UTF-8&quot;?&gt;<o:p></o:p></p><p class=3DMsoNormal>&lt;=
lookup&gt;<o:p></o:p></p><p class=3DMsoNormal>&nbsp;&nbsp;&nbsp; &lt;entry =
find=3D&quot;\bWid\b&quot; replace=3D&quot;Widget&quot;/&gt;<o:p></o:p></p>=
<p class=3DMsoNormal>&nbsp;&nbsp;&nbsp; &lt;entry find=3D&quot;\bAssbly\b&q=
uot; replace=3D&quot;Assembly&quot;/&gt;<o:p></o:p></p><p class=3DMsoNormal=
>&nbsp;&nbsp;&nbsp; &lt;entry find=3D&quot;\bEng\b&quot; replace=3D&quot;En=
gine&quot;/&gt;<o:p></o:p></p><p class=3DMsoNormal>&lt;/lookup&gt;<o:p></o:=
p></p><p class=3DMsoNormal><o:p>&nbsp;</o:p></p><p class=3DMsoNormal>I am h=
aving trouble figuring out a good XSLT 2 or 3 algorithm for actually doing =
the replacements. Any suggestions or pointers would be appreciated. Thank y=
ou very much.<o:p></o:p></p><p class=3DMsoNormal><o:p>&nbsp;</o:p></p><p cl=
ass=3DMsoNormal>Rick<o:p></o:p></p><p class=3DMsoNormal><o:p>&nbsp;</o:p></=
p><p class=3DMsoNormal>Rick Quatro<o:p></o:p></p><p class=3DMsoNormal>Carme=
n Publishing Inc.<o:p></o:p></p><p class=3DMsoNormal>585-729-6746<o:p></o:p=
></p><p class=3DMsoNormal><a href=3D"mailto:[email protected]">rick@fram=
eexpert.com</a><o:p></o:p></p><p class=3DMsoNormal><a href=3D"http://www.fr=
ameexpert.com/store">http://www.frameexpert.com/store</a><o:p></o:p></p><p =
class=3DMsoNormal><o:p>&nbsp;</o:p></p><p class=3DMsoNormal><o:p>&nbsp;</o:=
p></p></div></body></html>
<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>

------=_NextPart_000_0484_01D720CA.ACEBB4D0--