我是个初学者,遇个关于XML显示的难题想请教各位高手

我的XML代码如下:

 1<abc>
 2<dd>
 3<author>
 4<name><firstname>jane1</firstname><lastname>doe</lastname></name>
 5</author>
 6<publisher>
 7<department>Human Resources</department>
 8<phone>55-2300</phone>
 9<mobile>555-5423</mobile>
10</publisher>
11</dd>
12<dd>
13<author>
14<name><firstname>jane</firstname><lastname>doe</lastname></name>
15</author>
16<publisher>
17<department>Human Resources</department>
18<phone>55-2300</phone>
19<mobile>555-5423</mobile>
20</publisher>
21</dd>
22</abc>

开始时用了如下的XSL显示总是不行:

 1<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 2<xsl:output method="html"></xsl:output>
 3<xsl:template match="/">
 4<html>
 5<body>
 6<p>paaa</p>
 7<xsl:for-each select="abc/dd">
 8<xsl:apply-templates></xsl:apply-templates>
 9</xsl:for-each>
10</body>
11</html>
12</xsl:template>
13<xsl:template match="Publisher">
14<p>
15<xsl:value-of select="phone"></xsl:value-of>
16</p>
17</xsl:template>
18</xsl:stylesheet>

后来按另一本书的例子将名字空间改成:

 1<xsl:stylesheet xmlns:xsl="uri:xsl">   
 2就可以了,这是为何?我已经研究很久仍不得其解,请高手指教   
 3\---------------------------------------------------------------   
 4  
 5游览器版本低,   
 6升级你的游览器或将xsl改为:   
 7  
 8<?xml version="1.0" encoding="gb2312"?>
 9<xsl:stylesheet xmlns="http://www.w3.org/TR/REC-html40" xmlns:xsl="http://www.w3.org/TR/WD-xsl">
10<xsl:template match="/">
11<html>
12<body>
13<p>paaa</p>
14<xsl:for-each select="abc/dd">
15<xsl:apply-templates></xsl:apply-templates>
16</xsl:for-each>
17</body>
18</html>
19</xsl:template>
20<xsl:template match="Publisher">
21<p>
22<xsl:value-of select="phone"></xsl:value-of>
23</p>
24</xsl:template>
25</xsl:stylesheet>   
26  
27\---------------------------------------------------------------   
28  
29CSDN是用:<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"></xsl:stylesheet></xsl:stylesheet>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus