unique attribute names for form elements
I'm performing an XSL transformation which creates an editable HTML form based on an input XML file, with each form input element corresponding to each element's attribute in the XML file. The idea is that the user can edit the XML element's attributes by using it's corresponding field in the form. I'm wondering how I would give each form input element a unique ID so I can process it with a JSP. The input XML file could have one element with one attribute, or it could have 100 elements with a dozen attributes, so I'm not sure how I would access all of that information on the JSP without already knowing the names of the form input elements, or even how many elements there are.
Here's part of the code in my XSL
<form method="post" action="edittest2.jsp">
<table>
<xsl:for-each select="testcases/testcase/definition/testSteps/testStep">
<tr>
<xsl:for-each select="@*">
<td align="right"><b><xsl:value-of select="name()"/></b></td>
<td>
<input type="text" >
<xsl:attribute name="id">
<xsl:value-of select="name()"/>
</xsl:attribute>
<xsl:attribute name="value">
<xsl:value-of select="."/>
</xsl:attribute>
</input>
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
And here is an example of one of my input XML elements
<testStep action="sleep" timeout="500"></testStep>
So, this produces a HTML file with a new row for each testStep and an input field for each attribute of that element. The problem is that there may be 100 <testStep> elements that have an action called "action", so how would I uniquely identify the form elements so I can process them?
The overall idea is to be able to edit the attributes and save the changes back to the original XML using JSP and javabeans.
Thanks for any help, and sorry if I'm not clear enough. This is my first project of this sort and I still have much to learn.
|