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

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">
  <person>
     <name>Leigh</name>
     <address>123 Anystreet</address>
     <phone>+1-212-555-121</phone>
  </person>
</documentSection>

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

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


Leigh.

<xf:model>
 <xf:instance>
   <documentSection locationpath="" xmlns="" />
 </xf:instance>
 <xf:submission id="doQuery" method="get" replace="instance" "/>
 <xf:submission id="doSave" method="post" nodeset="instance('extracted'"
replace="all" />
<xf:model>
<body>
  <xf:input ref="@locationpath"><xf:label>Location to
edit:</xf:label></xf:input>
  <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>
  <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:group>
  <xf:submit submission="doQuery"><xf:label>Edit</xf:label></xf:submit>
  <xf:submit submission="doSave"><xf:label>Save</xf:label></xf:submit>
</body>


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

i.e.: 

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
sheet.
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?


TIA

Adam

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