Re: [xsl] inserting data from second file using key and document

Subject: Re: [xsl] inserting data from second file using key and document
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 14 Jan 2019 12:01:55 -0000
On 14.01.2019 12:50, Jim Albright jim_albright@xxxxxxxxxxxx wrote:

That is what I am trying to do but something is wrong with my attempt. Any clues?

<xsl:variable name="LN" select="document('LN-PT-converted2.html')"/>
<xsl:key name="insert" match="$LN/html/body/p" use="@domain"/>
<xsl:template match="Comments[parent::LEXSense[@LanguageCode='pt']]">
<xsl:variable name="item_number" select="preceding::LEXDomain"/>
<xsl:element name="Comments">
<xsl:apply-templates select="key('insert', $item_number)"/>

The key function has (in XSLT 2 and later) an optional third argument to define/change the context document (or in general subtree) you want to search, as you work with two documents and in your template match nodes from one document but want to search a second you need e.g.


key('insert', $item_number, $LN)

On the other hand for the key declaration it suffices to define

<xsl:key name="insert" match="/html/body/p" use="@domain"/>

Current Thread