1

我有一个包含 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,但没有用户输入数据,只有节点......)

真的需要解决这个问题...

再次感谢!

4

1 回答 1

0

要从数据库(关系或非关系)获取 XML 并应用转换,而不是编写自己的 servlet,我将使用XPL 管道,并通过页面流将此管道映射到 URL。现在您有了一个响应 HTTP 请求并返回 XML 的服务。要从 XForms 调用服务,您可以使用<xforms:submission replace="instance">. 您最终会在一个实例中使用 XML,并且可以使用以下内容显示它:<xforms:output value="saxon:serialize(instance(), 'xml')"/>.

在所有情况下(包括单独部署),管道和 XSLT 文件都必须位于“资源”中。通常,这意味着WEB-INF/resourcesOrbeon 的网络应用程序。但是您也可以通过设置 Orbeon资源管理器来使用磁盘上的其他目录来做更多花哨的事情。

于 2011-04-07T06:21:52.793 回答