W3C home > Mailing lists > Public > www-forms@w3.org > February 2006

RE: What is the best way to send arguments not in the model?

From: Klotz, Leigh <Leigh.Klotz@xerox.com>
Date: Tue, 7 Feb 2006 10:43:48 -0800
Message-ID: <E254B0A7E0268949ABFE5EA97B7D0CF401753263@usa7061ms01.na.xerox.net>
To: "Flinton Adam" <Adam.Flinton@cfh.nhs.uk>, <www-forms@w3.org>

Why not define what your instance to be a wrapper including the data
you're extracting and the meta-data about where it came from and goes
back to?
The returned value from the initial query can be something like this, so
this becomes the instance.
<documentSection locationpath="/a/b/c">
     <address>123 Anystreet</address>

Then when you post the updated instance, your server gets a
documentSection wrapper whose sold child element is the data that goes
back into your sever side document at the locationpath specified in the
attribute on documentSection.

So the instance starts out empty, then the user fills in the query bound
to location path, then an HTTP GET fills in the child data.   

Below is some XForms pseudocode to show you the client side.
Note that the editors for all possible values are included.
The controls in the body doesn't appear until the instance gets loaded
because "person" isn't there.
You can put in as may of these groups as you want to, and only the one
that matches the element that gets returned will show, due to relevance

When you press the Save button, the <documentSection> gets posted, along
with the locationpath saying where the data came from, and the child
element of documentSection is the data that goes there.

One word about this solution: you're trusting the client to remember
what section of the document you're editing, which may not be
appropriate depending on the sensitivity of your application.  If a
nefarious client could change the locationpath and do harm, then you
need to remember the location on the server side and just return a
mapping key in the returned documentSction, or perhaps leave the
locationpath back in the result but also return a second attribute that
hashes over locationpath, a secret, and other data to prevent replay
attack.  I'm not qualified to dispense any more advice on this subject
(or even this much ;-) 


   <documentSection locationpath="" xmlns="" />
 <xf:submission id="doQuery" method="get" replace="instance" "/>
 <xf:submission id="doSave" method="post" nodeset="instance('extracted'"
replace="all" />
  <xf:input ref="@locationpath"><xf:label>Location to
  <xf:group ref="person">
    <xf:input ref="name"><xf:label>Name</xf:input>
    <xf:input ref="address"><xf:label>Address</xf:input>
    <xf:input ref="phone"><xf:label>Phone</xf:input>
  <xf:group ref="book">
    <xf:input ref="title"><xf:label>Title</xf:input>
    <xf:input ref="author"><xf:label>Author</xf:input>
    <xf:input ref="isbn"><xf:label>ISBN</xf:input>
    <xf:input ref="price"><xf:label>Price</xf:input>
  <xf:submit submission="doQuery"><xf:label>Edit</xf:label></xf:submit>
  <xf:submit submission="doSave"><xf:label>Save</xf:label></xf:submit>

-----Original Message-----
From: www-forms-request@w3.org [mailto:www-forms-request@w3.org] On
Behalf Of Flinton Adam
Sent: Thursday, February 02, 2006 1:24 PM
To: www-forms@w3.org
Subject: What is the best way to send arguments not in the model?

Dear All,

We have a system which uses XSLT to Transform some XML into XHTML. When
the transform runs, it takes a note of the Xpath to that element in the
XML & puts it into the XHTML as a link to a popup which is used to edit
that small chunk of a much larger document.


1) The Servlet loads the XML file & holds onto it as a DOM in a
hashtable key'ed using it's url/filepath-name. 
2) The XML is then rendered into a viewable (XHTML form) via an XSLT
3) The XLST puts in the Xpath of the pretransformed XML element into the
XHTML as a link.
4) Clicking on that link makes the servlet use Xpath to pull the
contents of the XML element out as string & send it to a popup.
5) You do your editing in the pop-up
6) Clicking save posts the (changed) contents back to the servlet as
string & it is placed back into the DOM using the same Xpath which
originally extracted it.

Wht I am wondering wrt Xpath is that we need to post back various hidden
form values such as the xpath, the url of the file (which is the key to
get the relevant DOM) & a value to say it's a op-up posting back so
plaease put it into that DOM using this XPATH.

Given I would like to use Xforms to do this as I can save on
transforming XML > XHTML > XML in the popup, where would I be best off
putting these values?

i.e. at present the servlet would simply receive the XML Instance w/o
the relevant url & xpath to insert it back in.

I can obviously create a 2nd model to store the information as it comes
in so I can post it back, however it's the actual posting back I am
asking about i.e. is my only option to put these values within the url I
am posting e.g. some kind of MyServletURL/?xpath=/mynode/ etc?



This e-mail is confidential and privileged. If you are not the intended
recipient please accept our apologies; please do not disclose, copy or
distribute information in this e-mail or take any action in reliance on
its contents: to do so is strictly prohibited and may be unlawful.
Please inform us that this message has gone astray before deleting it.
Thank you for your co-operation.
Received on Tuesday, 7 February 2006 18:44:25 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:36:16 UTC