开发者

Getting and displaying data from database with xforms on submission

I have a database with an xml document in it, and I want to display a transformed xml on my xforms page, when the submission is sent (I'm using orbeon forms).

My solution is, that on the submission my servlet gets the xml from the database, writes it into a file, xslt transforms the xml tree (when and how should I do the transformation?), but I don't know, how to display this file on the xforms page. Maybe the replace="instance" attribute in can help, but i don't know how.

Thanks!

Now, after Alessandro's advice, Im trying to use this xpl thing, but it doesn't work. In the model:

<xforms:insert nodeset="instance('inst2')"
origin="xxforms:call-xpl('oxf:/resources/pipeline.xpl', 'data', 
instance('inst1'), 'data')"/>    

in 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>

My instance, that I want to transform is "complaint-instance", the transformed instance called "trf-instance", the pipeline.xpl file is in the same directory with my xforms page. My styesheet called customerToOperator.xsl. What's wrong in my code?

I just noticed, the note: "If you are using separate deployment, the service and XSLT transformation must be present in the Orbeon WAR file, instead of within your application." Ehm... Where should I put these files?

my app in details:

a) an xforms page, with 2 instances:

<instance id='inst1'>
<name>
   <lastname/>
   <firstname/>
</name>  
</instance>

<instance id='inst2'>
<fname>
   <fullname/>
</fname>
</instance>

I got 2 input fields, referenced o开发者_如何学Pythonn name/lastname and name/firstname. I have an xforms:insert node, described above, and an xforms:submission node:

<xforms:submission 
id="save-submission" 
ref="instance('inst2')"
action="/my-servlet"
method="post"
replace="none">

I added 2 files to orbeon/WEB-INF/resources, the pipeline.xpl, (described above) and transform.xsl:

<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>

And I have a servlet, which writes the posted instance on the console (now it writes inst2 on the console, but without the user input data, only the nodes...)

A really need to fix this...

Thanks again!


To get the XML from a database (relational or not) and apply a transformation, instead of writing my own servlet, I would use an XPL pipeline, and map this pipeline to a URL through the page flow. Now you have a service that answers to an HTTP request and returns XML. To call the service from XForms, you use an <xforms:submission replace="instance">. You end up with the XML in an instance, and you can display it with something like: <xforms:output value="saxon:serialize(instance(), 'xml')"/>.

In all cases (including separate deployment), the pipeline and XSLT file must be in the "resources". Usually, this means the WEB-INF/resources of the Orbeon's web app. But you can also do more fancy things by setting up the Orbeon resource manager to also use other directories on disk.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜