1

以下の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>

次に、下に入力フィールドが表示されます-したがって、私の要件は次のようになります。

  • テキストユーザーが入力フィールドに書き込んだものは何でも、その入力フィールドの前にXLTを使用してその値を表示したいと思います。

ありがとうスシル

4

1 に答える 1

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>
于 2012-11-23T13:55:22.173 に答える