Subject: Re: [xsl] inserting data from second file using key and document From: "Jim Albright jim_albright@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Mon, 14 Jan 2019 12:36:15 -0000 |
With that change it now takes 7 seconds. Thanks for showing what I needed!!!!! Jim Albright <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0"> <xsl:variable name="LN" select="document('LN-PT-converted2.html')"/> <xsl:key name="insert" match="/html/body/p" use="@domain"/> <xsl:template match="Comments[parent::LEXSense[@LanguageCode='pt']]"> <xsl:variable name="item_number" select="preceding::LEXDomain[1]"/> <!-- <test1><xsl:value-of select="$item_number"/></test1> <test2><xsl:value-of select="$LN/html/body/p[@domain=$item_number]"/></test2> --> <!-- <xsl:element name="Comments"> <xsl:apply-templates select="$LN/html/body/p[@domain=$item_number]"/> </xsl:element> --> <!-- <xsl:apply-templates select="$LN/html/body/p[@domain=$item_number]"/> --> <xsl:element name="Comments"> <xsl:apply-templates select="key('insert', $item_number, $LN)"/> </xsl:element> </xsl:template> <xsl:template match="span[@class='LNgrk']"/> <xsl:template match="span[@class='LNdfe']"/> <xsl:template match="span[@class='LNgle']"/> <xsl:template match="span[@class='LNill']"/> <!-- identify transform --> <xsl:template match="@*|*|processing-instruction()|comment()"> <xsl:copy> <xsl:apply-templates select="*|@*|text()|processing-instruction()|comment()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] inserting data from secon, Martin Honnen martin | Thread | Re: [xsl] inserting data from secon, Jim Albright jim_alb |
Re: [xsl] inserting data from secon, Jim Albright jim_alb | Date | [xsl] bat file creation based on xs, Rahul Singh rahulsin |
Month |