Hi

We're working on a web application where a user can define a simplistic XML
schema from a 'palette' of a few defined types, some of which are
complexTypes. This uses the castor.xml.schema.* classes which all works OK. 

>From the resulting schema we derive an XSL which renders an instance XML as
a web form, filling in the fields as appropriate. The problem I have now is
the next step, i.e. using the generated code in the web app to extract the
form contents

To give an example consider the simple schema

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"; >
<xsd:annotation><xsd:documentation>definition of Tim&apos;s schema
product</xsd:documentation></xsd:annotation>
<xsd:element name="product">
<xsd:complexType>
<xsd:sequence>
        <xsd:element name="newstr" type="xsd:string"></xsd:element>
        <xsd:element name="ndate" minOccurs="0"
type="xsd:date"></xsd:element>
        <xsd:element name="anint"
minOccurs="0"><xsd:simpleType><xsd:restriction
base="xsd:integer"><xsd:fractionDigits value="0"/><xsd:minInclusive
value="0"/><xsd:maxInclusive
value="10"/></xsd:restriction></xsd:simpleType></xsd:element>
<xsd:element name="aper" minOccurs="0" type="Person"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="Person"><xsd:sequence>
  <xsd:element name="surname" type="xsd:string"/>
  <xsd:element name="initials" minOccurs="0" type="xsd:string"/>
  <xsd:element name="firstname" type="xsd:string"/>
  <xsd:element name="title"><xsd:simpleType>
  <xsd:restriction base="xsd:string"><xsd:enumeration
value="Mr"/><xsd:enumeration value="Mrs"/><xsd:enumeration
value="Miss"/><xsd:enumeration value="Ms"/><xsd:enumeration
value="Dr"/><xsd:enumeration
value="other"/></xsd:restriction></xsd:simpleType></xsd:element></xsd:sequen
ce></xsd:complexType>
</xsd:schema>

instance conforming to the schema

<?xml version='1.0' ?>
<product>
        <newstr>Hello there</newstr>
        <ndate>2002-12-20</ndate>
        <anint>7</anint>
        
<aper><surname>Bloggs</surname><firstname>Fred</firstname><title>Mr</title><
/aper>
</product>

web form (values filled in by XSL from existing instance)

<form>
<input type="text" name="newstr" value="Hello there">
<input type="text" name="ndate"  value="2002-12-20">
<input type="text" name="anint"  value="7">
<select name="aper-title"><option
selected>Mr</option><option>Mrs</option><option>Miss</option><option>Ms</opt
ion><option>Dr</option><option>other</option></select><input type="text"
name="aper-firstname" size="8" value="Fred"><input type="text" size="2"
name="aper-initials" value=""><input type="text" name="aper-surname"
value="Bloggs">
</form>

Upon form submission we need to take the form data and create a new instance
from the new values (the first time the form is used all values will be
empty). Ideally we want to do this through some generic bit of code, given
we have access to the schema definition and the generated Castor classes.
Also if we have several product schemas we don't want to keep writing code
to wire up each form to the instance methods for each product.

I suspect I'm going to need to do some reflection on the generated code,
then pull out form parameters, cast the value and invoke the set method, but
the prospect of dealing with the complex types is becoming daunting :-/

Has anybody done this kind of thing before ?  Is there any of the castor
framework code we can leverage in performing this task?

thanks


Tim Fulcher

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to