From: Florent G. <li...@fg...> - 2013-11-03 16:24:40
|
No. I have tried to create /db/webapp/upload after your email, and I still have the same error. Same if I create a new directory in $EXIST_HOME/webapp/upload. The file betterform.log contains the excerpt at the end of this email [*]. I am not sure to see exactly what I need to do. Let's say I have an app foobar in /db/apps. I created a file with your HTML form at test/upload-csv.html (I changed the value of the attribute data-template-with from templates/page2.html, which does not exist, to templates/page.html): /db/apps/foobar/test/upload-csv.html Where am I supposed to create the functions foo:upload-document and f:move-to-db? Where am I supposed to create the dir /webapp/upload? Thank you for your quick help! Regards, -- Florent Georges http://fgeorges.org/ http://h2oconsulting.be/ [*] betterform.log excerpt: 2013-11-03 17:15:15,527 [eXistThread-2125] ERROR (? [doFilter]:?) - could not create document container de.betterform.xml.xforms.exception.XFormsException: could not create document container at de.betterform.xml.xforms.XFormsProcessorImpl.setXForms(XFormsProcessorImpl.java:290) at de.betterform.agent.web.WebProcessor.setXForms(Unknown Source) at de.betterform.agent.web.filter.XFormsFilter.doFilter(Unknown Source) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:533) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116) at org.eclipse.jetty.server.Server.handle(Server.java:368) at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:488) at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:932) at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:994) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:640) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235) at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628) at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543) at java.lang.Thread.run(Thread.java:680) Caused by: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup. at org.apache.xerces.parsers.DOMParser.parse(Unknown Source) at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source) at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:110) at de.betterform.xml.xforms.XFormsProcessorImpl.setXForms(XFormsProcessorImpl.java:287) ... 26 more Le Dimanche 3 novembre 2013 16h06, Loren Cahlander <lor...@gm...> a écrit : Did you create the folder upload in the webapp directory? > > >On Nov 3, 2013, at 9:57 AM, Florent Georges <li...@fg...> wrote: > > Thank you! I've modified view.xql accordingly (by the way, does >>that mean that eXist 2.1 supports the new (soon to become) standard >>serialization options in XQuery 3.0, and not the eXist-specific option >>anymore?) >> >> When I reload the page, I get an error saying "could not create >>document container". I googled a bit for this error, in relation to >>eXist and/or betterFORM, but could not find anything relevant. >>Screenshot at: >> >> http://fgeorges.org/tmp/exist-betterform-error.png >> >> Any idea? >> >>-- >> >>Florent Georges >>http://fgeorges.org/ >>http://h2oconsulting.be/ >> >> >> >> >> >>Le Dimanche 3 novembre 2013 15h27, Loren Cahlander <lor...@gm...> a écrit : >> >>I forgot to add the need to make a change to view.xql >>> >>> >>>Change >>> >>> >>>declare option exist:serialize"method=html5 media-type=text/html enforce-xhtml=yes"; >>> >>> >>> >>>to >>> >>> >>>declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization"; >>> >>> >>>declare option output:method"html5"; >>>declare option output:media-type"text/html"; >>> >>> >>> >>> >>> >>>On Nov 3, 2013, at 9:22 AM, Florent Georges <li...@fg...> wrote: >>> >>> Hi Loren, >>>> >>>> Thank you for the example! I copied the file to my webapp, and >>>>tried to access through my browser. But the browser actually sees the >>>>XForms elements, where I expected betterFORM to actually convert them >>>>to some HTML + JavaScript equivalent. That is, if I select "see >>>>source" on the browser, I see the exact same source, with the XForms >>>>elements. >>>> >>>> The documentation at http://exist-db.org/exist/apps/doc/xforms.xml, >>>>if I understand correctly, says it should be activated out of the box. >>>>Did I miss anything? >>>> >>>> Regards, >>>> >>>>-- >>>> >>>>Florent Georges >>>>http://fgeorges.org/ >>>>http://h2oconsulting.be/ >>>> >>>> >>>> >>>> >>>> >>>> >>>>Le Vendredi 1 novembre 2013 1h56, Loren Cahlander <lor...@gm...> a écrit : >>>> >>>>With betterFORM: >>>>> >>>>> >>>>>Create the directory upload in the webapp directory on the server. >>>>> >>>>> >>>>>Use something like the following as a page in the app (Please note that I am using bootstrap 3.0 instead of the 2.x that comes with exist.): >>>>> >>>>> >>>>><divxmlns="http://www.w3.org/1999/xhtml"xmlns:ev="http://www.w3.org/2001/xml-events"xmlns:xf="http://www.w3.org/2002/xforms"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"data-template="templates:surround"data-template-with="templates/page2.html"data-template-at="content"data-template-options="noscript=yes"> >>>>> <xf:modelid="up"> >>>>> <xf:instancexmlns=""> >>>>> <data> >>>>> <filefilename=""mediatype=""size=""/> >>>>> </data> >>>>> </xf:instance> >>>>> <xf:bindnodeset="/data/file"type="xs:anyURI"/> >>>>> <xf:submissionid="load"resource="upload"method="put"replace="none"ref="/"> >>>>> <xf:messageev:event="xforms-submit-error"level="ephemeral">An error occurred.</xf:message> >>>>> <xf:loadev:event="xforms-submit-done"resource="foo.html"show="new"/> >>>>> </xf:submission> >>>>> </xf:model> >>>>> <divclass="row-fluid"> >>>>> <divclass="col-lg-1"> </div> >>>>> <divclass="col-lg-9"> >>>>> <divclass="page-header"> >>>>> <h1data-template="config:app-title">Generated page</h1> >>>>> </div> >>>>> <divclass="alert alert-success"> >>>>> <p> >>>>> <adata-template="templates:load-source"href="index.html">This</a>is the entry >>>>> page into your application and was generated by eXide. It uses HTML templates >>>>> for a clean separation of HTML views and application logic.</p> >>>>> <p>To add your own template functions, start by editing the XQuery module <adata-template="templates:load-source"href="modules/app.xql">app.xql</a>.</p> >>>>> </div> >>>>> <divclass="row-fluid"> >>>>> <divclass="col-lg-6"> >>>>> <xf:groupmodel="up"> >>>>> <xf:uploadref="//file"> >>>>> <xf:filenameref="@filename"/> >>>>> <xf:mediatyperef="@mediatype"/> >>>>> <xf:sizeref="@size"/> >>>>> <xf:sendev:event="xforms-value-changed"submission="load"/> >>>>> </xf:upload> >>>>> <br/> >>>>> <xf:outputref="//file/@filename"> >>>>> <xf:label>File: </xf:label> >>>>> </xf:output> >>>>> <br/> >>>>> <xf:outputref="//file/@mediatype"> >>>>> <xf:label>Media: </xf:label> >>>>> </xf:output> >>>>> <br/> >>>>> <xf:outputref="//file/@size"> >>>>> <xf:label>Size: </xf:label> >>>>> </xf:output> >>>>> <br/> >>>>> <xf:outputref="//file"> >>>>> <xf:label>Content: </xf:label> >>>>> </xf:output> >>>>> </xf:group> >>>>> </div> >>>>> <divclass="col-lg-6"/> >>>>> </div> >>>>> </div> >>>>> </div> >>>>></div> >>>>> >>>>> >>>>> >>>>> >>>>>I have the following as a RestXQ function: >>>>> >>>>> >>>>>(:~ >>>>> : List all addresses and return them as XML. >>>>> :) >>>>>declare >>>>> %rest:PUT("{$content}") >>>>> %rest:path("/upload") >>>>> %rest:produces("application/xml", "text/xml") >>>>>function foo:upload-document($content as node()*) { >>>>> let $upload-path := util:unescape-uri($content/data/file/text(), "UTF-8") >>>>> return mvf:move-to-db(sutil:schema-dir('working'), $upload-path) >>>>>}; >>>>> >>>>> >>>>> >>>>> >>>>>I use a separate function module that moves the file from the filesystem to the database, because the file function module requires a DBA user to access the filesystem. >>>>> >>>>> >>>>>declare function f:move-to-db($collection as xs:string, $path as xs:string) >>>>>{ >>>>> let $segment := substring-after($path, 'upload/') >>>>> return system:as-user('admin', 'password', >>>>> try { >>>>> let $file-path := concat(system:get-exist-home(), '/webapp/upload/', $segment) >>>>> let $exists := file:exists($file-path) >>>>> return if ($exists) >>>>> then >>>>> let $contents := util:parse(file:read($file-path)) >>>>> let $stored := xmldb:store($collection, substring-after($segment, '/'), $contents) >>>>> let $deleted := file:delete($file-path) >>>>> return $contents >>>>> else () >>>>> } catch * { >>>>> () >>>>> }) >>>>>}; >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>>On Oct 31, 2013, at 2:29 PM, Florent Georges <li...@fg...> wrote: >>>>> >>>>> Hi, >>>>>> >>>>>> Still using the new web application framework, as eXide provides >>>>>>support for, I'd like to add a simple form for uploading a text >>>>>>file, which should trigger a query (the text file being the input >>>>>>of the query: it is a CSV and the query must parse it and add >>>>>>corresponding XML elements to the database). >>>>>> >>>>>> I am not sure what is the idiomatic solution here, in the new >>>>>>framework. What action should be the target of the form? What is >>>>>>the idiomatic way to implement it? >>>>>> >>>>>> Regards, >>>>>> >>>>>>-- >>>>>>Florent Georges >>>>>>http://fgeorges.org/ >>>>>>http://h2oconsulting.be/ >>>>>> >>>>>>------------------------------------------------------------------------------ >>>>>>Android is increasing in popularity, but the open development platform that >>>>>>developers love is also attractive to malware creators. Download this white >>>>>>paper to learn more about secure code signing practices that can help keep >>>>>>Android apps secure. >>>>>>http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk >>>>>>_______________________________________________ >>>>>>Exist-open mailing list >>>>>>Exi...@li... >>>>>>https://lists.sourceforge.net/lists/listinfo/exist-open >>>>>> >>>>> >>>>> >>>>> >>> >>> >>> > > > |