Hi,
My program, under Orbeon 3.9, try to update a set of documents stored in eXist db. The query is built automaticaly for each document, then it is sent via a xforms submission. Here is the submission processor <p:processor name="oxf:unsafe-xslt"> <p:input name="data" href="#params"/> <p:input name="config"> <xforms:submission xsl:version="2.0" method="post" resource="{pipeline:property('oxf.fr.persistence.service.exist.uri')}/{/*/*/app}/{/*/*/form}/data" replace="instance"> <!-- Move resulting <document> element as root element --> <xforms:insert ev:event="xforms-submit-done" nodeset="/*" origin="/*/*[1]"/> <!-- Copy eXist error --> <xforms:action ev:event="xforms-submit-error"> <xforms:delete while="/*/*" nodeset="/*/*"/> <xforms:setvalue ref="/*" value="event('response-body')"/> <xforms:message level="xxforms:log-debug"><xforms:output value="event('response-body')"/></xforms:message> <!-- TODO: Propagate error to caller --> </xforms:action> </xforms:submission> </p:input> <p:output name="data" id="submission"/> </p:processor> Here is the xslt processor to build the query <p:processor name="oxf:xslt"> <p:input name="data" href="#archibus-result"/> <p:input name="query" href="../data-access/xquery/insert-user-info2.xml"/> <p:input name="config"> <xsl:stylesheet version="2.0" exclude-result-prefixes="oxf xxforms ev xforms pipeline p"> <xsl:import href="oxf:/oxf/xslt/utils/copy.xsl"/> <!-- Get query and apply templates --> <xsl:variable name="query" select="doc('input:query')"/> <xsl:variable name="instance" select="/*" as="element()"/> <xsl:template match="/"> <xsl:apply-templates select="$query/*"/> </xsl:template> <!-- Dynamically build where clause --> <xsl:template match="where"> $resource-id = "<xsl:value-of select="$instance/user/@doc"/>" </xsl:template> <!-- Dynamically build insert clause --> <xsl:template match="insert"> <info> <xsl:copy-of select="$instance/user/child::*[name() != 'name-last']"/> </info> </xsl:template> <!-- Dynamically build result clause --> <xsl:template match="result"> <result><doc id="{$instance/user/@doc}"/></result> </xsl:template> </xsl:stylesheet> </p:input> <p:output name="data" id="request"/> </p:processor> This processor parse this xml query file <exist:query xmlns:exist="http://exist.sourceforge.net/NS/exist"> <exist:text> <![CDATA[ xquery version "1.0"; declare namespace xmldb="http://exist-db.org/xquery/xmldb"; declare namespace request="http://exist-db.org/xquery/request"; declare namespace text="http://exist-db.org/xquery/text"; declare namespace util="http://exist-db.org/xquery/util"; let $doc := (for $resource in collection() let $resource-uri := document-uri($resource) let $collection-name := string-join(tokenize($resource-uri, '/')[position() lt last()], '/') let $resource-name := tokenize($resource-uri, '/')[last()] let $resource-id := tokenize($resource-uri, '/')[last() - 1] where exists($resource/*) and $resource-name = ('data.xml') and ]]><where/><![CDATA[ return document-uri($resource)) let $toinsert := ]]><insert/><![CDATA[ let $insert := (update insert $toinsert into doc($doc)/form/internal) return ]]><result/><![CDATA[ ]]> </exist:text> </exist:query> and here is a query built for one document xquery version "1.0"; declare namespace xmldb="http://exist-db.org/xquery/xmldb"; declare namespace request="http://exist-db.org/xquery/request"; declare namespace text="http://exist-db.org/xquery/text"; declare namespace util="http://exist-db.org/xquery/util"; let $doc := (for $resource in collection() let $resource-uri := document-uri($resource) let $collection-name := string-join(tokenize($resource-uri, '/')[position() lt last()], '/') let $resource-name := tokenize($resource-uri, '/')[last()] let $resource-id := tokenize($resource-uri, '/')[last() - 1] where exists($resource/*) and $resource-name = ('data.xml') and $resource-id = "2c0f2f3fcc995ec25551b9bf494d2aad" return document-uri($resource)) let $insert := (update insert <info><dir-label>Direction Innovation et Outils</dir-label></info> into doc($doc)/form/internal) return <result><doc id="2c0f2f3fcc995ec25551b9bf494d2aad"/></result> When I test this query in the query dialog of the eXist java client administration tool, it works fine. The document is correctly updated. But when this query is sent via the xforms submission, it doesn't work. There is no error in orbeon log file, but an error message is generated in eXist log file : DEBUG (XQuery.java [compile]:144) - org.exist.xquery.XPathException: err:XPST0003 in line 20, column 53: unexpected token: doc I have tested that with eXist 1.4.2 and 2.0 tech-preview with same result. I don't see what could be wrong. I have posted the question in the eXist mailing list too, but could you help me ? Thanks. |
Administrator
|
Can you see with an HTTP monitor exactly what query is sent on the
wire to eXist? On OS X, we use HttpScoop. See: http://wiki.orbeon.com/forms/doc/developer-guide/admin/monitoring-http-requests That might help see if there is something wrong with the format of the query just before it reaches eXist. -Erik On Tue, Dec 4, 2012 at 6:54 AM, Olivier Thery <[hidden email]> wrote: > Hi, > > My program, under Orbeon 3.9, try to update a set of documents stored in > eXist db. The query is built automaticaly for each document, then it is sent > via a xforms submission. > > Here is the submission processor > > > > Here is the xslt processor to build the query > > > > This processor parse this xml query file > > > and here is a query built for one document > > > > When I test this query in the query dialog of the eXist java client > administration tool, it works fine. The document is correctly updated. > But when this query is sent via the xforms submission, it doesn't work. > There is no error in orbeon log file, but an error message is generated in > eXist log file : DEBUG (XQuery.java [compile]:144) - > org.exist.xquery.XPathException: err:XPST0003 in line 20, column 53: > unexpected token: doc > > I have tested that with eXist 1.4.2 and 2.0 tech-preview with same result. > I don't see what could be wrong. I have posted the question in the eXist > mailing list too, but could you help me ? > Thanks. > > > > -- > View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/xquery-xupdate-insert-problem-tp4656067.html > Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.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 > -- 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 |