2014-02-13 24 views
0

我想將上面的XML傳遞給XSLT。我想在一張桌子上展示結果。我認爲我做的一切正確,但是當我測試什麼都沒有出現! 有人可以幫助看到我做錯了什麼嗎?無法將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> 
+0

您正在使用哪種XSLT引擎?你如何調用XSLT引擎?你如何將XML傳遞給引擎? –

+0

感謝您的回答!我現在在他的w3schools網站測試,在這裏:http://www.w3schools.com/xsl/tryxslt.asp?xmlfile=cdcatalog&xsltfile=cdcatalog_apply – andyB

回答

0

其中的 「說明」 標籤中沒有輸入正確的XML開始。並且在樣式表元素中沒有聲明xsl命名空間和版本:

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

謝謝...我不知道命名空間是必需的!有效! – andyB

+0

請不要編輯你的問題後,已被回答,特別是如果編輯廢話的答案。其他人將在未來閱讀此主題,如果所提供的XSLT中的錯誤得到糾正,則沒有任何意義。 –