[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Combining lists without duplication

Subject: Re: Combining lists without duplication
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 28 Sep 2007 22:29:58 +0100
Re:  Combining lists without duplication
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&#129;&#224;bol</name>
      <long-form>Vel&#129;&#224;yat-e K&#129;&#224;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&#129;&#224;bul</alt-name>
      <alt-name>Kabol</alt-name>
      <iso-name>K&#129;&#224;bol</iso-name>
      <bgn-variant>Vel&#129;&#224;yat-e K&#129;&#224;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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.