Re: XMLForm Xindice Howto added to Wiki [please, att. Ivelin]
Hello again, Ivelin, I have coded the changes and finally got it working. The part I don't like too much is where I need to get the model in order to add the document to the DB. Until that part everything seems to fit quite nicely. Remember I got the model stored in a XMLDocumentContainer and now I need the whole model in a DOM Node or XML String in order to add it to Xindice. This is what I did: /** * Add the document to the database */ public void addDocument() throws Exception { try { //add the document to the database XindiceManager xi = new XindiceManager(); //needs the DocumentRoot of the container xi.add(xindiceSubCol, ((Document)(((XMLDocumentContainer)(getForm().getModel())).getValue())).getD ocumentElement(), null); } catch (Exception e) { getLogger().error(DOM Document could not be created, e); throw e; } } Yeah, what a casting experience! ;-) Maybe I'm missing somehting and there's an easier way in order to get what I need... I prefer to send thi to the list for review by you or anybody else and then I'll update the Wiki howto. Once reviewed and finished maybe this will be a candidate for the official how-to docs, what do you think? Thanks for your help, I'm learning a lot. - Original Message - From: Ivelin Ivanov [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, January 26, 2003 3:24 AM Subject: Re: XMLForm Xindice Howto added to Wiki [please, att. Ivelin] 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] - 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]
Re: XMLForm Xindice Howto added to Wiki [please, att. Ivelin]
Ivelin, I have coded the changes and finally got it working. The part I don't like too much is where I need to get the model in order to add the document to the DB. Until that part everything seems to fit quite nicely. Remember I got the model stored in a XMLDocumentContainer and now I need the whole model in a DOM Node or XML String in order to add it to Xindice. I understand. It looks like you've been in a really good mood to get this casting to work ;) I suggest emailing the JXPath lead Dmirti for ideas, his email is [EMAIL PROTECTED] This is what I did: /** * Add the document to the database */ public void addDocument() throws Exception { try { //add the document to the database XindiceManager xi = new XindiceManager(); //needs the DocumentRoot of the container xi.add(xindiceSubCol, ((Document)(((XMLDocumentContainer)(getForm().getModel())).getValue())).getD ocumentElement(), null); } catch (Exception e) { getLogger().error(DOM Document could not be created, e); throw e; } } Yeah, what a casting experience! ;-) Maybe I'm missing somehting and there's an easier way in order to get what I need... I prefer to send thi to the list for review by you or anybody else and then I'll update the Wiki howto. Once reviewed and finished maybe this will be a candidate for the official how-to docs, what do you think? Go ahead. This will be a nice addition to the samples and how-tos. 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]
Re: XMLForm Xindice Howto added to Wiki [please, att. Ivelin]
I understand. It looks like you've been in a really good mood to get this casting to work ;) Yeah! ;-) I suggest emailing the JXPath lead Dmirti for ideas, his email is [EMAIL PROTECTED] I'm sending email to him. Go ahead. This will be a nice addition to the samples and how-tos. Great. Since I'm not sure of what to do, I'll read the docs on how to submit first, but it'd be easier for me if I could update the wiki page and let you or other to commit it. I'm more or less comfortable using the wiki but not quite when it comes to Forrest... Well, I'll see what Dimitri has to say and I'll post again. - 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]
Re: XMLForm Xindice Howto added to Wiki [please, att. Ivelin]
Ivelin, I got reply from Dmitri. I'm copying it below. Unfortunately I was right and there's not better way of making it with Containers other that the casting I proposed. Maybe when updating to 1.1. I'll rewrite the how-to tomorrow if I can find a couple hours and put it in the Wiki so you could see it all. If you feel it's ok, then we'll talk about how to make it available for the official docs, ok? Thanks for your help. - Original Message - From: Dmitri Plotnikov To: Josema Alonso Sent: Monday, January 27, 2003 11:19 PM Subject: Re: please help about a problem using JXPath Containers in Cocoon Josema, I think your solution is fine with JXPath 1.0, despite all the type casts. With JXPath 1.1 I could recommend this to extract the document element: Element root = (Element)context.getPointer(/*).getNode(); Unfortunately the getNode() method was not introduced until after 1.0 was released. If you call getValue(), the Element is converted to string by stripping all tags and keeping all textual contents - that's not what you need. - Dmitri - 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]
Re: XMLForm Xindice Howto added to Wiki [please, att. Ivelin]
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]
Re: XMLForm Xindice Howto added to Wiki [please, att. Ivelin]
Ivelin, I'm trying to code your suggestions but I have problems and some doubts. 1) You can remove ArtistBean altogether Done. 2) Store the empty id structure in a static file or local constant Done. 3) Override the getForm() method in the action Wouldn't it be enough to override the getFormModel() method? 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? 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? 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' Sorry about all the questions but this is totally new for me and it is not easy. Best. - 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]
RE: XMLForm Xindice Howto added to Wiki [please, att. Ivelin]
Ouch...I forgot to include the URL. I'm sorry. http://wiki.cocoondev.org/Wiki.jsp?page=XMLFormXindice Thanks :) -Mensaje original- De: Ivelin Ivanov [mailto:[EMAIL PROTECTED]] Enviado el: jueves, 23 de enero de 2003 4:24 Para: [EMAIL PROTECTED] Asunto: Re: XMLForm Xindice Howto added to Wiki [please, att. Ivelin] What is the URL? -=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]
RE: XMLForm Xindice Howto added to Wiki [please, att. Ivelin]
Hi! I strongly believe in XForms, but the sample you pointed show that the use with Java Beans for DB connectivity and data validation is currently too complex. I am thinking in what will happen if every form will be code like the example in a huge application? What about changes in the large DB application? Can a generator build the Java Beans automatically what about the Action automatically generated? Maybe we can find the answer in this area. Please dont take this email in the wrong sense. I know this is a very new technology and you are doing your best effort to get it run under Cocoon. But maybe we can find another way to make it easier. If this is the currently way to work with the XForms with Db connectivity. I think many people will stay at the current model: XML Form + stylesheet + validation form + DB modular actions. Maybe we can find something similar. Best Regards, Antonio Gallardo. P.D: I know this is a cruel critic to the current work developed in this area. But I think it must to be told. Please dont take me bad. I strongly believe in Cocoon. Sorry Josema Alonso dijo: Ouch...I forgot to include the URL. I'm sorry. http://wiki.cocoondev.org/Wiki.jsp?page=XMLFormXindice Thanks :) -Mensaje original- De: Ivelin Ivanov [mailto:[EMAIL PROTECTED]] Enviado el: jueves, 23 de enero de 2003 4:24 Para: [EMAIL PROTECTED] Asunto: Re: XMLForm Xindice Howto added to Wiki [please, att. Ivelin] What is the URL? -=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] - 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]
RE: XMLForm Xindice Howto added to Wiki [please, att. Ivelin]
Hello. First of all, thanks for commenting on this. Comments inline... I strongly believe in XForms, but the sample you pointed show that the use with Java Beans for DB connectivity and data validation is currently too complex. I am thinking in what will happen if every form will be code like the example in a huge application? What about changes in the large DB application? I know. I'm with you. It is a pain to code everything like this, but I really prefer to code logic in Java and not in XML. After all you finally build a MVC miniapp this way. Can a generator build the Java Beans automatically what about the Action automatically generated? Maybe we can find the answer in this area. I think that's the way to go. There was some talk on this list a while ago but we need more work on this. Please dont take this email in the wrong sense. I know this is a very new technology and you are doing your best effort to get it run under Cocoon. Of course, I do not :-) It's very instructive. But maybe we can find another way to make it easier. I hope so. I think many people will stay at the current model: XML Form + stylesheet + validation form + DB modular actions. I proposed different approaches in my conclusions. Another one would be to have modular DB actions for Xindice-like databases. But that would not solve the problem. Maybe a totally different approach would be needed. I do not like my solution that much, but this is the simple one I've found by now. I think we need to start working on it putting things out of the Action and maybe later out of the model. I've been thinking about some XML descriptors that could build the Action and Bean autmatically and/or maybe a transformation phase after that for the DB actions...I'm not sure...I should learn more to accomplish something like that... Again, thanks for your comments. I really appreciate them. Best. - 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]
Re: XMLForm Xindice Howto added to Wiki [please, att. Ivelin]
Hi! I strongly believe in XForms, but the sample you pointed show that the use with Java Beans for DB connectivity and data validation is currently too complex. I would argue that it is no more complex than doing the same with Struts. Let alone plain JSP and classic controller Servlets. I am thinking in what will happen if every form will be code like the example in a huge application? What about changes in the large DB application? I guess the sample is supposed to focus on showing how to use XMLForm with Xindice. If it is not making it clear that this is the one message it sends, then the text should be revised. Can a generator build the Java Beans automatically what about the Action automatically generated? Maybe we can find the answer in this area. Let's try to find it. Josema proposed an answer in the XML db area. We need another brave soul (maybe Antonio :) to show relational db usage. Ivelin Please dont take this email in the wrong sense. I know this is a very new technology and you are doing your best effort to get it run under Cocoon. But maybe we can find another way to make it easier. If this is the currently way to work with the XForms with Db connectivity. I think many people will stay at the current model: XML Form + stylesheet + validation form + DB modular actions. Maybe we can find something similar. Best Regards, Antonio Gallardo. P.D: I know this is a cruel critic to the current work developed in this area. But I think it must to be told. Please dont take me bad. I strongly believe in Cocoon. Sorry Josema Alonso dijo: Ouch...I forgot to include the URL. I'm sorry. http://wiki.cocoondev.org/Wiki.jsp?page=XMLFormXindice Thanks :) -Mensaje original- De: Ivelin Ivanov [mailto:[EMAIL PROTECTED]] Enviado el: jueves, 23 de enero de 2003 4:24 Para: [EMAIL PROTECTED] Asunto: Re: XMLForm Xindice Howto added to Wiki [please, att. Ivelin] What is the URL? -=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] - 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] - 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]
Re: XMLForm Xindice Howto added to Wiki [please, att. Ivelin]
Excelent document. I would like to suggest a slight improvement. The Model part can be improved quite a bit if you use a DOM object directly instead of a JavaBean wrapper. more specificly: 1) You can remove ArtistBean altogether 2) Store the empty id structure in a static file or local constant 3) Override the getForm() method in the action 4) Use the JXPath DOMContainer to load the xml file(constant) 5) Use the DOMContainer object as the Form model 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) If you follow these steps and I am not totally wrong, you should be able to cut about 50 lines from the sample. -=Ivelin=- - Original Message - From: Josema Alonso [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, January 23, 2003 2:42 AM Subject: RE: XMLForm Xindice Howto added to Wiki [please, att. Ivelin] Ouch...I forgot to include the URL. I'm sorry. http://wiki.cocoondev.org/Wiki.jsp?page=XMLFormXindice Thanks :) -Mensaje original- De: Ivelin Ivanov [mailto:[EMAIL PROTECTED]] Enviado el: jueves, 23 de enero de 2003 4:24 Para: [EMAIL PROTECTED] Asunto: Re: XMLForm Xindice Howto added to Wiki [please, att. Ivelin] What is the URL? -=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] - 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]
Re: XMLForm Xindice Howto added to Wiki [please, att. Ivelin]
Excelent document. Thank you. I would like to suggest a slight improvement. The Model part can be improved quite a bit if you use a DOM object directly instead of a JavaBean wrapper. more specificly: ... Wow. It sounds very very good. I really need to learn much more about JXPath. I'll try to code it this weekend or early next week and update the Wiki accordingly. I'll post my results and/or doubts here, too. Thanks a lot for your help. - 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]
Re: XMLForm Xindice Howto added to Wiki [please, att. Ivelin]
Hi, I think that Xforms will be mainy used for web DB app. I am using this opensource tool that can be extended to build other formats from an database design. His name is Druid you can find it at: http://sourceforge.net/projects/druid I can said that I already build my postgresql database using this excelent tool. Best Regards, Antonio Gallardo. Josema Alonso dijo: Excelent document. Thank you. I would like to suggest a slight improvement. The Model part can be improved quite a bit if you use a DOM object directly instead of a JavaBean wrapper. more specificly: ... Wow. It sounds very very good. I really need to learn much more about JXPath. I'll try to code it this weekend or early next week and update the Wiki accordingly. I'll post my results and/or doubts here, too. Thanks a lot for your help. - 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] - 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]
Re: XMLForm Xindice Howto added to Wiki [please, att. Ivelin]
What is the URL? -=Ivelin=- - Original Message - From: Josema Alonso [EMAIL PROTECTED] To: Cocoon-Users [EMAIL PROTECTED] Sent: Wednesday, January 22, 2003 6:18 PM Subject: XMLForm Xindice Howto added to Wiki [please, att. Ivelin] Hi, all. Ivelin, I should have done it a long while ago, but it was not possible for me until this day. I added a HowTo on using Xindice with XMLForms. I tried to use the easiest possible way. I hope I had not too many faults. Please review it and comment it if you want. Hope it could be useful. Best. ps: I used the Wiki since it was a lot easier for me, but you can put it wherever you think is better. - 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] - 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]