kirangentlebreeze1987 Posted February 22, 2011 Share Posted February 22, 2011 hello experts i am a newbie to xslt and stuff i need to know how to use xsl:variable this is my file1.xml <?xml version="1.0" encoding="ISO-8859-1"?><employee> <employeeinf> <empid>1231</empid> </employeeinf> <employeeinf> <empid>1232</empid> </employeeinf></employee> this is my file2.xml <?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="empformattr.xsl"?><employee><employeeForm name="employeeform"><field name="enter the id" id="empId" type="text" nodeValue="empid"></field><field name="enter the id" id="empId" type="text" nodeValue="empid"></field></employeeForm></employee> 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:variable name="emp" select="document('emp1.xml')"/><xsl:template match="/"> <html> <body> <table border="1"> <xsl:for-each select="/employee/employeeForm/field"> <xsl:variable name="nodeid"select="/employee/employeeForm/field/@nodeValue"/> <xsl:if test="/employee/employeeForm/field/@type[. = 'text']"> <tr> <td><xsl:value-of select="/employee/employeeForm/field/@name"/></td><td><input type="text" name="id" id="{/employee/employeeForm/field/@id}" value="{$emp/employee/employeeinf/nodeid}"/></td> </tr> </xsl:if> </xsl:for-each> </table> </body> </html></xsl:template></xsl:stylesheet> there in the xsl variable i am taking out the value of nodeId in file2.xml and in the statement <td><xsl:value-of select="/employee/employeeForm/field/@name"/></td><td><input type="text" name="id" id="{/employee/employeeForm/field/@id}" value="{$emp/employee/employeeinf/nodeid}"/></td>i am using nodeid and itshould fetch the value of empid in file1.xml Link to comment Share on other sites More sharing options...
JohnBampton Posted February 22, 2011 Share Posted February 22, 2011 If you happen to look at the other thread I replied to you would have your answer.Thanks for not thanking me before!I am not sure I understand you, but I think you need something like this:$emp/employee/employeeinf[empid = $nodeid]/empidYou need to do a tutorial on xslt because you can't constantly get other people to do your work for you. Link to comment Share on other sites More sharing options...
kirangentlebreeze1987 Posted February 23, 2011 Author Share Posted February 23, 2011 If you happen to look at the other thread I replied to you would have your answer.Thanks for not thanking me before!I am not sure I understand you, but I think you need something like this:$emp/employee/employeeinf[empid = $nodeid]/empidYou need to do a tutorial on xslt because you can't constantly get other people to do your work for you.thank you friend Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.