Hello All.

I have a code that looks something like this:

xquery version "1.0-ml";
module namespace amit = "http://www.amitgope.com/api/search-options";;
declare function load-common-constraints()
{
    <options xmlns="http://marklogic.com/appservices/search";>
        <!-- term options -->
        <term>
            <empty apply="no-results" />
            <term-option>case-insensitive</term-option>
        </term>

        <!-- search contraints -->
        <constraint name="doi">
            <value>
                <element ns="http://www.google.com/app/meta"; name="DOI"/>
            </value>
        </constraint>
    </options>
}
declare function load-unique-constraint()
{
<options xmlns="http://marklogic.com/appservices/search";>
        { *amit:load-common-constraints()/options/** }
        <operator name="sort">
            <state name="relevance">
                <sort-order>
                    <score/>
                </sort-order>
            </state>
            <state name="date">
                <sort-order direction="descending" type="xs:date"
collation="">
                    <element ns="http://www.amit.com/app/meta"; name="Date"/>
                </sort-order>
                <sort-order>
                    <score/>
                </sort-order>
            </state>
        </operator>
        <operator name="JournalOnlineFirst">
            <state name="true">
            </state>
        </operator>
        <!-- results options -->
        <return-metrics>false</return-metrics>
        <return-facets>true</return-facets>

<searchable-expression>/Publisher[.//JournalOnlineFirst]</searchable-expression>

        <!-- results transformation -->
        <transform-results apply="raw"/>

    </options>
}

I want the end option to be like this:
"<options xmlns="http://marklogic.com/appservices/search";>
        <!-- term options -->
        <term>
            <empty apply="no-results" />
            <term-option>case-insensitive</term-option>
        </term>

        <!-- search contraints -->
        <constraint name="doi">
            <value>
                <element ns="http://www.google.com/app/meta"; name="DOI"/>
            </value>
        </constraint>
<operator name="sort">
            <state name="relevance">
                <sort-order>
                    <score/>
                </sort-order>
            </state>
            <state name="date">
                <sort-order direction="descending" type="xs:date"
collation="">
                    <element ns="http://www.amit.com/app/meta"; name="Date"/>
                </sort-order>
                <sort-order>
                    <score/>
                </sort-order>
            </state>
        </operator>
        <operator name="JournalOnlineFirst">
            <state name="true">
            </state>
        </operator>
        <!-- results options -->
        <return-metrics>false</return-metrics>
        <return-facets>true</return-facets>

<searchable-expression>/Publisher[.//JournalOnlineFirst]</searchable-expression>

        <!-- results transformation -->
        <transform-results apply="raw"/>
    </options>
"
What modifications do i need to make to my code so that i end up only havin
one option node and the calling of the first function only gives its child
nodes. This option i will pass on to the search api so that i can fetch the
results based on the different conditions.
-- 
Regards
Amit
_______________________________________________
General mailing list
General@developer.marklogic.com
http://community.marklogic.com/mailman/listinfo/general

Reply via email to