Hi,
I would like to present a summary of reports in an eXist database, ordered by a user-defined element, and then return only a subset of these reports (allow paging of results). The number of reports that are queried exceeds 1500, and I would like to limit the XML transferred to the client. The following XQuery facilitates paging of results, however the $pos variable refers to the original position of the record in the collection and not the position of the record after it has been ordered by the selected element. Is it is possible to retrieve the position of a record in a recordset, after it has been ordered, or is it necessary to select all records and then use the XSLT processor to retrieve records with the required position() value? thank you for any info Tanya ********************************************************************************************* <xdb:query collection="/db/{$db-name}/reports" create-collection="true" xmlns:xmldb="http://exist-db.org/xquery/xmldb" xmlns:util="http://exist-db.org/xquery/util" > xquery version "1.0"; declare namespace fn='http://www.w3.org/2005/02/xpath-functions'; declare namespace xmldb='http://exist-db.org/xquery/xmldb'; <result > { for $x at $pos in /* <xsl:value-of select='$order-by'/> return if (($pos gt <xsl:value-of select='$from'/>) and ($pos lt <xsl:value-of select='$to'/>)) then <report> <xsl:for-each select="doc('input:config-options')//report-summary/elements/element"> { $x//*[name() = '<xsl:value-of select = "."/>']} </xsl:for-each> <author>{doc('/db/<xsl:value-of select='$db-name'/>/user-accounts/Users.xml')//user[user-activity/report/@document-id= util:document-name($x)]/user-record/username/text()}</author> <filename label='Filename'>{util:document-name($x)}</filename> <date-modified>{xmldb:last-modified('/db/<xsl:value-of select='$db-name'/>/reports', util:document-name($x))}</date-modified> <position>{$pos}</position> </report> else <null/> } </result> </xdb:query> **************************************************************************************** -- 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 |
Free forum by Nabble | Edit this page |