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

Summarizing sibling nodes

Subject: Summarizing sibling nodes
From: Wayne Rambo <WRambo@xxxxxxxxxx>
Date: Wed, 14 Mar 2001 11:42:10 -0800
wayne rambo
I'm rather new to XSL (Few months) and am running across a little problem,
hoping someone here can help me. Thanks for your time.

I have the following XML. . .

<Truck-list>
    <Truck>
      <VINModelName>
        T600
      </VINModelName>
      <VINModelYearName>
        1999
      </VINModelYearName>
    </Truck>
    <Truck>
      <VINModelName>
        T100
      </VINModelName>
      <VINModelYearName>
        1999
      </VINModelYearName>
    </Truck>
   <Truck>
      <VINModelName>
        T600
      </VINModelName>
      <VINModelYearName>
        2000
      </VINModelYearName>
    </Truck>
   <Truck>
      <VINModelName>
        T600
      </VINModelName>
      <VINModelYearName>
        1999
      </VINModelYearName>
    </Truck>
</Truck-list>

What I am trying to accomplish is a summary of the truck somewhat like this
(Except in HTML and prettier):

Build Year: 1999
Model: T100
Count: 1

Build Year: 1999
Model: T600
Count: 2

Build Year: 2000
Model: T100
Count: 1

Build Year: 2000
Model: T600
Count: 1

The XSL chunk I have currently is as follows (I think this is the closest
I've been, but I've tried lots of things here):

<xsl:template match="Truck-list">
   [HTML table build]
     <xsl:for-each
select="Truck[not(VINModelYearName/preceding::Truck/VINModelYearName)]
             |Truck[not(VINModelName/preceding::Truck/VINModelName)]">
	   <tr>
		  <td class="lensBody" bgcolor="#FFFFFF" nowrap="true">	  
	          <xsl:value-of select="VINModelYearName"/>&#160; 
		  </td>
		  <td class="lensBody" bgcolor="#FFFFFF" nowrap="true">	  
	          <xsl:value-of select="VINModelName"/>&#160;
		  </td>
              <td class="lensBody" bgcolor="#FFFFFF" nowrap="true">	  
	          <xsl:value-of select="count(VINModelName)"/>&#160;
		  </td>
         </tr>
     </xsl:for-each>  
   </table>
</xsl:template>

I know the count part is wrong. I think I would put whatever pattern I use
in my for-each in my count to return the same set of results to count. I'm
not sure though, because basically what I'm trying to do is create nodes on
the fly matching a particular pattern. The pattern can change, because I
want it for all the years, and for any Model (Which I could make a list of,
but it would be quite long).

Again, thank you for your time.

wtr.

 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.