It is said that " XForms can directly talk to eXist to read and write XML documents and perform all the common CRUD (Create, Retrieve, Update and Delete) operations."
Excellent... but how does update per example works ? In the book tutorial, I believe you modifiy the instance : <xforms:trigger> <xforms:label>Add One</xforms:label> <xforms:insert ev:event="DOMActivate" context="instance('books-instance')" nodeset="book" at="1" position="before" origin="instance('book-template')"/> </xforms:trigger> And the you submit it to the eXist database. In my case, I wish not to update my instance, but add another instance in that file : <xforms:submission id="save-submission" ref="instance('news-template')" method="put" replace="none" action="/exist/rest/db/cgc/news.xml" /> The things is that it crushes everything in that file. How can I update news.xml ? Can you precise at what node the instance should be stocked ? |
Hi,
> (...) In my case, I wish not to > update my instance, but add another instance in that file : > > <xforms:submission id="save-submission" ref="instance('news-template')" > method="put" replace="none" action="/exist/rest/db/cgc/news.xml" /> > > The things is that it crushes everything in that file. How can I update > news.xml ? Can you precise at what node the instance should be stocked ? you can use xupdate to control what changes should be made to the stored resources. There's an example in the documentation: http://www.orbeon.com/ops/doc/processors-xmldb#xmldb Another very good listing of xupdate possibilities (helped me a lot): http://www.xmldatabases.org/projects/XUpdate-UseCases/ You can use PUT via the REST interface, too, but i think you can't PUT just the chunk that changed or should be added, but you have update and send the entire instance. florian -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
So to confirm, if you want to just update, you have to go through an xpl processor ? Steph Florian Schmitt a écrit : Hi, -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Hi Stephane,
> So to confirm, if you want to just update, you have to go through an xpl > processor ? Not precisely. As far as i see, there are two "scenarios": 1.) In your xforms, you have the complete xml file that should get updatet available as an instance. In this case, you can update that instance in your XForms and upload it via the REST interface completely. Here, you don't need a xpl. 2.) Your xforms instance consists only of the the xml part that should be added to an existing xml resource in eXist. Then you have to use the xmldb xpl processor. I think you can use XUpdate via the Rest interface, too. To do so, you have to issue a POST request containing the XUpdate document: http://www.exist-db.org/devguide.html#N1021D But to create the XUpdate document, in most cases a XPL would be useful to do the transformation, so there's no great advantage compared to the xmldb processor. For my part, i use the xmldb processor usually. florian -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Administrator
|
In reply to this post by StephR
Steph,
You can POST an XQuery or XUpdate to eXist directly from XForms. BTW we are giving a talk on XForms and eXist at the XForms Evening event of the XML 2007 conference in Boston on December 3: http://2007.xmlconference.org/public/schedule/topic/15 By then I hope to have some better material than what we have now ;-) -Erik Stephane Ruchet wrote: > Thanks Florian for the links! > > So to confirm, if you want to just update, you have to go through an xpl > processor ? > > Steph > > > Florian Schmitt a écrit : >> Hi, >> >>> (...) In my case, I wish not to >>> update my instance, but add another instance in that file : >>> <xforms:submission id="save-submission" ref="instance('news-template')" >>> method="put" replace="none" action="/exist/rest/db/cgc/news.xml" /> >>> >>> The things is that it crushes everything in that file. How can I update >>> news.xml ? Can you precise at what node the instance should be stocked ? >> >> you can use xupdate to control what changes should be made to the >> stored resources. There's an example in the documentation: >> >> http://www.orbeon.com/ops/doc/processors-xmldb#xmldb >> >> Another very good listing of xupdate possibilities (helped me a lot): >> >> http://www.xmldatabases.org/projects/XUpdate-UseCases/ >> >> You can use PUT via the REST interface, too, but i think you can't PUT >> just the chunk that changed or should be added, but you have update >> and send the entire instance. >> >> >> florian >> >> -- Orbeon Forms - Web Forms for the Enterprise Done the Right Way http://www.orbeon.com/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Hi Erik,
I read so ok... but how ? :) Erik Bruchez a écrit : Steph, -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Administrator
|
You can use the eXist REST API:
http://exist.sourceforge.net/devguide.html#N1021D This documentation about the oxf:xforms-submission processor is also useful: http://www.orbeon.com/ops/doc/processors-submission In your case, you would do the same directly from XForms. -Erik Stephane Ruchet wrote: > Hi Erik, > > I read so ok... but how ? :) > > > > > Erik Bruchez a écrit : >> Steph, >> >> You can POST an XQuery or XUpdate to eXist directly from XForms. >> >> BTW we are giving a talk on XForms and eXist at the XForms Evening >> event of the XML 2007 conference in Boston on December 3: >> >> http://2007.xmlconference.org/public/schedule/topic/15 >> >> By then I hope to have some better material than what we have now ;-) >> >> -Erik >> >> Stephane Ruchet wrote: >>> Thanks Florian for the links! >>> >>> So to confirm, if you want to just update, you have to go through an >>> xpl processor ? >>> >>> Steph >>> >>> >>> Florian Schmitt a écrit : >>>> Hi, >>>> >>>>> (...) In my case, I wish not to >>>>> update my instance, but add another instance in that file : >>>>> <xforms:submission id="save-submission" >>>>> ref="instance('news-template')" >>>>> method="put" replace="none" action="/exist/rest/db/cgc/news.xml" /> >>>>> >>>>> The things is that it crushes everything in that file. How can I >>>>> update >>>>> news.xml ? Can you precise at what node the instance should be >>>>> stocked ? >>>> >>>> you can use xupdate to control what changes should be made to the >>>> stored resources. There's an example in the documentation: >>>> >>>> http://www.orbeon.com/ops/doc/processors-xmldb#xmldb >>>> >>>> Another very good listing of xupdate possibilities (helped me a lot): >>>> >>>> http://www.xmldatabases.org/projects/XUpdate-UseCases/ >>>> >>>> You can use PUT via the REST interface, too, but i think you can't >>>> PUT just the chunk that changed or should be added, but you have >>>> update and send the entire instance. >>>> >>>> >>>> florian >>>> >>>> >> >> -- Orbeon Forms - Web Forms for the Enterprise Done the Right Way http://www.orbeon.com/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Erik & Florian,
1.) In your xforms, you have the complete xml file that should get updatet available as an instance. In this case, you can update that instance in your XForms and upload it via the REST interface completely. Here, you don't need a xpl.I like this idea and this is the one I would like to fulfill. My knowledge of xforms & instances are still limited and I didn't succeed in a working example. I have came up for now to this : a 'news-instance' instance that has all the news that is in the database to be viewed on the page. This is ok. There a 2nd instance, 'news-template', that will have the new "news" that the user wants to enter. At first I thought this would be easy, as the book tutorial shows, but I was confronted to a problem : impossible to remove the element "news" from that instance to only have <item> .... </item>. Then my idea was to first copy this instance in the 'news-instance' instance, and the launch the submission to eXist. <xforms:instance id="news-instance"> <news xmlns=""> <item> <subject/> <date/> <contributors/> <content/> <comment/> </item> </news> </xforms:instance> <xforms:instance id="news-template"> <!-- if I remove <news> I cannot make the right changements for the bind, group and trigger elements --> <news xmlns=""> <item mode="noView"> <subject/> <date/> <contributors/> <content/> <comment/> </item> </news> </xforms:instance> <xforms:bind nodeset="instance('news-template')"> <!-- if I remove <news> from news-template, what would be the proper nodeset? Should I replace all the item by instance('news-template') --> <xforms:bind nodeset="item" relevant="@mode = 'view'" /> <xforms:bind nodeset="item/subject" required="true()"/> <xforms:bind nodeset="item/date" type="xs:date" /> </xforms:bind> <xforms:submission id="save-submission" ref="instance('news-instance')" method="put" replace="none" action="/exist/rest/db/cgc/news.xml" /> <xforms:submission id="list-submission" serialize="false" method="get" action="/exist/rest/db/cgc/news.xml" replace="instance" instance="news-instance"/> </xforms:model> <xforms:group ref="instance('news-template') "> <xforms:trigger id="addNews" ref=".[item/@mode != 'view']"> <xforms:label>Add</xforms:label> <xforms:setvalue ref="item/@mode" ev:event="DOMActivate" value="'view'" /> </xforms:trigger> <br /> <br /> <xforms:group ref="item"> <xforms:input ref="subject"> <xforms:label>Subject: </xforms:label> </xforms:input> <br /> <xforms:input ref="date"> <xforms:label>Date: </xforms:label> </xforms:input> <br /> <xforms:input ref="contributors"> <xforms:label>Contributor(s): </xforms:label> </xforms:input> <br /> <xforms:textarea ref="content" appearance="xxforms:autosize"> <xforms:label>Content</xforms:label> </xforms:textarea> <br /> <xforms:submit submission="save-submission"> <xforms:label>Save</xforms:label> <!-- Copy first the template-instance in news-instance, then submit --> <xforms:insert ev:event="DOMActivate" context="instance('news-template')" nodeset="item" at="1" position="before" origin="instance('news-template')"/> </xforms:submit> <xforms:trigger id="cancelNews" ref="."> <xforms:label>Cancel</xforms:label> <xforms:setvalue ref="@mode" ev:event="DOMActivate" value="'noView'" /> </xforms:trigger> </xforms:group> </xforms:group> <xforms:group ref="instance('news-instance') "> <xforms:repeat nodeset="item" id="item-repeat"> <p> <strong><xforms:output ref="subject" /></strong> - <xforms:output ref="date" /> / <xforms:output ref="contributors" /> <hr /> <xforms:output ref="content" /> </p> </xforms:repeat> </xforms:group> What do you think ? 2.) Your xforms instance consists only of the the xml part that should be added to an existing xml resource in eXist. Then you have to use the xmldb xpl processor.Ok, I have made an example and it works great! You can use the eXist REST API: I think you can use XUpdate via the Rest interface, too. To do so, you have to issue a POST request containing the XUpdate document:Mmmm didn't understand a thing... I am really starting from zero :)! I thought it was possible to do something like this : <xforms:submission id="update-submission" ref="instance('news-instance')" method="put" replace="update" action="/exist/rest/db/cgc/news.xml" "extracode" /> Regards Steph -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Could someone confirm : for one reason, it is not possible to bind the root element of a document ? Here is my new code that works : <xforms:model> <!-- Load news when the XForms engine is ready --> <xforms:send ev:event="xforms-ready" submission="list-submission"/> <xforms:instance id="news-instance"> <news xmlns=""> <item> <subject/> <date/> <contributors/> <content/> <comment/> </item> </news> </xforms:instance> <xforms:instance id="news-template"> <!-- if I remove <news> I cannot make the right changements for the bind, group and trigger elements --> <news xmlns=""> <item mode="noView"> <!--mode="noView"--> <subject /> <date/> <contributors/> <content/> <comment/> </item> </news> </xforms:instance> <xforms:bind nodeset="instance('news-template')"> <xforms:bind nodeset="item" relevant="@mode = 'view'" /> <xforms:bind nodeset="item/subject" required="true()" /> <xforms:bind nodeset="item/date" type="xs:date" /> </xforms:bind> <xforms:submission id="save-submission" ref="instance('news-instance')" method="put" replace="none" action="/exist/rest/db/cgc/news.xml" /> <xforms:submission id="list-submission" serialize="false" method="get" action="/exist/rest/db/cgc/news.xml" replace="instance" instance="news-instance"/> </xforms:model> </head> <xforms:group ref="instance('news-template') "> <xforms:trigger id="addNews" ref=".[item/@mode != 'view']"> <xforms:label>Add</xforms:label> <xforms:setvalue ref="item/@mode" ev:event="DOMActivate" value="'view'" /> </xforms:trigger> <br /> <br /> <xforms:group ref="item"> <xforms:input ref="subject"> <xforms:label>Subject: </xforms:label> </xforms:input> <br /> <xforms:input ref="date"> <xforms:label>Date: </xforms:label> </xforms:input> <br /> <xforms:input ref="contributors"> <xforms:label>Contributor(s): </xforms:label> </xforms:input> <br /> <xforms:textarea ref="content" appearance="xxforms:autosize"> <xforms:label>Content</xforms:label> </xforms:textarea> <br /> <xforms:submit submission="save-submission"> <xforms:label>Save</xforms:label> <xforms:insert ev:event="DOMActivate" context="instance('news-instance')" nodeset="item" at="1" position="before" origin="instance('news-template')/*"/><!-- this was the trick ;) --> <xforms:setvalue ref="@mode" ev:event="DOMActivate" value="'noView'" /> <xforms:delete ev:event="DOMActivate" context="instance('news-template')" nodeset="item/*" at="1"/> </xforms:submit> <xforms:trigger id="cancelNews" ref="."> <xforms:label>Cancel</xforms:label> <xforms:setvalue ref="@mode" ev:event="DOMActivate" value="'noView'" /> </xforms:trigger> </xforms:group> </xforms:group> <xforms:group ref="instance('news-instance') "> <xforms:repeat nodeset="item" id="item-repeat"> <p> <strong><xforms:output ref="subject" /></strong> - <xforms:output ref="date" /> / <xforms:output ref="contributors" /> <hr /> <xforms:output ref="content" /> </p> </xforms:repeat> </xforms:group> Now, when a user clicks on the add button, the news-template keeps the data from the preceeding news that was entered before, which is normal. Now I would like to erase that instance and I didn't find anything else except the xforms:delete. But I have only managed to erase the hole element, not the text. Is this possible (I suppose of course yes ;) ) ? Thanks Stephane Ruchet a écrit : Erik & Florian, -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Administrator
|
Stephane Ruchet wrote:
> Some improvements... > > Could someone confirm : for one reason, it is not possible to bind the > root element of a document ? No that's supposed to work, there is no difference between the root element or other elements. > Now, when a user clicks on the add button, the news-template keeps the > data from the preceeding news that was entered before, which is normal. > Now I would like to erase that instance and I didn't find anything else > except the xforms:delete. But I have only managed to erase the hole > element, not the text. Is this possible (I suppose of course yes ;) ) ? The trick is to use a separate instance as the template to copy. Please check the XForms Bookcast tutorial for an example, and look at how "book-template" is used. -Erik -- Orbeon Forms - Web Forms for the Enterprise Done the Right Way http://www.orbeon.com/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Free forum by Nabble | Edit this page |