此 XML 输入文件:
<r>
<email>bob@example.com</email>
<name>Bob</name>
<mobile>123-456-7890</mobile>
</r>
馈入此 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="/r">
<xsl:variable name="email" select="email"/>
<xsl:variable name="name" select="name"/>
<xsl:variable name="mobile" select="mobile"/>
<form action="welcome.jsp" method="post">
<table>
<tr><td>Email:</td><td><input type="text" name="email" value="{$email}"></input></td></tr>
<tr><td>Name:</td><td><input type="text" name="name" value="{$name}"/></td></tr>
<tr><td>Mobile:</td><td><input type="text" name="mobile" value="{$mobile}"/></td></tr>
<tr><td></td><td><input type="submit" value="Submit"/></td></tr>
</table>
</form>
</xsl:template>
</xsl:stylesheet>
生成已完成表单的 HTML:
<form action="welcome.jsp" method="post">
<table>
<tr>
<td>Email:</td>
<td><input type="text" name="email" value="bob@example.com"></td>
</tr>
<tr>
<td>Name:</td>
<td><input type="text" name="name" value="Bob"></td>
</tr>
<tr>
<td>Mobile:</td>
<td><input type="text" name="mobile" value="123-456-7890"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Submit"></td>
</tr>
</table>
</form>
看起来像这样: