Subject: RE: [xsl] Merging Two Files and Removing Duplicate Nodes From: "Michael Kay" <mhkay@xxxxxxxxxxxx> Date: Fri, 6 Jul 2001 19:06:53 +0100 |
> I am trying to merge two files so that the output contains > only products > that have matching codes on both files. In addition, I don't want the > output to contain duplicate child elements under product > I've been able to get matching products using the folllowing > xsl and then > copy the children from each file. I just haven't figured how > to exclude > child nodes from the second file if they exist on the first file. > > <xsl:template match="/"> > <xsl:apply-templates > select="*//product[./code=document($second-file)//product/code]"/> > </xsl:template> Unless your processor is very clever, that's going to have O(m*n) performance. I'd strongly recommend using keys, even though you can no longer do the selection in one XPath statement: <xsl:key name="prod2" match="second-file-list/product" use="code"/> <xsl:template match="/"> <xsl:for-each select="first-file-list/product"> <xsl:variable name="code" select="code"/> <xsl:for-each select="document($second-file)"> <xsl:apply-templates select="key('prod2', $code)"> This will process all the products on the second file that also exist on the first file; products that are not present on both files will not be processed. Mike Kay Software AG XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Merging Two Files and Removin, Dendler James A | Thread | [xsl] result tree fragments and nod, Chris Nolte |
[xsl] result tree fragments and nod, Chris Nolte | Date | RE: [xsl] result tree fragments and, Michael Kay |
Month |