Render a Form from an XSLT file
- by Russ Clark
I've generated the following XSLT file, and have created a Form that will post to an ASP.Net MVC action called Home/ProcessRequest:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<html>
<body>
<xsl:value-of select="Employee/Name"/>
<br />
<xsl:value-of select="Employee/ID"/>
<form method="post" action="/Home/ProcessRequest?id=42">
<input id="Action" name="Action" type="radio" value="Approved"></input> Approved <br />
<input id="Action" name="Action" type="radio" value="Rejected"></input> Rejected <br />
<input type="submit" value="Submit"></input>
</form>
</body>
</html>
Here is my XML File:
<Employee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Name>Russ</Name>
<ID>42</ID>
</Employee>
This works fine the way it is, but I need to change the id parameter in my from from a hard coded integer, to use the ID element from my XML file. Does anyone know how to do this?