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

Subject: [xsl] Using Lookup file in XSLT to cross reference old and pull in new numbers
From: "Deiter, Cathy E (US) cathy.deiter@xxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 6 Apr 2021 17:05:20 -0000
I am a Newbie and 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 Editor version 22.1.

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

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

This is my XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
<xsl:output method="xml" indent="yes"/>
<xsl:include href="copy.xsl"/>

<xsl:template match="xref">
<xsl:variable name="OLDFILE"><xsl:value-of select="./@wpid"/></xsl:variable>
<xsl:attribute name="wpid">
<xsl:when test="$OLDFILE = document($NEWFILE)//NewFile/@id">
<xsl:value-of select="document($NEWFILE)//NewFile[@id=$OLDFILE]"/>
<xsl:copy-of select="."></xsl:copy-of>
Currently it is only returning the original value, not the new file number.
Thank you for any help,
Cathy Deiter

Current Thread