2012-12-22 35 views
2

我需要從我的xml文件中複製所有信息(實際上我需要將新的信息添加到我的xml文件中)。錯誤的xsl:副本輸出

我用非標準模板:

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <xsl:template match="@*|node()"> 
     <xsl:copy> 
      <xsl:apply-templates select="@*|node()" /> 
     </xsl:copy> 
    </xsl:template> 
</xsl:stylesheet> 

,我寫測試XML文件:

<?xml version="1.0" encoding="UTF-8"?> 
    <!DOCTYPE products SYSTEM "products.dtd" > 
    <?xml-stylesheet type="text/xsl" href="../xsl/copy.xsl"?> 
    <products> 
     <category name="Audio And Video"> 
      <subcategory name="Audio"> 
       <good> 
        <producer>Dell</producer> 
        <model>QQ678</model> 
        <color>White</color> 
        <date_of_issue>12-12-2012</date_of_issue> 
        <not_in_stock>true</not_in_stock> 
       </good> 
      </subcategory> 
      <subcategory name="Video"> 
       <good> 
        <producer>Samsung</producer> 
        <model>VH500</model> 
        <color>Black</color> 
        <date_of_issue>12-12-2006</date_of_issue> 
        <price>200</price> 
       </good> 
       <good> 
        <producer>Toshiba</producer> 
        <model>GP436</model> 
        <color>White</color> 
        <date_of_issue>12-12-2004</date_of_issue> 
        <not_in_stock>true</not_in_stock> 
       </good> 
      </subcategory> 
     </category> 
     <category name="Computers"> 
      <subcategory name="Pocket"> 
       <good> 
        <producer>HP</producer> 
        <model>rx371</model> 
        <color>Black</color> 
        <date_of_issue>31-01-2006</date_of_issue> 
        <not_in_stock>true</not_in_stock> 
       </good> 
      </subcategory> 
     </category> 
</products> 

當我在瀏覽器中打開該XML文件,我想我會看到相同的XML文件,但它顯示我:enter image description here

所以我犯了錯誤。請幫我解決我的問題

回答

2

你的樣式表除了將輸入複製到輸出之外什麼都不做。就瀏覽器輸出而言,它可以正確地做到這一點。這裏沒有證據存在問題。嘗試輸出一些HTML而不是僅僅複製。

+0

但我想複製我所有的xml文件,然後在它的許多網站上添加一些信息 –

+0

我看到這個模板複製所有節點到結果文件的信息 –

+0

爲什麼輸出看起來像這樣。沒有標籤 –