JSON转换为XML使用XSLT转换为、JSON、XSLT、XML

由网友(你太耀眼我怕闪瞎狗眼i)分享简介:是否有可能JSON使用现有的XSLT模板转换为XML? 我不希望有XML转换的另一层 JSON-> XML的> XSLT-方式>最后的XML 原因是我写一个新的用户界面为传统系统替换它FlexUI。当前UI发送XML请求并获得XML响应。我强调的JSON对象,这样我可以利用最新的MVVM框架,如An...

是否有可能JSON使用现有的XSLT模板转换为XML? 我不希望有XML转换的另一层 JSON-> XML的> XSLT-方式>最后的XML 原因是我写一个新的用户界面为传统系统替换它FlexUI。当前UI发送XML请求并获得XML响应。我强调的JSON对象,这样我可以利用最新的MVVM框架,如AngularJS或Backbone.js的。

  

我使用XSLT 2.0

解决方案

在客户端上XSLT可以通过JavaScript库做到这一点:

json2xml.js + SAXON CE json2xml.js +装订

在服务器上的XSLT可以通过XSLT 2.0库做到这一点:

FXSL 2.0

或者,您可以通过读取JSON文件做客户端:

在DTD定义的外部实体在XSLT处理器初始化定义的外部参数

然后使用字符串方法分析它。

参考

XSLT常见问题解答:逗号分隔的数据

和XML之间转换JSON

xml转换xslt工具下载v1.01绿色免费版

互动XSLT在浏览器

撒克逊-CE Github上回购

extracting使用XSLT版本从JSON文件的信息1.0

装订Github上回购

JSON来的XML工具?

Passing在XSLT 访问参数

Is it possible to translate JSON to XML using existing XSLT templates? I do not want to have another layer of xml transformation JSON->XML->XSLT->Final XML. Reason being that I am writing a new UI for a legacy system replacing it FlexUI. Current UI sends xml requests and gets xml response. I am emphasizing on JSON objects so that I can take advantage latest MVVM frameworks like AngularJS or Backbone.js.

I am using XSLT 2.0

解决方案

XSLT on the client can do it via JavaScript libraries:

json2xml.js + SAXON CE json2xml.js + Stapling

XSLT on the server can do it via XSLT 2.0 libraries:

FXSL 2.0

Or you can do it on the client by reading the JSON file via:

an external entity defined in the DTD an external parameter defined in the XSLT processor initialization

then parsing it using string methods.

References

XSLT FAQ: Comma Separated Data

Converting Between XML and JSON

Interactive XSLT in the Browser

Saxon-CE Github Repo

extracting information from a JSON file using XSLT version 1.0

Stapling Github Repo

Json to XML tool?

Passing and accessing parameters in XSLT

阅读全文

相关推荐

最新文章