[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: best way to generate form from xml+schema?

Subject: Re: best way to generate form from xml+schema?
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 16 Oct 2001 11:55:27 +0100
populate form from xml
Hi Graham,

> I originally wanted to use xsl as far as possible, with perl just as
> a 'glue' language completely independent of the particular schema
> used. But I'm starting to wonder how practical that actually is
> (especially without the ability to use XML1.1 style variables). I've
> just started realising the problems in coming back in the reverse
> direction ie. once the form has been submitted, I need to take the
> incoming cgi parameters and match them against the schema to
> generate the new xml file. At the moment, the only idea I have for
> that is to give the cgi parameters names which reflect the xml
> structure (eg not 'email', but 'programItem:submitter:email'). Write
> the parameters to a temporary file. Then use a stylesheet heavily
> dependent on 'substring-after' functions to generate an xml file
> with expanded versions of the parameters
> (eg
> <programItem>
>         <submitter>
>                 <email>a@xxx</email>
>         </submitter>
> </programItem> 
> Then read this into a second stylesheet which also reads in the
> schema to generate the full xml file.

You might want to look at the XForms method of achieving a similar
kind of thing. There, the basic approach is to link each input field
to a location in some template XML, using an XPath. What I'm
suggesting is, if you know what the XML document will look like as a
whole (or can construct a sample from the schema, which isn't *too*
difficult), then you can basically copy that, using the result of the
form to populate the elements and attributes with values. I think that
would be easier than trying to parse strings to create an XML
document, especially when some of the paths overlap each other
(although I have no doubt it's *possible* to approach it in that way).

> I'm assuming there's no way to do this more directly with only
> xsl1.0 variables... (eg. I can't pack the incoming parameters to a
> stylesheet into a variable and access them using 'name()' matched
> against the schema). It's starting to look like the number of file
> writes and reads may make this method too slow to be very practical
> compared with doing everything in Perl.

I don't think you should be shy about using a node-set() extension
function to get the XML variables that you want. Virtually every XSLT
processor in existence has one, so the stylesheet needn't be
completely unportable, if you're worried about that.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.