【发布时间】:2016-03-15 16:59:12
【问题描述】:
我有以下 XSLT 文件,它已经在处理我们在 ActiveMQ 上的 XML 文件。问题是我们正在升级系统并且我们不再有 XML 视图。相反,我们有一个以 JSON 格式返回队列信息的 URL。
<?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>PROJECT Notification</h2>
<div style="width:600px;background-color:#e5eecc;border:1px solid #98bf21;margin:10px;">
<table border="1" style="border-style:dashed">
<tr bgcolor="#9acd32">
<th width="300px;">Queue Name</th>
<th>Queue Size</th>
</tr>
<xsl:apply-templates select="queues" />
</table>
</div>
</body>
</html>
</xsl:template>
<xsl:template match="queue">
<tr>
<td><xsl:value-of select="@name"/></td><td><xsl:value-of select="./stats/@size" /></td>
</tr>
</xsl:template>
</xsl:stylesheet>
我想知道是否可以继续使用同一个 XSLT 文件,只需修改标签以开始从 JSON URL 读取。
我正在使用骆驼路由到这个 XSLT,但我不想创建一个处理器来将 JSON 转换为 XML。相反,我想立即使用 JSON。
【问题讨论】:
-
考虑使用通用语言(Python、Java、PHP、C#、Perl 等)将 JSON 解析为向量/数组/列表并重新创建原始 XML,以便 XSLT 无缝或直接HTML。