Splendid. Between Ugo and Marc's replies, I've got everything I need. If I'm able to
make something out of all of this, who knows, some docs might come along.
Regards, Upayavira
On 10 Jul 2003 at 14:38, Ugo Cei wrote:
> Upayavira wrote:
> > I'd like to start building a site that uses jxforms and flow to
> > allow the user to edit content (addresses) stored in a single XML
> > file. There'll be one user responsible for up to 200 addresses, with
> > the addresses visible on a public site.
> >
> > The addresses are all stored in a single XML file.
> >
> > I can see how, using jxforms/flow, I can really easily build the
> > front end. But how do I get my data out of my XML file, and then get
> > the changed data back into it?
> >
> > I could do it in Java, but that'd require XML parsers, serializers,
> > etc, etc, which'd be a pain to write for such a small and simple
> > site.
> >
> > Can I use jxpath in some way to access the XML file resource?
> >
> > Regards, Upayavira
>
> I'm doing something similar, even though my form's model is the whole
> XML file and not just some part of it (but it should be easy to
> extract just what you need using JXPath). Since a form's model can be
> a DOM and not just a bean, you could just parse the file and set the
> Document as the form's model:
>
> /* WARNING: Exception handling removed for brevity */
>
> importClass(Packages.org.apache.excalibur.xml.dom.DOMParser);
> importClass(Packages.org.xml.sax.InputSource);
> importClass(Packages.org.apache.xml.serialize.DOMWriterImpl);
>
> function newPaziente(form, pathname) {
> var parser = cocoon.getComponent(DOMParser.ROLE);
> var domPaziente = parser.parseDocument(new InputSource(pathname));
> if (parser != null) {
> cocoon.releaseComponent(parser);
> parser = null;
> }
> form.setModel(domPaziente);
> form.sendView("forms/newPaziente");
> var fos = null;
> fos = new java.io.FileOutputStream(file);
> var writer = new DOMWriterImpl();
> writer.writeNode(fos, domPaziente);
> fos.close();
> }
>
>
> HTH,
> Ugo
>
> --
> Ugo Cei - http://www.beblogging.com/blog/
>
>