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

Grouping problem (?)

Subject: Grouping problem (?)
From: "Dunning, John" <JDunning@xxxxxxxxx>
Date: Mon, 15 Sep 2003 06:12:32 -0400
virginia postcode
Hi all,
I suspect this is a grouping problem; I'm trying to increase a number based
on element content, and without any extension functions.

[step 1]
Show the first person's name and address
[step 2]
For each person,
    if the address is the same as the first listed person's
          then display the name in the same table as the first person's
information, adding '1' to the first person's number
[step 3]
For each person
    If the address is different than the first listed person's
        then display the name in a new table with the number incremented by
1.

The problem is in step 3; I can't author a complicated enough match pattern
to return the number I'm looking for; I could compare one element (e.g.,
<street> of each person with the first person, but I want to loop through
all the <address> elements to compare them as well.


Example desired output:

               1   | First Person               |  (Name)
                   |                            | (address)
               ----------------------------------------------
               2   | People with same           |  (names)
                   | address as first person    |
               -----------------------------------------------
[Problem]      3   | Person with different      |  (name)
                   | address                    |  (address)
                ------------------------------------------------
[Problem]      4   | Person with different      |  (name)
                   | address                    |  (address)
                ------------------------------------------------

Sample Data:
<people>
 <person sequence="1">
  <addressbook lang="en">
   <last-name>FIRST</last-name>
   <first-name>Person</first-name>
   <address>
    <street>address</street>
    <city>city</city>
    <state>Virginia</state>
    <postcode>23232</postcode>
    <country>US</country>
   </address>
  </addressbook>
 </person>
 <person sequence="2">
  <addressbook lang="en">
   <last-name>DIFF1</last-name>
   <first-name>Difperson1</first-name>
   <address>
    <street>address2</street>
    <city>city2</city>
    <state>Virginia</state>
    <postcode>21111</postcode>
    <country>US</country>
   </address>
  </addressbook>
 </person>
 <person sequence="3">
  <addressbook lang="en">
   <last-name>SAMEADDRESS1</last-name>
   <first-name>Same1 </first-name>
   <address>
    <street>address</street>
    <city>city</city>
    <state>Virginia</state>
    <postcode>23232</postcode>
    <country>US</country>
   </address>
  </addressbook>
 </person>
 <person sequence="4">
  <addressbook lang="en">
   <last-name>SAMEADDRESS2</last-name>
   <first-name>Second</first-name>
   <address>
    <street>address</street>
    <city>city</city>
    <state>Virginia</state>
    <postcode>23232</postcode>
    <country>US</country>
   </address>
  </addressbook>
 </person>
 <person sequence="5">
  <addressbook lang="en">
   <last-name>DIFF2</last-name>
   <first-name>Persondiff2</first-name>
   <address>
    <street>address3</street>
    <city>city3</city>
    <state>Virginia</state>
    <postcode>21311</postcode>
    <country>US</country>
   </address>
  </addressbook>
 </person>
</people>


I'm using this template to test each person:
<xsl:template name="testSameAddress">
<xsl:variable name="difTest">
	<xsl:for-each select="//person[@sequence !=
'1']/addressbook[1]/address/*">
	<xsl:variable name="nodeName" select="name(.)"></xsl:variable>
		<xsl:choose>
			<xsl:when test="not(text() =
//person[1]/addressbook[1]/address/*[name(.)=$nodeName]/text())">1</xsl:when
>
			<xsl:otherwise>0</xsl:otherwise>
	</xsl:choose>
</xsl:for-each>
</xsl:variable>
<xsl:choose>
	<xsl:when test="contains($difTest,0)">
		<tr><td><b>2</b>-1</td>
			<td>additional people at same address</td>
			<td>
				<xsl:call-template
name="showSamepersonAddress"/>
			</td>
		</tr>
	</xsl:when>
	<xsl:otherwise/>
</xsl:choose>


Any response is greatly appreciated; if anyone would like to see the (7kb)
stylesheet I've been working on let me know and I'll send it along.

TIA,
John


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


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-2013 All Rights Reserved.