虽然这是没有记录,并随时更改,你可以使用本地斯卡拉函数从XPath的:
converter:jsonStringToXml(instance('json'))
下面是一个完整的例子:
<xh:html
xmlns:xh="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms">
<xh:head>
<xf:model>
<xf:instance id="json">
<json type="object">
<data>{ "name": "Mark", "age": 21 }</data>
</json>
</xf:instance>
</xf:model>
</xh:head>
<xh:body>
<xf:output
xmlns:converter="org.orbeon.oxf.json.Converter"
value="
xxf:serialize(
converter:jsonStringToXml(instance('json')/data),
'xml'
)"/>
</xh:body>
</xh:html>
在Orbeon窗体2016.3,我们plan to include XPath函数执行此操作。
因此,您收到本身包含JSON的JSON? – ebruchez
是的,确切的;另外,我注意到ConverterTest中有Converter.jsonStringToXml方法。不知道如何从orbeon形式调用这个方法来解决我的问题? –