viv:current-query
retrieves a copy of the current structured query
Synopsis
node viv:current-query (global, original, type); Boolean global; Boolean original; "system"|"user" type;
Description
Returns an operator node containing a copy of the current structured query.
Returns
- global: if true, returns the global query and not the one in the current context (e.g., the one passed in an add-sources).
- original: if true, returns the original query and not the one that has been transformed by query modification macros.
- type: when specified, only the terms related to the given type are returned. In general, when a query is presented to the user, it's good practice to use the user option for this parameter. This ignores all the parts of the query that a user does not have to be aware of (e.g., an implicit sorting option).
Example
Input Example:
<query>
<operator logic="and">
<term str="query1" field="query"/>
</operator>
</query>
<source name="ok">
Query2:
<value-of select="viv:current-query()/term/@str"/>
<query>
<operator logic="and">
<term str="query3" field="query"/>
</operator>
</query>
Query3:
<value-of select="viv:current-query(false())/term/@str"/>
Query1:
<value-of select="viv:current-query(true())/term/@str"/>
</source>
<add-sources names="ok">
<query>
<operator logic="and">
<term str="query2" field="query"/>
</operator>
</query>
</add-sources>
Query1:
<value-of select="viv:current-query()/term/@str"/>
Output Example:
<meta query=" query1 query2 query2 query3 "/>
<query>
<operator logic="and">
<term str="query1" field="query" processing="strict"/>
</operator>
</query>
<source name="ok">
Query2:
<value-of select="viv:current-query()/term/@str"/>
<query>
<operator logic="and">
<term str="query3" field="query"/>
</operator>
</query>
Query3:
<value-of select="viv:current-query(false())/term/@str"/>
Query1:
<value-of select="viv:current-query(true())/term/@str"/>
</source>
<added-source name="ok">
<query>
<operator logic="and">
<term str="query2" field="query" processing="strict"/>
</operator>
</query>
Query2: query2
<query>
<operator logic="and">
<term str="query3" field="query" processing="strict"/>
</operator>
</query>
Query3: query3
Query1: query1
</added-source>
Query1: query1