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

RE: Open, edit, save XML file--help or example

From: Klotz, Leigh <Leigh.Klotz@xerox.com>
Date: Wed, 20 Dec 2006 10:31:01 -0800
Message-ID: <E254B0A7E0268949ABFE5EA97B7D0CF4029633F7@usa7061ms01.na.xerox.net>
To: "Colin Sagan" <colin@cmbf.org>, <www-forms@w3.org>

I don't think FormFaces is going to be able to save to a local file with
a file:// URI, but you can ask on the FormFaces list at SourceForge.
You can do it through a web server if the web server implements PUT; you
probably have to specially enable PUT on the directory you want the
files to be placed in, using your web servers configuration.  It's not
too onerous for apache -- check on the syntax of ".htaccess" files.

You can also change your put to a post and write a small script to save
the data to a file.
Since the data posted is already the XML file, you should just be able
to write it directly to a file.
You still should probably use .htaccess or some other mechanism to
preform authentication first, though!

As for re-ordering, you will need to do that by posting to a script on
the server side and using replace='instance' to get the data back;
XForms 1.0 offers very little for structural modification of the XML
file.  You will find the insert and delete actions, though, which can
operate on repeating structure, so you should be able to add a new dish
at any point in the list.  There's an example of this in the XForms 1.0
Recommendation, tested in X-Smiles, and another one (apparently updated
to work with the pecularities of Mozilla XForms) in

Please write back if you have other specific questions.


-----Original Message-----
From: www-forms-request@w3.org [mailto:www-forms-request@w3.org] On
Behalf Of Colin Sagan
Sent: Saturday, December 16, 2006 10:51 PM
To: www-forms@w3.org
Subject: Open, edit, save XML file--help or example

I am working on a system for a restaurant to update it's menu easily  
and I thought I'd take the opportunity to sink my teeth into xforms.  
I've got it displaying but I can't get it to save, and I haven't had  
much luck finding good examples of this process.

Currently I am trying to use the formfaces javascript but have by no  
means exhausted the options. Just seemed like the easiest given that  
I don't have a lot of experience with apache and the plugins are too  
limited in terms of mobility.

So this is what I've patched together from different examples, also,  
next I want to get reordering and insert/delete working so if there  
is anything I'm doing currently that will prevent that I would  
appreciate suggestions to make that easier.

<?xml version="1.0" encoding="UTF-8"?>

   <xf:instance src="breakfast-edit_test.xml" xmlns="" />
   <xf:submission id="read-from-file" method="get" action="breakfast- 
edit_test.xml" replace="instance" />
   <xf:submission id="save-to-file" method="put" action="breakfast- 
edit_test.xml" />


	<xf:repeat id="courses" nodeset="/menu/course">
	<xf:input ref="courseTitle">
		<xf:label>Course Title</xf:label>
	<xf:textarea ref="courseDescription">
		<xf:label>Course Description</xf:label>
	<xf:repeat id="dishes" nodeset="dish">
		<xf:textarea ref="description">
		<xf:input ref="price">

<xf:submit submission="read-from-file">

	<xf:action ev:event="DOMActivate">
		<xf:send submission="read-from-file" />


And the XML file (I cut it down to one dish per course so it doesn't  
take up so much room!

<?xml version="1.0" encoding="UTF-8"?>
<menu id="breakfast">
	<date />
		<courseTitle>Coffee Bar</courseTitle>
		<courseDescription>Bluebottle Coffee -- Dogpatch Blend
			<description>Espresso with organic milk,
macchiato, cappuccino, latte
			<description>Drip Coffee</description>
			<description>Mighty Leaf Green Tea &amp; Classic
			<description>Fresh leaves, lemon verbena herbal
		<courseTitle>Grab &amp; Go</courseTitle>
		<courseDescription />
			<description>Hard boiled egg with
herbed/flavored salts</description>
			<description>Seasonal fruit</description>
		<courseDescrption />
			<description>Ginger scones</description>
			<description>Pain au chocolat</description>
		<courseTitle>Breakfast Pizza</courseTitle>
		<courseDescription>Served 7:30 to
			<description>Egg and truffle -- Pizza crust,
sunny side up egg,  
truffle olive oil</description>
			<description>Bacon &amp; eggs scramble -- Hobbs
bacon and eggs,  
Received on Wednesday, 20 December 2006 18:31:44 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:37:55 UTC