xsl-list
[Top] [All Lists]

Re: Identity Transform Grouping Question

2004-10-21 15:55:08
Hi Ethan,

  Unfortunately, that fixed the previous problem, but I've now noticed the 
opposite effect -- offices with the same name in different cities are being 
grouped together.

Yes, I assumed that all offices with a certain name would be located in the same city... (wrong assumption:)

  I think the problem is that the "offices" key needs to include the <city> 
node to form the proper grouping (office within city within country).  I tried changing the key 
as follows:
<xsl:key name="offices" match="office" 
use="concat(ancestor::country/@name,'-',cities/city,'-',names/name[(_at_)lang='en'])"/>
That's correct.

and changing the city and office templates as follows:
  city:
<xsl:apply-templates select="ancestor::offices/office[cities/city=current() and 
count(.|key('offices',concat(ancestor::country/@name,'-',cities/city=current(),
'-',names/name[(_at_)lang='en']))[1])=1]">
That's not: in the third argument for concat, you pass "cities/city=current()" which produces a boolean value true() or false(). (I think this will put a "1" or "0" in the key string like "England-1-Branch 4")

<xsl:sort select="names/name[(_at_)lang='en']"/>

  office:
<xsl:apply-templates select="key('offices',concat(ancestor::country/@name,'-',
cities/city=current(),'-',names/name[(_at_)lang='en']))" mode="location"/>
Idem: in both cases, you'll want to remove "=current()". That should give the correct grouping, and bring back the <address> and <phone> nodes as well.

Good luck,
Anton


  These changes seemed to fix my above problem, except that the result tree is missing all 
of the <address> and <phone> nodes.  I'm not sure how my changes affected this.