xsl-list
[Top] [All Lists]

RE: Getting specific elements from a list

2005-05-27 01:12:22
Instead of

<xsl:value-of select=".//EnumValueDescription[last()]"/>

use

<xsl:value-of select="(.//EnumValueDescription)[last()]"/>

The way you wrote it, you select every EnumValueDescription that is the last
such child of its parent, and then xsl:value-of displays the first of these.

Michael Kay
http://www.saxonica.com/
 

-----Original Message-----
From: Simon, Jb [mailto:jb(_dot_)simon(_at_)lmco(_dot_)com] 
Sent: 26 May 2005 21:37
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Getting specific elements from a list


Hi, I have the following XML snippit :

<tblEnumeratedTypes>
      <EnumeratedType>ColorType</EnumeratedType>
      <tblEnumValues>
              <EnumeratedType>ColorType</EnumeratedType>
              <EnumValueDescription>Red</EnumValueDescription>
      </tblEnumValues>
      <tblEnumValues>
              <EnumeratedType>ColorType</EnumeratedType>
              <EnumValueDescription>White</EnumValueDescription>
      </tblEnumValues>
      <tblEnumValues>
              <EnumeratedType>ColorType</EnumeratedType>
              <EnumValueDescription>Blue</EnumValueDescription>
      </tblEnumValues>
</tblEnumeratedTypes>

What I need as output is 

TEST ( int, ColorType, Red, Blue )

The problem I'm having is getting the Red and Blue, basically, the 
First and last EnumeratedType element of EnumeratedTypes.

I tried various combinations, although it seems this should have
worked...

      <xsl:template match="tblEnumeratedTypes_WC" mode="range-macro">


test ( 
      int, 
      <xsl:value-of select="EnumeratedType"/>,
      <xsl:value-of select=".//EnumValueDescription[1]"/>,
      <xsl:value-of select=".//EnumValueDescription[last()]"/>
) ;

      </xsl:template>

When I execute that I get (line breaks are not a problem)

TEST ( 
      int, 
      ColorType,
      Red,
      Red
      ) ;

What is the problem is that I can never get the last Value to be Blue.

Oh, XSL Procesor : Microsoft (R) XSLT Processor Version 4.0
Also tried it using Mozilla, same result

Any Ideas ?

TIA
Joe Simon

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--