Hi
I would like to add a named file to an exist collection, eg filename.xml. To do this, I need to make use of the exist database xquery extensions, spefically xmldb:store The xquery below includes the xmldb:store function and will add a named file to the exist database, via the exist db xquery sandbox, however, when I use the same statement in the xmldb-query processor, the file is not inserted. Does anyone know what the problem might be? thank you for any assistance Tanya xquery: ====== declare namespace xmldb="http://exist-db.org/xquery/xmldb"; <result> { let $collection := collection('/db/g/config-files') for $name in ('status.xml') let $filename := $name let $contents := '<test><abc>abc</abc></test>' let $result := xmldb:store($collection, $filename, $contents) return <a>{$result}</a> } </result> xquery passed to xmldb-query processor: ================================= <p:processor name="oxf:xslt"> <p:input name="data" href="#data"/> <p:input name="config"> <xdb:query collection="/db/g/config-files" create-collection="true" xsl:version="2.0" > xquery version "1.0"; declare namespace xmldb="http://exist-db.org/xquery/xmldb"; <result> { let $collection := collection('/db/g/config-files') for $name in ('status.xml') let $filename := $name let $contents := '<test><abc>abc</abc></test>' let $result := xmldb:store($collection, $filename, $contents) return <a>{$result}</a> } </result> </xdb:query> </p:input> <p:output name="data" id="query" /> </p:processor> <!-- Run query and return document-info --> <p:processor name="oxf:xmldb-query"> <p:input name="datasource" href="datasource.xml"/> <p:input name="query" href="#query" /> <p:output name="data" id='query-result' /> </p:processor> -- This message (and any attachments) is for the recipient only. NERC is subject to the Freedom of Information Act 2000 and the contents of this email and any reply you make may be disclosed by NERC unless it is exempt from release under the Act. Any material supplied to NERC may be stored in an electronic records management system. -- 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 ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Hi, as a follow up to my last email, in case it is useful to anyone, the following xquery will stored a named file in an exist database:
<!-- Use special eXist functions --> <p:processor name="oxf:unsafe-xslt"> <p:input name="data" href="#data"/> <p:input name="config"> <xdb:query collection="/db/g/config-files" create-collection="false" xsl:version="2.0"> xquery version "1.0"; <result> { xmldb:store(collection('/db/g/config-files'), 'status.xml', '<xsl:copy-of select="/form/containers"/>') } </result> </xdb:query> </p:input> <p:output name="data" id="xmldb-query"/> </p:processor> <p:processor name="oxf:xmldb-query"> <p:input name="datasource" href="datasource.xml"/> <p:input name="query" href="#xmldb-query"/> </p:processor> >>> Tanya Gray 08/14/06 6:04 PM >>> Hi I would like to add a named file to an exist collection, eg filename.xml. To do this, I need to make use of the exist database xquery extensions, spefically xmldb:store The xquery below includes the xmldb:store function and will add a named file to the exist database, via the exist db xquery sandbox, however, when I use the same statement in the xmldb-query processor, the file is not inserted. Does anyone know what the problem might be? thank you for any assistance Tanya xquery: ====== declare namespace xmldb="http://exist-db.org/xquery/xmldb"; <result> { let $collection := collection('/db/g/config-files') for $name in ('status.xml') let $filename := $name let $contents := '<test><abc>abc</abc></test>' let $result := xmldb:store($collection, $filename, $contents) return <a>{$result}</a> } </result> xquery passed to xmldb-query processor: ================================= <p:processor name="oxf:xslt"> <p:input name="data" href="#data"/> <p:input name="config"> <xdb:query collection="/db/g/config-files" create-collection="true" xsl:version="2.0" > xquery version "1.0"; declare namespace xmldb="http://exist-db.org/xquery/xmldb"; <result> { let $collection := collection('/db/g/config-files') for $name in ('status.xml') let $filename := $name let $contents := '<test><abc>abc</abc></test>' let $result := xmldb:store($collection, $filename, $contents) return <a>{$result}</a> } </result> </xdb:query> </p:input> <p:output name="data" id="query" /> </p:processor> <!-- Run query and return document-info --> <p:processor name="oxf:xmldb-query"> <p:input name="datasource" href="datasource.xml"/> <p:input name="query" href="#query" /> <p:output name="data" id='query-result' /> </p:processor> -- This message (and any attachments) is for the recipient only. NERC is subject to the Freedom of Information Act 2000 and the contents of this email and any reply you make may be disclosed by NERC unless it is exempt from release under the Act. Any material supplied to NERC may be stored in an electronic records management system. -- 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 ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Administrator
|
Hi Tanya,
Thank you for this valuable information! I have updated the Wiki page talking about eXist support to include some of what you are saying. You can have a look at it by following the link below (look for "Create a Named File" towards the bottom of the page). And of course, please feel free to correct any error you see, or to update this page as you deem reasonable. https://wiki.objectweb.org/ops/Wiki.jsp?page=EXist Alex On 8/15/06, Tanya Gray <[hidden email]> wrote: > Hi, as a follow up to my last email, in case it is useful to anyone, the following xquery will stored a named file in an exist database: > > <!-- Use special eXist functions --> > <p:processor name="oxf:unsafe-xslt"> > <p:input name="data" href="#data"/> > <p:input name="config"> > <xdb:query collection="/db/g/config-files" create-collection="false" xsl:version="2.0"> > xquery version "1.0"; > <result> > { > > xmldb:store(collection('/db/g/config-files'), 'status.xml', '<xsl:copy-of select="/form/containers"/>') > } > </result> > </xdb:query> > </p:input> > <p:output name="data" id="xmldb-query"/> > </p:processor> > > <p:processor name="oxf:xmldb-query"> > <p:input name="datasource" href="datasource.xml"/> > <p:input name="query" href="#xmldb-query"/> > </p:processor> > > > > > > > >>> Tanya Gray 08/14/06 6:04 PM >>> > Hi > > I would like to add a named file to an exist collection, eg filename.xml. To do this, I need to make use of the exist database xquery extensions, spefically xmldb:store > > The xquery below includes the xmldb:store function and will add a named file to the exist database, via the exist db xquery sandbox, however, when I use the same statement in the xmldb-query processor, the file is not inserted. > > Does anyone know what the problem might be? > > thank you for any assistance > Tanya > > > xquery: > ====== > > declare namespace xmldb="http://exist-db.org/xquery/xmldb"; > > <result> > > { > let $collection := collection('/db/g/config-files') > > for $name in ('status.xml') > > let $filename := $name > let $contents := '<test><abc>abc</abc></test>' > let $result := xmldb:store($collection, $filename, $contents) > > return <a>{$result}</a> > > } > </result> > > > > xquery passed to xmldb-query processor: > ================================= > > <p:processor name="oxf:xslt"> > <p:input name="data" href="#data"/> > <p:input name="config"> > > <xdb:query collection="/db/g/config-files" create-collection="true" > xsl:version="2.0" > > xquery version "1.0"; > > declare namespace xmldb="http://exist-db.org/xquery/xmldb"; > > <result> > > { > let $collection := collection('/db/g/config-files') > > for $name in ('status.xml') > > let $filename := $name > let $contents := '<test><abc>abc</abc></test>' > let $result := xmldb:store($collection, $filename, $contents) > > return <a>{$result}</a> > > } > </result> > > > > </xdb:query> > </p:input> > <p:output name="data" id="query" /> > </p:processor> > > > > <!-- Run query and return document-info --> > <p:processor name="oxf:xmldb-query"> > <p:input name="datasource" href="datasource.xml"/> > <p:input name="query" href="#query" /> > <p:output name="data" id='query-result' /> > </p:processor> > > > > > > > -- > This message (and any attachments) is for the recipient only. NERC > is subject to the Freedom of Information Act 2000 and the contents > of this email and any reply you make may be disclosed by NERC unless > it is exempt from release under the Act. Any material supplied to > NERC may be stored in an electronic records management system. > > > > > > -- > 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 > ObjectWeb mailing lists service home page: http://www.objectweb.org/wws > > > -- Blog (XML, Web apps, Open Source): http://www.orbeon.com/blog/ -- 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 ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
In reply to this post by Tanya Gray (Oxford)
Wouldn't the use of "xmldb:store(collection('/db/g/config-files'), 'status.xml', '<xsl:copy-of select="/form/containers"/>')" be potentially unsafe? I mean, the /form/containers could contain an apostrophe and would close your string inadvertently once it comes out of the transformation, no?
|
Free forum by Nabble | Edit this page |