我有一个复杂的 XML,我正在尝试编写一个 XSL 转换以将其转换为 HTML。有人可以帮我吗?
这是XML
<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="Mbooks.xsl"?>
<project>
<books>
<bookName>Eclpise</bookName>
<bookCount>3</bookCount>
<Data>
<NEW>
<bookNumber>book3687110</bookNumber>
<ISBN>927fd6ca660e5a9</ISBN>
<Isbninfo>
<IsbninfoDetails>
<IsbninfoName>new book</IsbninfoName>
<IsbninfoVersion>version 1</IsbninfoVersion>
</IsbninfoDetails>
<IsbninfoDetails>
<IsbninfoName> new book 1</IsbninfoName>
<IsbninfoVersion>version 2</IsbninfoVersion>
</IsbninfoDetails>
</Isbninfo>
</NEW>
<NEW>
<bookNumber>book3674796</bookNumber>
<ISBN>6fa276825144</ISBN>
<Isbninfo>
<IsbninfoDetails>
<IsbninfoName>new book 3</IsbninfoName>
<IsbninfoVersion>version 3</IsbninfoVersion>
</IsbninfoDetails>
<IsbninfoDetails>
<IsbninfoName>new book 4</IsbninfoName>
<IsbninfoVersion>version 4</IsbninfoVersion>
</IsbninfoDetails>
</Isbninfo>
</NEW>
</Data>
</books>
<books>
<bookName>ORACLE</bookName>
<bookCount>0</bookCount>
<Data>
</Data>
</books>
<books>
<bookName>MUSIC</bookName>
<bookCount>0</bookCount>
<Data>
</Data>
</books>
</project>
这是 XSLT。
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>BOOK_INFORMATION </h2>
<table style="display: inline-block; border: 1px solid; float: left; ">
<tr bgcolor="#FFA500">
<th>book Name</th>
<th>book_Count</th>
<th>book_Number</th>
<th>ISBN</th>
<th>Isbninfo_Name</th>
<th>Isbninfo_Version</th>
</tr>
<xsl:for-each select="project/books">
<tr>
<td>
<xsl:value-of select="bookName"/>
</td>
<td>
<xsl:value-of select="bookCount"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
我不确定如何获得其他信息:我希望将所有信息都放在一张桌子上。我试着<xsl:for-each>
在 for each 里面做,但它不起作用。