Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xsl loop? 1

Status
Not open for further replies.

birney29

Programmer
Oct 11, 2001
140
GB
im using xsl to dynamically populate a drop down list. the XML is basically a list of names with an ID number. I can populate the list properly if i know how many entrys there are in the XMl document but what i really need is to use a loop so it stops making the drop down list when the id = "x" to mark the end of the file. here is my code so far:
Code:
 <xsl:element name=&quot;Select&quot;>
					<xsl:attribute name=&quot;NAME&quot;>status</xsl:attribute>
					<xsl:attribute name=&quot;size&quot;>1</xsl:attribute>

								<xsl:element name=&quot;option&quot;>
									<xsl:attribute name=&quot;value&quot;><xsl:value-of select=&quot;ID&quot;/></xsl:attribute>
									<xsl:attribute name=&quot;selected&quot;/>
									<xsl:for-each select=&quot;details/person[id= 1]&quot;>
									<xsl:value-of select=&quot;FirstName&quot;/> <xsl:value-of select=&quot;LastName&quot;/>
									</xsl:for-each>
								</xsl:element>
								<xsl:element name=&quot;option&quot;>
									<xsl:attribute name=&quot;value&quot;><xsl:value-of select=&quot;ID&quot;/></xsl:attribute>
									<xsl:attribute name=&quot;selected&quot;/>
								<xsl:for-each select=&quot;details/person[id= 2]&quot;>
									<xsl:value-of select=&quot;FirstName&quot;/> <xsl:value-of select=&quot;LastName&quot;/>
								</xsl:for-each>
								</xsl:element>
								<xsl:element name=&quot;option&quot;>
									<xsl:attribute name=&quot;value&quot;><xsl:value-of select=&quot;ID&quot;/></xsl:attribute>
									<xsl:for-each select=&quot;details/person[id= 3]&quot;>
									<xsl:value-of select=&quot;FirstName&quot;/> <xsl:value-of select=&quot;LastName&quot;/>
									</xsl:for-each>
								</xsl:element>
				</xsl:element>
Kenneth Birney
User Interface Programmer
Scottish Police
 
oh dear, that didnt come out very well! sorry Kenneth Birney
User Interface Programmer
Scottish Police
 
it should be possible with a <xsl:for-each>. i'm a bit confused as to how you use the for-each tho. i think you need just one


<xsl:for-each select=&quot;details/person&quot;>
<xsl:element name=&quot;option&quot;>
<xsl:attribute name=&quot;value&quot; select=&quot;ID&quot;/>
<xsl:attribute name=&quot;selected&quot;/>
<xsl:value-of select=&quot;concat(FirstName, ' ', LastName)&quot;/>
</xsl:element>
</xsl:for-each>

----------------------------------------------------------
if the attribute for selected is not always there then you could add an <xsl:if>.
 
Mr tom, i knew you wouldnt lmet me down! i hop tek-tips are paying you! ( i know i should!!) thanks a lot

Kenneth Birney
User Interface Programmer
Scottish Police
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top