| Newsgroups |
gmane.text.xml.xsl.general.mulberrytech |
| Message-ID |
<[email protected]> |
--Apple-Mail=_00441675-38DE-4E12-AD62-6359DDF31C5C
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=us-ascii
My instinct would be=20
(a) build a map containing the replacements
(b) for each text node, tokenize the content, then scan the tokens looking =
each one up in the map.
The big advantage of this approach is that the cost is constant regardless =
how many substitutions there are, whereas most other approaches have a cost=
that increases linearly with the number of substitutions.
Michael Kay
Saxonica
> On 24 Mar 2021, at 20:28, [email protected] <[email protected]=
berrytech.com> wrote:
>=20
> Hello All,
>=20=20
> I have a fairly large XML file similar to this:
>=20=20
> <?xml version=3D"1.0" encoding=3D"UTF-8"?>
> <products>
> <product>ACME Wid Assbly</product>
> <product>Ford Eng Rebuild Kit</product>
> </products>
>=20=20
> I want to do an identity transform except that I want to do some find and=
replace on some of the words. For example
>=20=20
> Wid =3D Widget
> Assbly =3D Assembly
> Eng =3D Engine
>=20=20
> I am thinking of creating a lookup XML file to drive the find/replace act=
ions:
>=20=20
> <?xml version=3D"1.0" encoding=3D"UTF-8"?>
> <lookup>
> <entry find=3D"\bWid\b" replace=3D"Widget"/>
> <entry find=3D"\bAssbly\b" replace=3D"Assembly"/>
> <entry find=3D"\bEng\b" replace=3D"Engine"/>
> </lookup>
>=20=20
> I am having trouble figuring out a good XSLT 2 or 3 algorithm for actuall=
y doing the replacements. Any suggestions or pointers would be appreciated.=
Thank you very much.
>=20=20
> Rick
>=20=20
> Rick Quatro
> Carmen Publishing Inc.
> 585-729-6746
> [email protected] <mailto:[email protected]>
> http://www.frameexpert.com/store <http://www.frameexpert.com/store>
>=20=20
>=20=20
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/293509> (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]
--~--
--Apple-Mail=_00441675-38DE-4E12-AD62-6359DDF31C5C
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
charset=us-ascii
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; charset=
=3Dus-ascii"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode=
: space; line-break: after-white-space;" class=3D"">My instinct would be&nb=
sp;<div class=3D""><br class=3D""></div><div class=3D"">(a) build a map con=
taining the replacements</div><div class=3D""><br class=3D""></div><div cla=
ss=3D"">(b) for each text node, tokenize the content, then scan the tokens =
looking each one up in the map.</div><div class=3D""><br class=3D""></div><=
div class=3D"">The big advantage of this approach is that the cost is const=
ant regardless how many substitutions there are, whereas most other approac=
hes have a cost that increases linearly with the number of substitutions.</=
div><div class=3D""><br class=3D""></div><div class=3D"">Michael Kay</div><=
div class=3D"">Saxonica</div><div class=3D""><div><br class=3D""><blockquot=
e type=3D"cite" class=3D""><div class=3D"">On 24 Mar 2021, at 20:28, <a hre=
f=3D"mailto:[email protected]" class=3D"">[email protected]</a> <<a =
href=3D"mailto:[email protected]" class=3D"">xsl-list=
[email protected]</a>> wrote:</div><br class=3D"Apple-inte=
rchange-newline"><div class=3D""><meta charset=3D"UTF-8" class=3D""><div cl=
ass=3D"WordSection1" style=3D"page: WordSection1; caret-color: rgb(0, 0, 0)=
; font-family: Helvetica; font-size: 13px; font-style: normal; font-variant=
-caps: normal; font-weight: normal; letter-spacing: normal; text-align: sta=
rt; text-indent: 0px; text-transform: none; white-space: normal; word-spaci=
ng: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><div style=
=3D"margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=
=3D"">Hello All,<o:p class=3D""></o:p></div><div style=3D"margin: 0in; font=
-size: 11pt; font-family: Calibri, sans-serif;" class=3D""><o:p class=3D"">=
</o:p></div><div style=3D"margin: 0in; font-size: 11pt; font-family: =
Calibri, sans-serif;" class=3D"">I have a fairly large XML file similar to =
this:<o:p class=3D""></o:p></div><div style=3D"margin: 0in; font-size: 11pt=
; font-family: Calibri, sans-serif;" class=3D""><o:p class=3D""> </o:p=
></div><div style=3D"margin: 0in; font-size: 11pt; font-family: Calibri, sa=
ns-serif;" class=3D""><?xml version=3D"1.0" encoding=3D"UTF-8"?><o:p =
class=3D""></o:p></div><div style=3D"margin: 0in; font-size: 11pt; font-fam=
ily: Calibri, sans-serif;" class=3D""><products><o:p class=3D""></o:p=
></div><div style=3D"margin: 0in; font-size: 11pt; font-family: Calibri, sa=
ns-serif;" class=3D""> <product>ACME Wid Assbly<=
/product><o:p class=3D""></o:p></div><div style=3D"margin: 0in; font-siz=
e: 11pt; font-family: Calibri, sans-serif;" class=3D""> &=
lt;product>Ford Eng Rebuild Kit</product><o:p class=3D""></o:p></d=
iv><div style=3D"margin: 0in; font-size: 11pt; font-family: Calibri, sans-s=
erif;" class=3D""></products><o:p class=3D""></o:p></div><div style=
=3D"margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=
=3D""><o:p class=3D""> </o:p></div><div style=3D"margin: 0in; font-siz=
e: 11pt; font-family: Calibri, sans-serif;" class=3D"">I want to do an iden=
tity transform except that I want to do some find and replace on some of th=
e words. For example<o:p class=3D""></o:p></div><div style=3D"margin: 0in; =
font-size: 11pt; font-family: Calibri, sans-serif;" class=3D""><o:p class=
=3D""> </o:p></div><div style=3D"margin: 0in; font-size: 11pt; font-fa=
mily: Calibri, sans-serif;" class=3D"">Wid =3D Widget<o:p class=3D""></o:p>=
</div><div style=3D"margin: 0in; font-size: 11pt; font-family: Calibri, san=
s-serif;" class=3D"">Assbly =3D Assembly<o:p class=3D""></o:p></div><div st=
yle=3D"margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" cla=
ss=3D"">Eng =3D Engine<o:p class=3D""></o:p></div><div style=3D"margin: 0in=
; font-size: 11pt; font-family: Calibri, sans-serif;" class=3D""><o:p class=
=3D""> </o:p></div><div style=3D"margin: 0in; font-size: 11pt; font-fa=
mily: Calibri, sans-serif;" class=3D"">I am thinking of creating a lookup X=
ML file to drive the find/replace actions:<o:p class=3D""></o:p></div><div =
style=3D"margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" c=
lass=3D""><o:p class=3D""> </o:p></div><div style=3D"margin: 0in; font=
-size: 11pt; font-family: Calibri, sans-serif;" class=3D""><?xml version=
=3D"1.0" encoding=3D"UTF-8"?><o:p class=3D""></o:p></div><div style=3D"m=
argin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=3D"">=
<lookup><o:p class=3D""></o:p></div><div style=3D"margin: 0in; font-s=
ize: 11pt; font-family: Calibri, sans-serif;" class=3D""> =
<entry find=3D"\bWid\b" replace=3D"Widget"/><o:p class=3D""></o:p></=
div><div style=3D"margin: 0in; font-size: 11pt; font-family: Calibri, sans-=
serif;" class=3D""> <entry find=3D"\bAssbly\b" replace=
=3D"Assembly"/><o:p class=3D""></o:p></div><div style=3D"margin: 0in; fo=
nt-size: 11pt; font-family: Calibri, sans-serif;" class=3D""> &n=
bsp; <entry find=3D"\bEng\b" replace=3D"Engine"/><o:p class=3D""></o:=
p></div><div style=3D"margin: 0in; font-size: 11pt; font-family: Calibri, s=
ans-serif;" class=3D""></lookup><o:p class=3D""></o:p></div><div styl=
e=3D"margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=
=3D""><o:p class=3D""> </o:p></div><div style=3D"margin: 0in; font-siz=
e: 11pt; font-family: Calibri, sans-serif;" class=3D"">I am having trouble =
figuring out a good XSLT 2 or 3 algorithm for actually doing the replacemen=
ts. Any suggestions or pointers would be appreciated. Thank you very much.<=
o:p class=3D""></o:p></div><div style=3D"margin: 0in; font-size: 11pt; font=
-family: Calibri, sans-serif;" class=3D""><o:p class=3D""> </o:p></div=
><div style=3D"margin: 0in; font-size: 11pt; font-family: Calibri, sans-ser=
if;" class=3D"">Rick<o:p class=3D""></o:p></div><div style=3D"margin: 0in; =
font-size: 11pt; font-family: Calibri, sans-serif;" class=3D""><o:p class=
=3D""> </o:p></div><div style=3D"margin: 0in; font-size: 11pt; font-fa=
mily: Calibri, sans-serif;" class=3D"">Rick Quatro<o:p class=3D""></o:p></d=
iv><div style=3D"margin: 0in; font-size: 11pt; font-family: Calibri, sans-s=
erif;" class=3D"">Carmen Publishing Inc.<o:p class=3D""></o:p></div><div st=
yle=3D"margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" cla=
ss=3D"">585-729-6746<o:p class=3D""></o:p></div><div style=3D"margin: 0in; =
font-size: 11pt; font-family: Calibri, sans-serif;" class=3D""><a href=3D"m=
ailto:[email protected]" class=3D"">[email protected]</a><o:p class=
=3D""></o:p></div><div style=3D"margin: 0in; font-size: 11pt; font-family: =
Calibri, sans-serif;" class=3D""><a href=3D"http://www.frameexpert.com/stor=
e" class=3D"">http://www.frameexpert.com/store</a><o:p class=3D""></o:p></d=
iv><div style=3D"margin: 0in; font-size: 11pt; font-family: Calibri, sans-s=
erif;" class=3D""><o:p class=3D""> </o:p></div><div style=3D"margin: 0=
in; font-size: 11pt; font-family: Calibri, sans-serif;" class=3D""><o:p cla=
ss=3D""> </o:p></div></div><div style=3D"caret-color: rgb(0, 0, 0); fo=
nt-family: Helvetica; font-size: 13px; font-style: normal; font-variant-cap=
s: normal; font-weight: normal; letter-spacing: normal; text-align: start; =
text-indent: 0px; text-transform: none; white-space: normal; word-spacing: =
0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=3D""><di=
v style=3D"border-top-width: 1px; border-top-style: solid; border-top-color=
: black; background-color: rgb(221, 221, 221); color: rgb(136, 136, 136); f=
ont-size: smaller; padding: 5px; text-align: center; font-family: arial, ve=
rdana, arial, sans-serif; clear: both; margin: auto;" class=3D""><a href=3D=
"http://www.mulberrytech.com/xsl/xsl-list" class=3D"">XSL-List info and arc=
hive</a><div style=3D"text-align: center;" class=3D""><a href=3D"http://lis=
ts.mulberrytech.com/unsub/xsl-list/293509" style=3D"color: blue;" class=3D"=
">EasyUnsubscribe</a><span class=3D"Apple-converted-space"> </span>(<a=
href=3D"" style=3D"color: blue;" class=3D"">by email</a>)</div></div></div=
></div></blockquote></div><br class=3D""></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>
--Apple-Mail=_00441675-38DE-4E12-AD62-6359DDF31C5C--