我有一个包含 xml 文档的数据库,我想在发送提交时在我的 xforms 页面上显示转换后的 xml(我正在使用 orbeon 表单)。
我的解决方案是,在提交时,我的 servlet 从数据库中获取 xml,将其写入文件,xslt 转换 xml 树(我应该何时以及如何进行转换?),但我不知道如何显示xforms 页面上的这个文件。也许 replace="instance" 中的属性可以提供帮助,但我不知道如何。
谢谢!
现在,在 Alessandro 的建议下,我尝试使用这个 xpl 东西,但它不起作用。在模型中:
<xforms:insert nodeset="instance('inst2')"
origin="xxforms:call-xpl('oxf:/resources/pipeline.xpl', 'data',
instance('inst1'), 'data')"/>
在 pipeline.xpl 中:
<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline"
xmlns:oxf="http://www.orbeon.com/oxf/processors">
<p:param type="input" name="data"/>
<p:param type="output" name="data"/>
<p:processor name="oxf:xslt">
<p:input name="data" href="#data"/>
<p:input name="config" href="transform.xsl"/>
<p:output name="data" ref="data"/>
</p:processor>
我要转换的实例是“complaint-instance”,转换后的实例称为“trf-instance”,pipeline.xpl 文件与我的 xforms 页面位于同一目录中。我的样式表名为 customerToOperator.xsl。我的代码有什么问题?
我刚刚注意到,注释:“如果您使用单独的部署,则服务和 XSLT 转换必须存在于 Orbeon WAR 文件中,而不是在您的应用程序中。” 嗯...我应该把这些文件放在哪里?
我的应用程序详细信息:
a) 一个 xforms 页面,有 2 个实例:
<instance id='inst1'>
<name>
<lastname/>
<firstname/>
</name>
</instance>
<instance id='inst2'>
<fname>
<fullname/>
</fname>
</instance>
我有 2 个输入字段,在姓名/姓氏和姓名/名字上引用。我有一个 xforms:insert 节点,如上所述,还有一个 xforms:submission 节点:
<xforms:submission
id="save-submission"
ref="instance('inst2')"
action="/my-servlet"
method="post"
replace="none">
我在 orbeon/WEB-INF/resources、pipeline.xpl(如上所述)和 transform.xsl 中添加了 2 个文件:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<fname>
<fullname>
<xsl:value-of select="name/firstname"/>
<xsl:value-of select="name/lastname"/>
</fullname>
</fname>
</xsl:template>
</xsl:stylesheet>
而且我有一个servlet,它在控制台上写入发布的实例(现在它在控制台上写入inst2,但没有用户输入数据,只有节点......)
真的需要解决这个问题...
再次感谢!