Subject: Re: [xsl] Dynamic output dependant on existance of other nodes. From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Thu, 8 Nov 2001 15:39:35 +0000 |
Hi Ian, > If Airport_choices exists, and Airport exists, then the menu is > populated by the contents of Airport_choices and the formfield Name > attribute is set to "Airport". > > If Airport_choices exists, and Airport does not exist, simply > display a list populated by the contents of Airport Choices and the > formfield Name attribute is set to "Airport_choices". In a template matching the Item element, you can work out whether this Item is an Airport_choices Item with: @Name = 'Airport_choices' You can find the sibling Item elements with: ../Item and you can work out whether one of them has a Name attribute equal to 'Airport' with: ../Item/@Name = 'Airport' So in the template for Item elements: <xsl:choose> <xsl:when test="@Name = 'Airport_choices'"> <xsl:variable name="fieldname"> <xsl:choose> <xsl:when test="../Item/@Name = 'Airport'">Airport</xsl:when> <xsl:otherwise>Airport_choices</xsl:otherwise> </xsl:choose> </xsl:variable> <select name="{$fieldname}"> <xsl:for-each select="Val"> <option><xsl:value-of select="." /></option> </xsl:for-each> </select> </xsl:when> <xsl:otherwise>...</xsl:otherwise> </xsl:choose> > This needs to work for combinations of any <itemname>_choice and > <itemname> pair. You can test whether this Item has a name in the form <itemname>_choices with: substring-after(@Name, '_') = 'choices' You can find the itemname from the name of the current Item with: substring-before(@Name, '_choices') Inserting this into the above code, you get: <xsl:choose> <xsl:when test="substring-after(@Name, '_') = 'choices'"> <xsl:variable name="itemname" select="substring-before(@Name, '_choices')" /> <xsl:variable name="fieldname"> <xsl:choose> <xsl:when test="../Item/@Name = $itemname"> <xsl:value-of select="$itemname" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="@Name" /> </xsl:otherwise> </xsl:choose> </xsl:variable> <select name="{$fieldname}"> <xsl:for-each select="Val"> <option><xsl:value-of select="." /></option> </xsl:for-each> </select> </xsl:when> <xsl:otherwise>...</xsl:otherwise> </xsl:choose> I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Dynamic output dependant on e, Ian Blizard | Thread | [xsl] XSL/FOP: Implementing a count, Rachael Blank |
Re: [xsl] XSL/FOP:Implementing a co, Jeni Tennison | Date | RE: [xsl] Q on ISO TimeDate convert, Mark Nahabedian |
Month |