Does anyone know if there is a way to make XSL read in a node list and then sequentially go through it(outputting certain things for different nodes in the order they appear in the xml doc), instead of outputting each node that is the same together? Like if you had the following xml: <textfield> <textname>firstName</textname> </textfield> <combo> <cmboname>cmboNat</cmboname> </combo> <textfield> <textname>firstName</textname> </textfield> the xsl would output a textfield then a combo and then a textfield instead of two textfields and a combo or vice versa.
Frank Daly
Ranch Hand
Joined: Mar 31, 2000
Posts: 132
posted
0
Hi Brendan You should change your xml file to <control controlType="Text"> <textname>firstName</textname> </control> <control controlType="combo"> <cmboname>cmboNat</cmboname> </control> <control controlType="Text"> <textname>firstName</textname> </control> Your xsl file should then include <xsl:for-each select="control"> <xsl:choose> <xsl:when test="@controlType='Text'"> ...code to display text box.. </xsl:when> <xsl therwise> ...code to display combo box... </xsl therwise> </xsl:choose> </xsl:for-eahc>
frank
Mapraputa Is
Leverager of our synergies
Sheriff
Joined: Aug 26, 2000
Posts: 10065
posted
0
In XSLT there are two approaches to get data from XML document: �pull� and �push�. You pull data when you are using such elements as <xsl:for-each>, <xsl:value-of select>... If, instead, you want to get your data �how they are�, you can write a template for each element you want to see in the output and apply all this templates with <xsl:apply-templates/> element. XSLT processor walks through input tree and for each element applies matching template. Here is your XML document (I added root element and changed content of the last textname to �secondName� with illustrative purpose) <?xml version="1.0"?> <root> <textfield> <textname>firstName</textname> </textfield> <combo> <cmboname>cmboNat</cmboname> </combo> <textfield> <textname>secondName</textname> </textfield> </root> XSL: <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="textname"> <!-- ... some processing here, like --> <b><xsl:value-of select="."/></b> </xsl:template> <xsl:template match="cmboname"> <!-- ... some other processing here, like --> <i><xsl:value-of select="."/></i> </xsl:template> </xsl:stylesheet> the output is: firstNamecmboNatsecondName
[This message has been edited by Mapraputa Is (edited June 21, 2001).]