【发布时间】:2021-10-31 18:27:27
【问题描述】:
如何组合多个 XML 并为组合的 XML 准备 XSLT? 我尝试将多个 XML 合并为一个,并尝试为该 XML 准备 XSLT 转换。以上是一个 XML 的 XSLT。需要为组合的 XML 准备 XSLT。
XML-1
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
</cd>
</catalog>
XML-2
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<cd>
<title>Empire Burlesque-1</title>
<artist>Bob Dylan-1</artist>
</cd>
</catalog>
XSLT
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th style="text-align:left">Details</th>
<th style="text-align:left">XML-1</th>
</tr>
<tr>
<xsl:for-each select="catalog/cd">
<td>Title</td>
<td><xsl:value-of select="title"/></td>
</xsl:for-each>
</tr>
<tr>
<xsl:for-each select="catalog/cd">
<td>Artist</td>
<td><xsl:value-of select="artist"/></td>
</xsl:for-each>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
The above is the XSLT for one XML. Need to prepare XSLT for the combined XML
[1]: https://i.stack.imgur.com/g8ce7.jpg
【问题讨论】:
-
向我们展示两个 XML 输入的小而有代表性的样本,XSLT 用于单个文件,以及您想要的两个样本的输出。还要说明您使用的 XSLT 版本和/或 XSLT 处理器。
-
@MartinHonnen XML-1
XML-2Steven 60 XSLT 我需要的是带边框的表格格式 Columns 2-Director and age Director Age Steven 60 Mathew 55Mathew 55 -
@MartinHonnen 我正在使用此链接进行 xslt 转换 w3schools.com/xml/…
-
@MartinHonnen
-
请编辑您的问题,以格式正确的方式显示问题中的任何代码示例。