Saved Query XML Schema Definition

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:element name="query">
        <xs:annotation>
            <xs:documentation>Save Query root element</xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="executeACL" minOccurs="0">
                    <xs:annotation>
                        <xs:documentation>Specifies which user or group can execute the saved query</xs:documentation>
                    </xs:annotation>
                    <xs:simpleType>
                        <xs:restriction base="xs:string">
                            <xs:minLength value="1"/>
                        </xs:restriction>
                    </xs:simpleType>
                </xs:element>
                <xs:element name="store" minOccurs="0">
                    <xs:annotation>
                        <xs:documentation>Specifies to which store the saved query applies</xs:documentation>
                    </xs:annotation>
                    <xs:simpleType>
                        <xs:restriction base="xs:string">
                            <xs:minLength value="1"/>
                        </xs:restriction>
                    </xs:simpleType>
                </xs:element>
                <xs:element name="condition" minOccurs="0">
                    <xs:annotation>
                        <xs:documentation>The saved query condition in apsdb syntax</xs:documentation>
                    </xs:annotation>
                    <xs:simpleType>
                        <xs:restriction base="xs:string">
                            <xs:minLength value="1"/>
                        </xs:restriction>
                    </xs:simpleType>
                </xs:element>
                <xs:element name="ftsQuery" minOccurs="0">
                    <xs:annotation>
                        <xs:documentation>Set in case the user wants to run a full text search</xs:documentation>
                    </xs:annotation>
                    <xs:simpleType>
                        <xs:restriction base="xs:string">
                            <xs:minLength value="1"/>
                        </xs:restriction>
                    </xs:simpleType>
                </xs:element>
                <xs:element name="returnedFields" minOccurs="0">
                    <xs:annotation>
                        <xs:documentation>Specifies which fields should be returned in result</xs:documentation>
                    </xs:annotation>
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="field" maxOccurs="unbounded">
                                <xs:simpleType>
                                    <xs:restriction base="xs:string">
                                        <xs:minLength value="1"/>
                                    </xs:restriction>
                                </xs:simpleType>
                            </xs:element>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
                <xs:element name="sort" minOccurs="0">
                    <xs:annotation>
                        <xs:documentation>Specifies on which field the sorting should be done, and the type and order of the sorting(ascending or descending) </xs:documentation>
                    </xs:annotation>
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="field" maxOccurs="unbounded">
                                <xs:complexType>
                                    <xs:sequence>
                                        <xs:element name="name">
                                            <xs:simpleType>
                                                <xs:restriction base="xs:string">
                                                    <xs:minLength value="1"/>
                                                </xs:restriction>
                                            </xs:simpleType>
                                        </xs:element>
                                        <xs:element name="type">
                                            <xs:simpleType>
                                                <xs:restriction base="xs:string">
                                                    <xs:minLength value="1"/>
                                                </xs:restriction>
                                            </xs:simpleType>
                                        </xs:element>
                                        <xs:element name="order">
                                            <xs:annotation>
                                                <xs:documentation>ASC(ascending) or DESC(descending)</xs:documentation>
                                            </xs:annotation>
                                            <xs:simpleType>
                                                <xs:restriction base="xs:string">
                                                    <xs:minLength value="1"/>
                                                    <xs:enumeration value="ASC"/>
                                                    <xs:enumeration value="DESC"/>
                                                </xs:restriction>
                                            </xs:simpleType>
                                        </xs:element>
                                    </xs:sequence>
                                </xs:complexType>
                            </xs:element>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
                <xs:element name="count" minOccurs="0">
                    <xs:annotation>
                        <xs:documentation>Specifies the number of records that match the query</xs:documentation>
                    </xs:annotation>
                    <xs:complexType>
                        <xs:simpleContent>
                            <xs:extension base="xs:string"/>
                        </xs:simpleContent>
                    </xs:complexType>
                </xs:element>
                <xs:element name="aggregate" minOccurs="0">
                    <xs:annotation>
                        <xs:documentation>Allows the user to execute an aggregate function on the results returned by his query request</xs:documentation>
                    </xs:annotation>
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="expression">
                                <xs:simpleType>
                                    <xs:restriction base="xs:string">
                                        <xs:minLength value="1"/>
                                    </xs:restriction>
                                </xs:simpleType>
                            </xs:element>
                            <xs:element name="page" type="xs:boolean" minOccurs="0">
                                <xs:annotation>
                                    <xs:documentation>Defines the page number of the page to return in case there is more than one</xs:documentation>
                                </xs:annotation>
                            </xs:element>
                            <xs:element name="global" type="xs:boolean" minOccurs="0">
                                <xs:annotation>
                                    <xs:documentation>Specifies if the aggregate function should be executed on all the documents returned by the condition</xs:documentation>
                                </xs:annotation>
                            </xs:element>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
                <xs:element name="runAs" minOccurs="0">
                    <xs:annotation>
                        <xs:documentation>It allows the owner to run a service as one of his own users</xs:documentation>
                    </xs:annotation>
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="user">
                                <xs:simpleType>
                                    <xs:restriction base="xs:string">
                                        <xs:minLength value="1"/>
                                    </xs:restriction>
                                </xs:simpleType>
                            </xs:element>
                            <xs:element name="deniedFields" type="xs:boolean" minOccurs="0">
                                <xs:annotation>
                                    <xs:documentation>Gives the owner the possibility to request the denied fields for the runAs user</xs:documentation>
                                </xs:annotation>
                            </xs:element>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
                <xs:element name="resultsPerPage" type="xs:positiveInteger" minOccurs="0">
                    <xs:annotation>
                        <xs:documentation>Determines the number of results per page to return</xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="forceCurrentSnapShot" type="xs:boolean" minOccurs="0">
                    <xs:annotation>
                        <xs:documentation>In order to avoid data inconsistency, even for a short duration of time, 
                                            the user can send this parameter with value "true" to query data from the master database server.
                                            Will query from slave database server if the value is set to "false" </xs:documentation>
                    </xs:annotation>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

Saved Query Example

<query> 
      <executeACL>creator</executeACL> 
      <store>testStore</store> 
      <condition><![CDATA[ startingDate<date>={startdate}]]></condition>
      <returnedFields> 
           <field>firstName</field> 
           <field>lastName </field> 
      </returnedFields> 
      <count>true</count> 
      <resultsPerPage>10</resultsPerPage> 
</query>