Re: Using Lookup file in XSLT to cross reference old and pull in new numbers
| Newsgroups | gmane.text.xml.xsl.general.mulberrytech |
|---|---|
| Organization | Liberty Development |
| Message-ID | <[email protected]> |
On 06.04.2021 19:05, Deiter, Cathy E (US) [email protected] wrote: > 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. > <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" > pretext=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> I would always use a key e.g. declare <xsl:key name=3D"file-ref" match=3D"row/NewFile" use=3D"@id"/> then simply use a template <xsl:template match=3D"xref/@wpid[key('file-ref', ., doc('lookup.xml'))= ]"> <xsl:attribute name=3D"{name()}" select=3D"key('file-ref', ., doc('lookup.xml')"/> </xsl:template> All normal copying would be handled by the identity transformation. Of course the path and the lookup document is bested stored in a global parameter or variable. --~---------------------------------------------------------------- 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] --~--