无法将XML传递给XSLT(没有结果显示)

时间:2014-02-13 16:34:52

标签: xml xslt xsd

我正在尝试将上面的XML传递给XSLT。我想在桌子上显示结果。我想我正在做的一切正确,但是当我测试什么都没有出现! 有人可以帮忙看看我做错了吗?

我的XML:

<?xml version="1.0"?>

<search>

  <searchWord>gta</searchWord>

  <resultsList>

    <resultsFromLeft>
      <link>link from left</link>
      <titulo>title from left</titulo>
      <descricao>description from left</description>
    </resultsFromLeft>

    <resultsFromRight>
      <link>link from right</link>
      <title>Title from right</title>
      <description>description from right</description>
    </resultsFromRight>

  </resultsList>

  <totalresults>
    10000
  </totalresults>

</search>

我的XSLT:

<xsl:stylesheet>

  <xsl:template match="/">
    <html>
      <body>
        <h2>Search Gta</h2>

        <table border="1">

          <th>Search Word</th>
          <th>Results from left link</th>
          <th>Results from left description</th>
          <th>Results from left title</th>
          <th>Results from right link</th>
          <th>Results from right description</th>
          <th>Results from right title</th>
          <th>Total Results</th>

          <tr>
            <xsl:apply-templates />
          </tr>

        </table>

      </body>
    </html>
  </xsl:template>

  <xsl:template match="resultsList">
    <td><xsl:apply-templates select="resultsFromLeft/link"/></td>
    <td><xsl:apply-templates select="resultsFromLeft/title"/></td>
    <td><xsl:apply-templates select="resultsFromLeft/description"/></td>
    <td><xsl:apply-templates select="resultsFromRight/link"/></td>
    <td><xsl:apply-templates select="resultsFromRight/title"/></td>
    <td><xsl:apply-templates select="resultsFromRight/description"/></td>
  </xsl:template>

</xsl:stylesheet>

1 个答案:

答案 0 :(得分:0)

其中一个“description”标记未在输入xml中正确启动。并且样式表元素中没有xsl名称空间和版本的声明:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">