Subject: Re: [xsl] Combining lists without duplication From: David Carlisle <davidc@xxxxxxxxx> Date: Fri, 28 Sep 2007 22:29:58 +0100 |
not sure I got all your ules 100% but something like <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output encoding="US-ASCII" indent="yes"/> <xsl:variable name="f2" select="doc('sub2.xml')"/> <xsl:key name="a" match="subdiv" use="@fips"/> <xsl:template match="subdiv"> <xsl:variable name="a" select="key('a',@fips,$f2)"/> <xsl:copy> <xsl:copy-of select="@*"/> <basename> <name> <xsl:value-of select="($a[@nt='N']/@short-name,basename/name1)[1]"/> </name> <xsl:apply-templates select="$a[@nt='N']/(@bgn-name,@bgn-name-nd)"/> </basename> <other-names> <xsl:for-each-group select="basename/*,$a[@nt='V']/(@bgn-name,@bgn-name-nd)[not(.=$a[@nt='N']/@*)]" group-by="."> <xsl:apply-templates select="."/> </xsl:for-each-group> </other-names> </xsl:copy> </xsl:template> <xsl:template match="subdiv[@nt='N']/@bgn-name"> <long-form><xsl:value-of select="."/></long-form> </xsl:template> <xsl:template match="subdiv[@nt='N']/@bgn-name-nd"> <long-form-nd><xsl:value-of select="."/></long-form-nd> </xsl:template> <xsl:template match="subdiv[@nt='V']/@*"> <bgn-variant><xsl:value-of select="."/></bgn-variant> </xsl:template> <xsl:template match="basename[1]/*"> <alt-name><xsl:value-of select="."/></alt-name> </xsl:template> <xsl:template match="basename[2]/*"> <iso-name><xsl:value-of select="."/></iso-name> </xsl:template> </xsl:stylesheet> where the main input (sub1.xml) is your first file and sub2.xml is your second $ saxon8 sub1.xml sub.xsl <?xml version="1.0" encoding="US-ASCII"?> <subdiv fips="AF13"> <basename> <name>Kàbol</name> <long-form>Velàyat-e Kàbol</long-form> <long-form-nd>Velayat-e Kabol</long-form-nd> </basename> <other-names> <alt-name>Kabul</alt-name> <alt-name>Kaboul</alt-name> <alt-name>Kàbul</alt-name> <alt-name>Kabol</alt-name> <iso-name>Kàbol</iso-name> <bgn-variant>Velàyat-e Kàbul</bgn-variant> <bgn-variant>Velayat-e Kabul</bgn-variant> <bgn-variant>Kabul Province</bgn-variant> </other-names> </subdiv> ________________________________________________________________________ The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Combining lists without dupli, Roger Sperberg | Thread | RE: [xsl] Combining lists without d, cknell |
RE: [xsl] Re: Where's a basic "boil, Scott Trenda | Date | RE: [xsl] Where's a basic "boiler-p, Scott Trenda |
Month |