xsl-list
[Top] [All Lists]

RE: First occurence of a repeating value

2002-11-07 08:03:34
You could use this:

 <xsl:output method="text" indent="yes"/>

 <xsl:template match="sub">
 <xsl:text>Title: </xsl:text>
 <xsl:value-of select="entry/item2"/> <!-- if you want the value instead
of the element use select="entry/*[.='val2']" -->
 <xsl:text>&#10;------&#10;</xsl:text>
 <xsl:apply-templates select="entry"/>
 </xsl:template>

 <xsl:template match="entry">
 <xsl:for-each select="*[not(self::item2)]"> <!-- if you want the value
instead of the element use select="*[not(.='val2')]" -->
  <xsl:value-of select="name()"/>
  <xsl:text>: </xsl:text>
  <xsl:value-of select="."/>
  <xsl:text>&#10;</xsl:text>
 </xsl:for-each>
 <xsl:text>&#10;</xsl:text>
 </xsl:template>


-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of 
Todd Bishop
Sent: Thursday, November 07, 2002 2:37 AM
To: XSL-List(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] First occurence of a repeating value


My XML is of the form:

<main>
  <sub>
     <entry>
        <item1>val1</item1>
        <item2>val2</item2>
        <item3>val3</item3>
     </entry>
     <entry>
        <item1>val4</item1>
        <item2>val2</item2>
        <item3>val5</item3>
     </entry>
     <entry>
        <item1>val6</item1>
        <item2>val2</item2>
        <item3>val7</item3>
     </entry>
   </sub>
</main>

I want the output to be as shown below, using "val2" once as the title,
and listing all the other values after that:

Title: val2
------
Item1: val1
Item3: val3

Item4: val4
Item5: val5

Item6: val6
Item7: val7

Any suggestions on how to accomplish this? Thanks in advance.

-- Todd





_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail


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



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



<Prev in Thread] Current Thread [Next in Thread>