kirangentlebreeze1987 Posted February 23, 2011 Share Posted February 23, 2011 Hello experts i am having a problem matching the values in xml file below is my empformattr.xml <?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="test.xsl"?><employee><employeeForm name="employeeform"> <field name="enter the id" id="empId" type="text" nodeValue="empid"></field><field name="enter the name" id="empName" type="text" nodeValue="empname"></field><field name="enter the department" id="empLoc" type="text" nodeValue="empdep"></field><field name="enter the role" id="empRole" type="text" nodeValue="emprole"></field></employeeForm></employee> this is my emp1.xml <?xml version="1.0" encoding="ISO-8859-1"?><employee> <empid>1231</empid> <empname>kiran</empname> <empdept>ers</empdept> <emprole>sw</emprole></employee> this is my xsl <?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:variable name="emp" select="document('emp1.xml')"/><xsl:template match="/employee/employeeForm"> <html> <body> <table border="1"> <xsl:for-each select="field"> <xsl:variable name="match"> <xsl:value-of select="@nodeId"/> </xsl:variable> <xsl:call-template name="match"> <xsl:with-param name='nodeType' select="@type"/> <xsl:with-param name='employeeTag' select="@nodeValue"/> <xsl:with-param name='fieldName' select="@name"/> <xsl:with-param name='fieldId' select="@id"/> </xsl:call-template> <xsl:apply-templates select="match"/> </xsl:for-each> </table> </body> </html></xsl:template><xsl:template name="match"> <xsl:param name="nodeType"/> <xsl:param name="employeeTag"/> <xsl:param name="fieldName"/> <xsl:param name="fieldId"/> <xsl:param name="nodeValue"/> <xsl:if test="$nodeType='text'"> <tr> <td> <xsl:value-of select="$fieldName"/><input type="text" name="$fieldName" id="$fieldId" value="{$emp/employee/empid}"/> </td> </tr> </xsl:if> </xsl:template> </xsl:stylesheet> right now i am getting the values of empid in all the textboixesbuti should match the correct values if it is name i should get name value in the textbox if it is role i should get role in the textbox i can make use of xsl:if to map to particular value by using something like<xsl:if test="$employeeTag='empname'>..........operation.........</xsl:if><xsl:if test="$employeeTag='emprole'>.............operation.............</xsl:if>here i can use many xsl:if but i wanted to complete all the things in 1 xsl:ifany one help me pls??? Link to comment Share on other sites More sharing options...
JohnBampton Posted February 25, 2011 Share Posted February 25, 2011 look up <xsl:choose that's what you need Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.