[xsl] work-around for poor XML design needed

Subject: [xsl] work-around for poor XML design needed
From: "jdunning" <jdunning@xxxxxxxxx>
Date: Wed, 23 Oct 2002 18:56:56 +0200
Hi all,
I need a workaround for a poor XML design.  The XML structure is as follows:
<!-- countries which belong to no regional organization -->
<!-- a regional organization -->
      <!-- the name of the regional org. is a country code -->
<!-- countries following a region are members of that regional org. -->
<!-- another regional org. -->
      <!-- the other regional org.'s name -->
<!-- members of that regional org. -->

What I need is to display a list of regional organizations with members,
followed by all countries not in an organization as such:

AP: (GH, GM, KE, UG); EP: (AT, BE, CH, LI, CY); AA, AB, AC, AD

The problem is that the countries that make up a region are not elementally
contained and I'm unsure of a way to specify "the <country> elements between
this <region> and the next <region>"

This is the template I've been working with:

<xsl:for-each select="states/region/country">
    <xsl:value-of select="."/>:(
    <!-- PROBLEM: all following countries are siblings (regardless of
               which region they should belong to -->
                 <xsl:value-of select="."/>
                 <xsl:if test="not(position()=last)">
                    <xsl:text> </xsl:text>
     <xsl:if test="parent::region[1]/preceding-sibling::country">
                <xsl:value-of select="."/>
                <xsl:if test="not(position()=last)">
                    <xsl:text> </xsl:text>

Any help is always appreciated.  TIA, John

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread