Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 如何使用XSLT获取输入字段值?_Xml_Xslt - Fatal编程技术网

Xml 如何使用XSLT获取输入字段值?

Xml 如何使用XSLT获取输入字段值?,xml,xslt,Xml,Xslt,我想使用XSLT获取输入feild值,以下是示例: 例如: 并将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/

我想使用XSLT获取输入feild值,以下是示例:

例如:

并将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>

此处的值-->>
我的CD收藏
标题
艺术家
然后在下面您将看到输入字段-因此我的要求如下:

  • 用户在输入字段中写入的文本我想在输入字段前面使用XLT显示该值
谢谢
Sushil在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>

函数copytext()
{
document.getElementById(“copytext”).innerHTML=document.getElementById(“inputText”).value;
}
此处的值-->>
我的CD收藏
标题
艺术家

使用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>

函数copytext()
{
document.getElementById(“copytext”).innerHTML=document.getElementById(“inputText”).value;
}
此处的值-->>
我的CD收藏
标题
艺术家

对于初学者来说,这是一次很好的尝试,因此+1请包含源XML文档(不要只是重定向),并指定转换的确切结果。w3schools不是一个很好的XSLT学习网站——请看这里的原因:http:www.w3dougs.comDimitre是正确的@Sushil,我对代码做了小版本,它将文本从文本框复制到跨区域。。但我担心它在W3Ttry it窗口中不起作用。不过,对于初学者来说,这是一个很好的尝试,因此+1请包含源XML文档(不要只是重定向),并指定转换的确切结果。w3schools不是一个很好的XSLT学习网站——请看这里的原因:http:www.w3dougs.comDimitre是正确的@Sushil,我对代码做了小版本,它将文本从文本框复制到跨区域。。但我担心它在W3Schools try it window中不起作用。同时,我将在我的端尝试使用javascript的一些东西,并让您知道。@SushilRaghav,这在W3Schools上不起作用。。他们已经禁用了脚本!因此,请转到此链接:。。粘贴您的输入XML和XSLT,2)将输出复制到一个新的文本文件,将其另存为(somefilename)*.html或*.htm,3)在浏览器中打开它(即firefox、opera或chrome等),同时我将尝试使用javascript编写一些内容,并让您知道。@SushilRaghav,这在W3上不起作用。。他们已经禁用了脚本!因此,请转到此链接:。。粘贴您的输入XML和XSLT,2)将输出复制到新的文本文件,将其另存为(somefilename)*.html或*.htm,3)在浏览器中打开(例如firefox、opera或chrome等)