html - 如何组合多个xml并为组合的XML准备XSLT 以上是一个XML的XSLT
问题描述
如何组合多个 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
解决方案
更改<xsl:for-each select="catalog/cd">
为 eg <xsl:for-each select="catalog/cd | document('XML-2.xml')/catalog/cd">
,以同时处理第二个文档。
推荐阅读
- hyperledger - 非管理员参与者的超级账本作曲家中的访问控制问题
- regex - 正则表达式查找包含 2 个字符串之一但不包含特定文本的起始模式
- xml - xpath 无法处理源 xml 中的名称空间
- javascript - 连续更改每个其他 div 的背景颜色
- angular - 为什么我不能在 Observable 中分配布尔变量?
- java - java - 如何在java中的kafka中获取消费者组的消费者滞后
- amazon-web-services - 适用于 AWS 的 Register-SSMTaskWithMaintenanceWindow Cmdlet
- python - 单独的训练和部署
- ios - 用于 MAC 登录的 MFA(第二因素身份验证)
- java - 如何使用 java 8 流 api 迭代枚举值