在线等待:帮忙看看这段XSL代码怎么死都不能解析这段XML文件?日后攒分了一定再追加分数! (谢谢!!!)
XML文件如下:
<info title= "图片类别 ">
<CateGories>
<Cate>
<Name> 北京日报 </Name>
<Code/>
<ID> 266 </ID>
<MEMO/>
</Cate>
<Cate>
<Name> 工人日报 </Name>
<Code/>
<ID> 266 </ID>
<MEMO/>
</Cate>
<Cate>
<Name> 解放日报 </Name>
<Code/>
<ID> 266 </ID>
<MEMO/>
</Cate>
<Cate>
<Name> 光明日报 </Name>
<Code/>
<ID> 266 </ID>
<MEMO/>
</Cate>
<Cate>
<Name> 北京晚报 </Name>
<Code/>
<ID> 266 </ID>
<MEMO/>
</Cate>
<Cate>
<Name> 北京晨报 </Name>
<Code/>
<ID> 266 </ID>
<MEMO/>
</Cate>
</CateGories>
</info>
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= "/ ">
<div>
<xsl:value-of select= "info/@title " />
</div>
<xsl:apply-templates select= "info/CateGories " />
</xsl:template>
<xsl:template match= "info/CateGories ">
<xsl:for-each select= "Cate ">
<xsl:choose>
<xsl:when test= "position() mod 2=1 ">
<div id= "float ">
<a>
<xsl:attribute name= "href ">
<xsl:text> pt.jsp?catID= </xsl:text>
<xsl:value-of select= "ID " />
</xsl:attribute>
<xsl:value-of select= "Name " />
</a>
</div>
</xsl:when>
<xsl:when test= "position() mod 2=0 ">
<div>
<a>
<xsl:attribute name= "href ">
<xsl:text> pt.jsp?catID= </xsl:text>
<xsl:value-of select= "ID " />
</xsl:attribute>
<xsl:value-of select= "Name " />
</a>
<br />
<br />
</div>
</xsl:when>
</xsl:choose>