Re: [xsl] selecting specific elements from a second file

Subject: Re: [xsl] selecting specific elements from a second file
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 17 Dec 2016 15:27:09 -0000
On 17.12.2016 16:19, Mark Wilson mark@xxxxxxxxxxxx wrote:
I want to select elements from the second file to add to the first file
when their @pofis-number match (in this instance 2966 has a match, 2967
does not.

Well, which XSLT processor do you use, which XSLT version?


With XSLT 2.0 you could define a key

<xsl:key name="flaws" match="Flaws" use="@pofis-number"/>

and then write a template

<xsl:template match="Stamp">
<xsl:copy>
<xsl:apply-templates select="@*, node(), key('flaws', @pofis-number, doc('file2.xml'))/node()"/>
</xsl:copy>
</xsl:template>


together with identity transformation template (or XSLT 3.0 xsl:node on-no-match="shallow-copy").

Current Thread