kirangentlebreeze1987 Posted February 21, 2011 Posted February 21, 2011 hello experts i have a problem in testing the <xsl:if>please help in getting this issue solved i am a newbie to xsltthis is my xml file <?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="employeeformxsl.xsl"?> <employeeform> <employee> <field> <name>enter id</name> <id>1231</id> <type>text</type> </field> <field> <name>enter id</name> <id>1231</id> <type>checkbox</type> </field> </employee> </employeeform> this is my xslt <?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="html" indent="yes"/><xsl:template match="/"> <html> <body> <table> <xsl:for-each select="employeeform/employee"> <xsl:if test="employeeform/employee/field/type=text"> <tr> <td><input type="text"/></td> </tr> </xsl:if> <xsl:if test="employeeform/employee/field/type=checkbox"> <tr> <td><input type="checkbox"/></td> </tr> </xsl:if> </xsl:for-each> </table> </body> </html></xsl:template></xsl:stylesheet> now in the if tag if the test=text a textbox should be created and if it is checkbox checkbox should be created but when i ran xml file in my browser it isnt displaying anything help me in solving this
JohnBampton Posted February 22, 2011 Posted February 22, 2011 <xsl:for-each select="employeeform/employee"> <xsl:if test="field/type='text'"> <tr> <td><input type="text"/></td> </tr> </xsl:if> <xsl:if test="field/type='checkbox'"> <tr> <td><input type="checkbox"/></td> </tr> </xsl:if> </xsl:for-each>
Recommended Posts
Archived
This topic is now archived and is closed to further replies.