簡體   English   中英

鏈接 XSL 和 XML 文件

[英]Linking XSL and XML Files

我正在嘗試鏈接這兩個文件,以便可以顯示代碼中已經存在的屬性和元素(@name 和 callNo。)由於某種原因,即使我檢查了文件拼寫和所有文件,這些文件也沒有鏈接。 如果我嘗試運行 XSL 文件,頁面將不會顯示我嘗試檢索的屬性/元素。 順便說一句,據我所知沒有錯誤。

問題2.xml:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="Question2.xsl"?>
<!DOCTYPE patron [
<!ELEMENT patron (item*)>
<!ATTLIST patron name CDATA #REQUIRED>
<!ELEMENT item (title,authors,callNo,due)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT authors (#PCDATA)>
<!ELEMENT callNo (#PCDATA)>
<!ELEMENT due (#PCDATA)>
]>
<patron name="John Smith">
<item>
<title>Wireless network security</title>
<authors>T. Wrightson</authors>
<callNo>212.12/56</callNo>
<due>25-12-2016</due>
</item>
<item>
<title>Analysis</title>
<authors>T. Tao</authors>
<callNo>515/305</callNo>
<due>23-12-2016</due>
</item>
<item>
<title>The art of computer programming</title>
<authors>D.E. Knuth</authors>
<callNo>005.1/300</callNo>
<due>25-11-2016</due>
</item>
<item>
<title>Python for dummies</title>
<authors>S. Maruch and A. Ranum</authors>
<callNo>145.3/157</callNo>
<due>01-10-2016</due>
</item>
</patron>

問題2.xsl:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns="http://www.w3.org/1999/xhtml" version="1.0">
<xsl:output method="xml" indent="yes" encoding="UTF-8" />
<xsl:template match="/patron">
  <html>
     <head>
        <title>Question2</title>
     </head>
     <body>
        <h1>
           <xsl:text>Patron record:</xsl:text>
           <xsl:value-of select="@name" />
        </h1>
        <font size="6" color="green">
           <xsl:value-of select="callNo" />
        </font>
     </body>
  </html>
 </xsl:template>
</xsl:stylesheet>

檢查此代碼:-

<xsl:value-of select="callNo" />
              to
<xsl:value-of select="item/callNo" />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM