我想使用下面的XSLT获取输入字段值是示例:
示例:http://www.w3schools.com/xsl/tryxslt.asp?xmlfile=cdcatalog&xsltfile=tryxsl_if
并将xslt代码替换为以下内容,
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<xsl:template match="/">
<html>
<body>
<input type="text" name="testTextBox" value="testValue"/>
value here -->> <xsl:value-of select=".//x:TextBox[@Name = 'testTextBox']" />
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<xsl:if test="price>10">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
然后在下面你会看到输入字段 - 所以我的要求是这样的:
由于 苏希尔
答案 0 :(得分:1)
XSLT无法实现。它是您正在寻找的DOM,可能您应该使用像Javascript这样的浏览器脚本!
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Edited by XMLSpy® -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<head>
<script language="javascript" type="text/javascript">
function copytext()
{
document.getElementById("copytext").innerHTML=document.getElementById("inputText").value;
}
</script>
</head>
<body onload="copytext()">
<input id="inputText" type="text" name="testTextBox" value="testValue" onkeydown="copytext()"/>
value here -->> <span id="copytext"/>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<xsl:if test="price>10">
<tr>
<td>
<xsl:value-of select="title"/>
</td>
<td>
<xsl:value-of select="artist"/>
</td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>