opensubscriber
   Find in this group all groups
 
Unknown more information…

o : ops-users@objectweb.org 15 August 2006 • 6:02PM -0400

[ops-users] Re: xmldb:store & xmldb-query
by Tanya Gray

REPLY TO AUTHOR
 
REPLY TO GROUP




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.



Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.