Expression Logic Problem
Hello. I'm trying to solve an expression logic problem and I'm stumped. I'm trying to determine if the context node I'm matching in a template is the first element. If it is, I want to prepend some information. If it isn't first, I just want to display the data. However, it seems as though every element matches my expression that tries to determine if the element is first. If someone could help me understand my delimma, I'd greatly appreciate it. Here is a sample of my data and my template: My data: <document> <configure> <server> <resultfield id="100">Snow White</resultfield> <resultfield id="50">Mickey Mouse</resultfield> </server> </configure> <record> <field id="100">Snow White and the Seven Dwarfs</field> <field id="100">A story about some dwarves and their friend</field> <field id="50">Fantasia</field> <record> </document> My Template: <xsl:template match="field"> <xsl:variable name="id" select="@id"/> <xsl:choose> <!-- when the ID of the resultfield returned by the server matches the ID of a resultfield to display in the configuration data and it is the first one, display the resultfield value and precede it with the display name from the configuration data. If it isn't first, just display the resultfield value --> <xsl:when test="/document/configure/server/resultfield/@id=$id"> <xsl:if test="self::node()"> <!-- I've also tried position()=1 here without success --> <xsl:value-of select="/document/configure/server/resultfield[@id=$id]"/>: </xsl:if> <xsl:value-of disable-output-escaping="yes" select="."/> <br/> </xsl:when> <xsl:otherwise/> </xsl:choose> </xsl:template> The data I expect and want: Snow White: Snow White and the Seven Dwarfs A story about some dwarves and their friend Mickey Mouse: Fantasia The data I get: Snow White: Snow White and the Seven Dwarfs Snow White: A story about some dwarves and their friend Mickey Mouse: Fantasia Regards, Garrel Renick garrel@xxxxxxxx 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