[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Summarizing sibling nodes
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"/>  </td> <td class="lensBody" bgcolor="#FFFFFF" nowrap="true"> <xsl:value-of select="VINModelName"/>  </td> <td class="lensBody" bgcolor="#FFFFFF" nowrap="true"> <xsl:value-of select="count(VINModelName)"/>  </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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|