Thanks a lot.  At the risk of disclosing my ignorance:

  1. Do you parse a schema definition every time it is needed by the listeners? 
 Or do the listeners store the received information somewhere?

  2. What exactly are the listeners?  Template motors for html generation?

  3. Is it possible for you to sketch an overall design/scenario?  Like:

  1. Input schema XYZ...
  ...
  i. Input XYZ valild xml file ...
  ...
  j. Output html form to user ...
j+1. Filled in html form sent to server
  ...
  k. Output html/xml with style sheet or whatever.

Where does your example code fit?  Hope these questions are not too stupid.

- Regards, Jon
 

-----Original Message-----
From: Benoit Orihuela [mailto:[EMAIL PROTECTED] 
Sent: Friday, January 06, 2006 9:54 AM
To: user@xmlbeans.apache.org
Subject: Re: Html forms -> xmlBeans -> xml document

Hi all,


>   1. Has anyone here done something similar?
Yeah, I've done something similar on a project I'm currently working on. 
Starting from an XML Schema definition, we generate HTML forms for the Front 
Office part, screens for visualization of data entered in form for the Back 
Office part (forms instruction), XSL-FO files for PDF generation, business 
objects with XDoclet information (@hibernate tags) and other minor things ...

>   2. Are there any obvious tools I that I have overseen?
At the time we started the project (last summer), I've not find any tool to do 
this. So we use directly the XML Beans API for the parsing of the XML Schema 
and we defined an interface that listeners have to implement to receive 
information about the schema (à la SAX). The main entry point of the 
generation process looks like this :

    public void parseXsdFile(File xsdFile) {
        try {
            logger.debug("parseXsdFile() Parsing XSD file : " + xsdFile);
            SchemaTypeLoader loader =                
XmlBeans.typeLoaderForClassLoader(SchemaDocument.class.getClassLoader());
            XmlObject[] xmlObjects = new XmlObject[1];
            xmlObjects[0] = loader.parse(xsdFile, null, null);

            SchemaTypeSystem sts =
                XmlBeans.compileXsd(xmlObjects,
                                    XmlBeans.getBuiltinTypeSystem(),
                                    null);

            SchemaGlobalElement[] globals = sts.globalElements();

            for (int i = 0; i < globals.length; i++) {
                SchemaGlobalElement sge = globals[i];
                targetNamespace = sge.getName().getNamespaceURI();
                logger.debug("parseXsdFile() Target namespace : " +  
targetNamespace);

                // here, we send an event to listeners to tell them a new
                // global element parsing has started
                // ...

                SchemaType st = sge.getType();
                SchemaType basicType = sge.getType().getBaseType();
                // used to retrieve local annotations of elements
                SchemaParticle schemaParticle = st.getContentModel();

                SchemaProperty[] properties = st.getProperties();
                for (int k = 0; k < properties.length; k++) {
                    SchemaProperty property = properties[k];
                    // process property and send events to listeners
                }

               // send event to listeners about end of global element parsing
            }
        } catch (XmlException xe) {
            logger.debug("XMLException : " + xe.getMessage());
            xe.printStackTrace();
        } catch (IOException ie) {
            logger.debug("IOException : " + ie.getMessage());
            ie.printStackTrace();
        }
    }


Regards,

Benoit.
-- 
Benoit Orihuela - [EMAIL PROTECTED] - GPG-PGP : C94615BE
Architecte logiciel, Zenexity - http://www.zenexity.fr
Mobile : +33 (0)6 87 42 71 07 - Tél : +33 (0)1 44 89 47 67
Zenexity, 101-103 boulevard Mac Donald 75019 Paris


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to