我有以下XSLT文件已經與ActiveMQ上的XML文件一起工作。問題是我們正在升級系統,並且我們沒有XML視圖了。相反,我們有一個以JSON形式返回隊列信息的URL。如何使用XSLT轉換JSON?
<?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閱讀,而不是保持。
我使用camel來路由到這個XSLT,但我不想創建一個Processor來將JSON轉換爲XML。相反,我想馬上使用JSON。
考慮通用語言(Python和Java的,PHP,C#,Perl等)的JSON解析成矢量/陣列/列出並重新創建原始XML,以便XSLT無縫或直接轉換爲HTML。 – Parfait