Best practice for conditional document section

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Best practice for conditional document section

orbeon-list.5.montgomery
Hi,

Here's a really simplified example of a process I'm attempting to emulate using Orbeon.

Let's say I have a document schema like this:

<grammar
  datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
  xmlns="http://relaxng.org/ns/structure/1.0">
  <start>
    <element name="myform">
      <element name="action">
        <text/>
      </element>
      <element name="first-name">
        <text/>
      </element>
      <optional>
        <element name="note">
          <text/>
        </element>
      </optional>
    </element>
  </start>
</grammar>

The /myform/note element is optional, obviously.

For my default instance document, I want to provide the briefest possible valid instance, which would be:

<myform>
   <action/>
   <first-name/>
</myform>

For my user interface, I have already figured out how to use xsl:if to conditionally make the xforms:input tag appear/dissapear based on the exitance of the 'note' element.

My remaining problem is this:  If my user wants to add a 'note' element to the document, what is the best way to accomplish this?

If I'm forced to guess at the solution, I would say this is the best approach:

1) add a UI element (link/button/whatever) that updates the value of the 'action' node to something like 'add_note'

2) in the page flow XML, use an xupdate template to append the 'note' node using 'xu:append'

I am assuming I might use 'xu:remove' to delete a no-longer-needed node?

The only parts of this scenario that bother me are:

1) XUpdate seems to be un-loved as an XML technology.  Many posts I have read online even described it as depricated.  Also, the XUpdate reference link in the Orbeon documentation seems to be dead.  If XUpdate is abandoned by the XML community, will Orbeon maintain backwards compatibility?

2) Doesn't Orbeon support some sort of session literals that the page-flow can receive without having to bastardize the instance document by adding an 'action' element?  This doesn't seem like an elegant solution.

Best Regards,

David Montgomery





--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Best practice for conditional document section

Alessandro  Vernet
Administrator
On 11/21/05, [hidden email]
> For my user interface, I have already figured out how to use xsl:if to conditionally make the xforms:input tag appear/dissapear based on the exitance of the 'note' element.

Hi David,

If you are using PresentationServer 3.0, you can just bind the control
to the node "note", and the control will not appear if the node is not
there. Isn't that simple? :)

> My remaining problem is this:  If my user wants to add a 'note' element to the document, what is the best way to accomplish this?
>
> If I'm forced to guess at the solution, I would say this is the best approach:
>
> 1) add a UI element (link/button/whatever) that updates the value of the 'action' node to something like 'add_note'
> 2) in the page flow XML, use an xupdate template to append the 'note' node using 'xu:append'

Yes, except that I would recommend you use XSLT instead of XUpdate for
the reasons you mentionned.

> 2) Doesn't Orbeon support some sort of session literals that the page-flow can receive without having to bastardize the instance document by adding an 'action' element?  This doesn't seem like an elegant solution.

With PresentationServer 3.0, you don't need anymore to use this
"action" element trick. It was used in the past to discriminate in the
page flow between multiple buttons on the page. Now with
PresentationServer 3.0, different triggers can reference different
submissions, and so make requests to different URLs. This is more
elegant, which I guess responds to your question.

Alex
--
Blog (XML, Web apps, Open Source): http://www.orbeon.com/blog/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet