>
> > 3) Override the getForm() method in the action
> Wouldn't it be enough to override the getFormModel() method?

Yes. Your code looks good.

> Something like this:
>   protected Object getFormModel() {
>  //to load the XML model
>  Container DOMModel = null;
>  Source modelSrc = null;
>    //this parameter holds the name of the xml file with the empty XML
> structure
>     String modelFileName = getParameters().getParameter("xmlform-model",
> null);
>     if(modelFileName==null) return null;
>     try {
>      modelSrc = getSourceResolver().resolveURI(modelFileName);
>   DOMModel = new XMLDocumentContainer(new
> StreamSource(modelSrc.getInputStream()));
>         return DOMModel;
>       }
>       catch ( Exception e) {
>         throw new CascadingRuntimeException( " Failed instantiating form
> model ", e );
>       }
>       finally {
>         getSourceResolver().release(modelSrc);
>       }
>   }
>
> > 4) Use the JXPath DOMContainer to load the xml file(constant)
> I have used XMLDocumentContainer. I see there's a DocumentContainer but
only
> present in JXPath 1.1 alpha and the jar file is still not included in
> Cocoon, so I used the soon to be deprecated mentioned.
> Btw, how could I extract a DOMNode from the root or an XML String so I
could
> store the whole structure afterwards? I see in 1.1alpha I could do
something
> like 'DocumentContainer.MODEL_DOM' but I guess in 1.0 I should get a
> JXPathContext and search for the root node so I can get the String I need.
> Am I right?

Absolutely. On all counts.

>
> > 5) Use the DOMContainer object as the Form model
> Ok. But where should I store it? In a separate file like the ArtistBean I
> got before?
> Or maybe would be enough to declare it and initialize it in the getForm()
or
> getFormModel() method?

Should do.

>
> > 6) When you need to reference a node in the model, instead of using the
> DOM
> > API, you can directly use XPath,
> > like this: getForm().getValue("/@id")
> At this stage I can only see the form and when trying to access the model
I
> get the following exception: 'Cannot setValue of an object that is not
some
> other object's property/child'

I am not sure why that is. Look at the source of the XMLFormTransformer and
see how it uses the Form.getValue() to access properties referenced via
"ref" attributes in an XMLForm source document.

>
> Sorry about all the questions but this is totally new for me and it is not
> easy.

Not a problem at all. I have been looking for a good XML data model & db
example for a long time.
You are getting up to speed very fast.



Cheers,


Ivelin




---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

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

Reply via email to