雖然這是沒有記錄,並隨時更改,你可以使用本地斯卡拉函數從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形式調用這個方法來解決我的問題? –