我是XML的新手,我制作了一个XML文件和一个XSL文件。将XSL文件链接到XML文件后,浏览器中XML的输出变为空白。我找不到错误。
这是我的XML:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="cupcake.xsl"?>
<cupcakes>
<item>
<name>Luscious Vanilla</name>
<flavour>Vanilla</flavour>
<colour>Brown</colour>
<energy> 100 cj </energy>
</item>
<item>
<name>Chocolate Hazelnut</name>
<flavour>chocolaty</flavour>
<colour>coffe</colour>
<energy> 100 cj </energy>
<cost> $10 </cost>
</item>
<item>
<name>Risch Red Velvet</name>
<flavour>red velvet</flavour>
<colour>red</colour>
<energy> 100 cj </energy>
<cost> $10 </cost>
</item>
<item>
<name>Classic straberry</name>
<flavour>straberry</flavour>
<colour>pink</colour>
<energy> 100 cj </energy>
<cost> $10 </cost>
</item>
<item>
<name>Lemon Drop</name>
<flavour>lemon</flavour>
<colour>yellow</colour>
<energy> 100 cj </energy>
<cost> $10 </cost>
</item>
</cupcakes>
这是我的XSL:
<?xml version="1.0" encoding="UTF-8"?>
<html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE">
<xsl:for-each select="cupcakes/item">
<div style="background-color:teal;color:white;padding:4px">
<span style="font-weight:bold"><xsl:value-of select="name"/> - </span>
<xsl:value-of select="price"/>
</div>
<div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
<p>
<xsl:value-of select="cost"/>
</p>
</div>
</xsl:for-each>
</body>
</html>