2017-01-01 25 views
0

我已經創建了一個應用程序來創建一個xsl和xml文件,但是輸出結果並沒有顯示爲XML佈局(如預期的HTML表格)。輸出在Internet Explorer中沒有顯示爲XML表格

要在xml或xsl文件中進行什麼更改才能使輸出看起來像HTML表格一樣?

我檢查了各種瀏覽器,但都顯示下面的輸出(邊緣)或根本沒有輸出。

中的XML文件(newfile_output.xml)具有含量:

<?xml version="1.0" encoding="utf-8"?> 
<?xml-stylesheet type="text/xsl"  
    href="C:\Users\Michel\Documents\newfile_output.xsl"?> 
<patch_list xml:lang="en"> 
    <patch> 
    <type>Program</type> 
    <id>I-B000</id> 
    <name>Jazz Dry/Amb1 Kit SL1,2</name> 
    <favorite> </favorite> 
    <category>Drums</category> 
    <subcategory>Natural Drums</subcategory> 
    <setlistname></setlistname> 
    <setlistslotreferenceid></setlistslotreferenceid> 
    <setlistslotreferencename></setlistslotreferencename> 
    <description></description> 
    </patch> 
    .... 
    <patch> 
    <type>WaveSequence</type> 
    <id>U-F012</id> 
    <name>Looped Cello G Vibrato</name> 
    <favorite> </favorite> 
    <category></category> 
    <subcategory></subcategory> 
    <setlistname></setlistname> 
    <setlistslotreferenceid></setlistslotreferenceid> 
    <setlistslotreferencename></setlistslotreferencename> 
    <description></description> 
    </patch> 
</patch_list> 

XSL文件(newfile_output.xsl)具有以下內容:

<?xml version="1.0"?> 
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:template match="/"> 
    <html> 
    <body> 
    <h2>Patch List</h2> 
    <table border="1"> 
     <tr bgcolor="#80a0ff"> 
     <th>ListSubType</th> 
     <th>Id</th> 
     <th>Name</th> 
     <th>Fav</th> 
     <th>Category</th> 
     <th>Sub Category</th> 
     <th>Set List Slot Reference Id</th> 
     <th>Set List Slot Reference Name</th> 
     <th>Set List Name</th> 
     <th>Description</th> 
     </tr> 
     <xsl:for-each select="patch_list/patch"> 
     <tr> 
      <td><xsl:value-of select="type"/></td> 
      <td><xsl:value-of select="id"/></td> 
      <td><xsl:value-of select="name"/></td> 
      <td><xsl:value-of select="favorite"/></td> 
      <td><xsl:value-of select="category"/></td> 
      <td><xsl:value-of select="subcategory"/></td> 
      <td><xsl:value-of select="setlistslotreferenceid"/></td> 
      <td><xsl:value-of select="setlistslotreferencename"/></td> 
      <td><xsl:value-of select="setlistname"/></td> 
      <td><xsl:value-of select="description"/></td> 
     </tr> 
     </xsl:for-each> 
    </table> 
    </body> 
    </html> 
</xsl:template> 
</xsl:stylesheet> 

的輸出如下所示:

Program I-A000 KRONOS German Grand Keyboard A.Piano Program I-A001 German 
Dark Grand Keyboard A.Piano Program I-A002 R.Ferrante German Grand Keyboard 
A.Piano Program I-A003 German New Age Grand Keyboard A.Piano Program I-A004 
L.Mays German Grand Keyboard A.Piano Program I-A005 German Grand + VPM 
Keyboard A.Piano Program I-A006 KRONOS Japanese Grand Keyboard A.Piano 
Program I-A007 Japanese ... 
+2

'href =「C:\ Users \ Michel \ Documents \ newfile_output.xsl」'不是一個合適的URL。製作一個合適的網址。 – Tomalak

回答

1

我試過用我的IE瀏覽器它工作正常。 檢查文件權限和引用的XSL文件的目錄路徑

+0

我接受了這個答案,因爲我發現真正的問題是我沒有顯示的部分內部的非法HTML字符。我認爲這將是頁眉/頁腳或XSL文件的一部分。 –

1

添加

<xsl:output method="html" indent="yes" /> 

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

元素之後。它應該看起來像

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <xsl:output method="html" indent="yes" /> 
    <xsl:template match="/"> 
    ... 
相關問題