W3C home > Mailing lists > Public > www-forms@w3.org > October 2005

RE: What is the best way to deep copy an element?

From: Mark Birbeck <mark.birbeck@x-port.net>
Date: Mon, 17 Oct 2005 20:00:10 +0100
Message-ID: <50BE8DE1-9FA5-4E1F-902D-74BFCCF1C8F8@s15.mail.x-port.net>
To: "'Flinton Adam'" <Adam.Flinton@cfh.nhs.uk>
Cc: <www-forms@w3.org>

Hi Adam,

First, on xf:copy--it is intended to behave in the same way that xf:value
does in a xf:select. So in the same way that you can choose one item from a
list and have the 'value' of the item you have chosen 'copied' to a node, so
too, you can do the same with an element and its children. (I say this,
because I don't really understand what you mean by having xf:copy on

For example, if you had a selection control with some currencies as choices:


If you had selected 'EUR' then some target node would be set to 'EUR'--as
you would expect!

Now, if we replace xf:value with xf:copy, we might have choices like this:

  <ccy name="USD" rate="..." />
  <ccy name="EUR" rate="..." />
  <ccy name="GBP" rate="..." />

In this situation, if you selected the second one, your target node would
actually be the whole node plus any children.

So xf:copy 'copies' a tree to the target, in the same way that xf:value
'copies' a string of text to the target.

However, I'm not sure this is going to help you in what you are trying to
do, since it only applies to xf:select and xf:select1. I'm assuming that you
actually want to edit XHTML in a xf:textarea and have whatever the user
types saved to the instance. This is not currently possible in *standard*
XForms, although there is no reason why implementations shouldn't provide a
control that allows trees to be edited.

In some stuff we have done, we do it slightly differently and store the
encoded data, such as:

    Hello, &lt;em&gt;world&lt;/em&gt;

This is what you get if you type '<' or '>' into the xf:textarea, although
to make it easier we have a version of xf:textarea that allows you to do
simple XHTML editing (bold, italics, that kind of thing), which is invoked
by using @appearance.



Mark Birbeck
x-port.net Ltd.

e: Mark.Birbeck@x-port.net
t: +44 (0) 20 7689 9232
w: http://www.formsPlayer.com/
b: http://internet-apps.blogspot.com/

Download our XForms processor from

> -----Original Message-----
> From: www-forms-request@w3.org 
> [mailto:www-forms-request@w3.org] On Behalf Of Flinton Adam
> Sent: 17 October 2005 18:29
> To: www-forms@w3.org
> Subject: What is the best way to deep copy an element?
> Dear All,
> I am trying to write an Xforms app which allows a user to add 
> & change annotations written in XHTML where the annotation is 
> contained within a textarea
> If I use a repeat e.g.:
> <xf:repeat id="r2" style="" nodeset="mif:class/mif:attribute">
> 						<tr>
> 							<td>
> <xf:output ref="@name">
> 							</xf:output>
> 							</td>
> 							<td
> style="width: 50%; text-align: left; vertical-align: top;">
> <xf:textarea id="annotation" ref="mif:annotation/*" />
> 							</td>
> 						</tr>
> 					</xf:repeat>
> Then I just get the first bit of text etc but the moment it 
> rus into an xhtml element (e.g. <p> </p> then that's the end.
> I noticed that itemset contains a copy element:
> http://www.w3.org/TR/xforms/slice9.htm
> 9.3.4 The copy Element
> Which seems to do what I require (i.e. copy everything 
> between <annotation & </annotation>
> There is (at present) only one annotation & I am wondering if 
> within the repeat I can "auto-select" the single choice
> Just out of interest, why isn't there a copy element in a 
> repeat? I you are looking to display/edit chunks of XHTML 
> (e.g. as documentation) then it may be necessary.
> 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 Monday, 17 October 2005 19:01:06 UTC

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