xsl-list
[Top] [All Lists]

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

2019-01-14 06:02:00
On 14.01.2019 12:50, Jim Albright jim_albright(_at_)wycliffe(_dot_)org 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"/>
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>