Using Lookup file in XSLT to cross reference old and pull in new numbers

"Deiter, Cathy E (US) [email protected]" <[email protected]> Tue, 6 Apr 2021 17:05:30 -0000
Newsgroups gmane.text.xml.xsl.general.mulberrytech
Message-ID <[email protected]>
--_000_decf5721a92946ce9ae49fc237be69ecbaesystemscom_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

I am a Newbie and am having difficulties with an XSLT doing a lookup. I nee=
d to lookup up an old file number based off of an attribute, look at the lo=
okup file and pull in the new number. I am using Oxygen Editor version 22.1.

My XML file looks like this. I need to find the highlighted file in my look=
up and replace with the new file number.
<proc>
<title>FOLLOW-ON MAINTENANCE</title>
<step1 id=3D"M20340-03.01.01">
<para> Install access cover. <xref wpid=3D"M20236" pretext=3D"(" posttext=
=3D")"/>
</para>
</step1>
<step1 id=3D"M20340-03.01.02">
<para> Fill cooling system to proper fluid level. <xref wpid=3D"M20333" pre=
text=3D"(" posttext=3D")"/>
</para>
</step1>

My Lookup file looks like this (only added a few rows)
<row><NewFile id=3D"M20236">M20016-9-2350-372</Newfile></row>
<row><NewFile id=3D"M20234">M20381-9-2350-372</Newfile></row>
<row><NewFile id=3D"M20232">M20017-9-2350-372</Newfile></row>

This is my XSLT:
<?xml version=3D"1.0" encoding=3D"UTF-8"?>
<xsl:stylesheet xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform"
xmlns:xs=3D"http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes=3D"xs"
version=3D"2.0">
<xsl:output method=3D"xml" indent=3D"yes"/>
<xsl:include href=3D"copy.xsl"/>

<xsl:template match=3D"xref">
<xsl:variable name=3D"OLDFILE"><xsl:value-of select=3D"./@wpid"/></xsl:vari=
able>
<xsl:variable name=3D"NEWFILE">file:///C:/BAE/FAASV/OldnumberFAASV/Newfile_=
lookup.xml</xsl:variable>
<xref>
<xsl:attribute name=3D"wpid">
<xsl:choose>
<xsl:when test=3D"$OLDFILE =3D document($NEWFILE)//NewFile/@id">
<xsl:value-of select=3D"document($NEWFILE)//NewFile[@id=3D$OLDFILE]"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select=3D"."></xsl:copy-of>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xref>
Currently it is only returning the original value, not the new file number.
Thank you for any help,
Cathy Deiter
--~----------------------------------------------------------------
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]
--~--

--_000_decf5721a92946ce9ae49fc237be69ecbaesystemscom_
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=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii">
<meta name=3D"Generator" content=3D"Microsoft 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;}
@font-face
	{font-family:"Trebuchet MS";
	panose-1:2 11 6 3 2 2 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:#0563C1;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:#954F72;
	text-decoration:underline;}
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=3D"EN-US" link=3D"#0563C1" vlink=3D"#954F72">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:&quot;Tr=
ebuchet MS&quot;,sans-serif;color:#333333;background:white">I am a Newbie a=
nd am having difficulties with an XSLT doing a lookup. I need to lookup up =
an old file number based off of an attribute,
 look at the lookup file and pull in the new number. I am using Oxygen Edit=
or version 22.1.</span><span style=3D"font-size:10.0pt;font-family:&quot;Tr=
ebuchet MS&quot;,sans-serif;color:#333333"><br>
<br>
<span style=3D"background:white">My XML file looks like this. I need to fin=
d the highlighted file in my lookup and replace with the new file number.</=
span><br>
<span style=3D"background:white">&lt;proc&gt;</span><br>
<span style=3D"background:white">&lt;title&gt;FOLLOW-ON MAINTENANCE&lt;/tit=
le&gt;</span><br>
<span style=3D"background:white">&lt;step1 id=3D&quot;M20340-03.01.01&quot;=
&gt;</span><br>
<span style=3D"background:white">&lt;para&gt; Install access cover. &lt;xre=
f wpid=3D&quot;<span style=3D"background:yellow;mso-highlight:yellow">M2023=
6</span>&quot; pretext=3D&quot;(&quot; posttext=3D&quot;)&quot;/&gt;</span>=
<br>
<span style=3D"background:white">&lt;/para&gt;</span><br>
<span style=3D"background:white">&lt;/step1&gt;</span><br>
<span style=3D"background:white">&lt;step1 id=3D&quot;M20340-03.01.02&quot;=
&gt;</span><br>
<span style=3D"background:white">&lt;para&gt; Fill cooling system to proper=
 fluid level. &lt;xref wpid=3D&quot;<span style=3D"background:yellow;mso-hi=
ghlight:yellow">M20333</span>&quot; pretext=3D&quot;(&quot; posttext=3D&quo=
t;)&quot;/&gt;</span><br>
<span style=3D"background:white">&lt;/para&gt;</span><br>
<span style=3D"background:white">&lt;/step1&gt;</span><br>
<br>
<span style=3D"background:white">My Lookup file looks like this (only added=
 a few rows)</span><br>
<span style=3D"background:white">&lt;row&gt;&lt;NewFile id=3D&quot;M20236&q=
uot;&gt;M20016-9-2350-372&lt;/Newfile&gt;&lt;/row&gt;</span><br>
<span style=3D"background:white">&lt;row&gt;&lt;NewFile id=3D&quot;M20234&q=
uot;&gt;M20381-9-2350-372&lt;/Newfile&gt;&lt;/row&gt;</span><br>
<span style=3D"background:white">&lt;row&gt;&lt;NewFile id=3D&quot;M20232&q=
uot;&gt;M20017-9-2350-372&lt;/Newfile&gt;&lt;/row&gt;</span><br>
<br>
<span style=3D"background:white">This is my XSLT:</span><br>
<span style=3D"background:white">&lt;?xml version=3D&quot;1.0&quot; encodin=
g=3D&quot;UTF-8&quot;?&gt;</span><br>
<span style=3D"background:white">&lt;xsl:stylesheet xmlns:xsl=3D&quot;</spa=
n></span><a href=3D"http://www.w3.org/1999/XSL/Transform"><span style=3D"fo=
nt-size:10.0pt;font-family:&quot;Trebuchet MS&quot;,sans-serif;color:#368AD=
2;border:none windowtext 1.0pt;padding:0in;background:white;text-decoration=
:none">http://www.w3.org/1999/XSL/Transform</span></a><span style=3D"font-s=
ize:10.0pt;font-family:&quot;Trebuchet MS&quot;,sans-serif;color:#333333;ba=
ckground:white">&quot;</span><span style=3D"font-size:10.0pt;font-family:&q=
uot;Trebuchet MS&quot;,sans-serif;color:#333333"><br>
<span style=3D"background:white">xmlns:xs=3D&quot;</span></span><a href=3D"=
http://www.w3.org/2001/XMLSchema"><span style=3D"font-size:10.0pt;font-fami=
ly:&quot;Trebuchet MS&quot;,sans-serif;color:#368AD2;border:none windowtext=
 1.0pt;padding:0in;background:white;text-decoration:none">http://www.w3.org=
/2001/XMLSchema</span></a><span style=3D"font-size:10.0pt;font-family:&quot=
;Trebuchet MS&quot;,sans-serif;color:#333333;background:white">&quot;</span=
><span style=3D"font-size:10.0pt;font-family:&quot;Trebuchet MS&quot;,sans-=
serif;color:#333333"><br>
<span style=3D"background:white">exclude-result-prefixes=3D&quot;xs&quot;</=
span><br>
<span style=3D"background:white">version=3D&quot;2.0&quot;&gt;</span><br>
<span style=3D"background:white">&lt;xsl:output method=3D&quot;xml&quot; in=
dent=3D&quot;yes&quot;/&gt;</span><br>
<span style=3D"background:white">&lt;xsl:include href=3D&quot;copy.xsl&quot=
;/&gt;</span><br>
<br>
<span style=3D"background:white">&lt;xsl:template match=3D&quot;xref&quot;&=
gt;</span><br>
<span style=3D"background:white">&lt;xsl:variable name=3D&quot;OLDFILE&quot=
;&gt;&lt;xsl:value-of select=3D&quot;./@wpid&quot;/&gt;&lt;/xsl:variable&gt=
;</span><br>
<span style=3D"background:white">&lt;xsl:variable name=3D&quot;NEWFILE&quot=
;&gt;file:///C:/BAE/FAASV/OldnumberFAASV/Newfile_lookup.xml&lt;/xsl:variabl=
e&gt;</span><br>
<span style=3D"background:white">&lt;xref&gt;</span><br>
<span style=3D"background:white">&lt;xsl:attribute name=3D&quot;wpid&quot;&=
gt;</span><br>
<span style=3D"background:white">&lt;xsl:choose&gt;</span><br>
<span style=3D"background:white">&lt;xsl:when test=3D&quot;$OLDFILE =3D doc=
ument($NEWFILE)//NewFile/@id&quot;&gt;</span><br>
<span style=3D"background:white">&lt;xsl:value-of select=3D&quot;document($=
NEWFILE)//NewFile[@id=3D$OLDFILE]&quot;/&gt;</span><br>
<span style=3D"background:white">&lt;/xsl:when&gt;</span><br>
<span style=3D"background:white">&lt;xsl:otherwise&gt;</span><br>
<span style=3D"background:white">&lt;xsl:copy-of select=3D&quot;.&quot;&gt;=
&lt;/xsl:copy-of&gt;</span><br>
<span style=3D"background:white">&lt;/xsl:otherwise&gt;</span><br>
<span style=3D"background:white">&lt;/xsl:choose&gt;</span><br>
<span style=3D"background:white">&lt;/xsl:attribute&gt;</span><br>
<span style=3D"background:white">&lt;/xref&gt;</span><br>
<span style=3D"background:white">Currently it is only returning the origina=
l value, not the new file number.<o:p></o:p></span></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:&quot;Tr=
ebuchet MS&quot;,sans-serif;color:#333333;background:white">Thank you for a=
ny help,
<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:10.0pt;font-family:&quot;Tr=
ebuchet MS&quot;,sans-serif;color:#333333;background:white">Cathy Deiter</s=
pan><o:p></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>

--_000_decf5721a92946ce9ae49fc237be69ecbaesystemscom_--