<commit_before><!--
    Copyright (C) 2006 Orbeon, Inc.
  
    This program is free software; you can redistribute it and/or modify it under the terms of the
    GNU Lesser General Public License as published by the Free Software Foundation; either version
    2.1 of the License, or (at your option) any later version.
  
    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
    without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    See the GNU Lesser General Public License for more details.
  
    The full text of the license is available at http://www.gnu.org/copyleft/lesser.html
-->
<xhtml:html xmlns:xforms="http://www.w3.org/2002/xforms"
            xmlns:ev="http://www.w3.org/2001/xml-events"
            xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
            xmlns:f="http://orbeon.org/oxf/xml/formatting"
            xmlns:xhtml="http://www.w3.org/1999/xhtml"
            xmlns:xi="http://www.w3.org/2001/XInclude"
            xmlns:exist="http://exist.sourceforge.net/NS/exist">
    
    <xhtml:head>
        <xhtml:title>eXist Sandbox</xhtml:title>
        <xforms:model>

            <xforms:instance id="control-instance">
                <control xmlns="">
                    <operation>query</operation>
                    <resource>/db/</resource>
                    <query/>
                    <insert/>
                    <error/>
                    <formatted-result/>
                </control>
            </xforms:instance>

            <xforms:bind nodeset="instance('control-instance')">
                <xforms:bind nodeset="query" relevant="../operation = 'query'"/>
                <xforms:bind nodeset="insert" relevant="../operation = 'insert'"/>
                <xforms:bind nodeset="formatted-result"
                        calculate="if (instance('response-instance')/*)
                                   then xxforms:serialize(xxforms:call-xpl('oxf:/ops/utils/formatting/format.xpl', 'data', instance('response-instance')/*[1], 'data')/*, 'html')
                                   else ''"/>
            </xforms:bind>


            <xforms:instance id="query-instance">
                <exist:query><!-- start="first item to be returned"  max="max items to be returned" -->
                    <exist:text/>
                    <!--<exist:properties>-->
                        <!--<exist:property name="name1" value="value1"/>-->
                    <!--</exist:properties>-->
                </exist:query>
            </xforms:instance>

            <xforms:instance id="insert-instance">
                <exist:result/><!-- hits="2628" start="1" count="10" -->
            </xforms:instance>

            <xforms:instance id="response-instance">
                <exist:result/><!-- hits="2628" start="1" count="10" -->
            </xforms:instance>

            <xforms:instance id="delete-instance">
                <dummy/>
            </xforms:instance>

            <xforms:submission id="query-submission" ref="instance('query-instance')"
                               action="/exist/rest/{instance('control-instance')/resource}" method="post"
                               replace="instance" instance="response-instance"/>

            <xforms:submission id="insert-submission" ref="instance('insert-instance')"
                               action="/exist/rest/{instance('control-instance')/resource}" method="put"
                               replace="none"/>

            <xforms:submission id="delete-submission" ref="instance('delete-instance')"
                               action="/exist/rest/{instance('control-instance')/resource}" method="delete"
                               replace="none"/>

            <xforms:setvalue ev:event="xforms-submit-error" ref="instance('control-instance')/error" value="event('response-body')"/>
        </xforms:model>
        <xhtml:style type="text/css">
            .sandbox-url-input input { width: 30em }
            .xforms-label { margin-right: 1em }
            .query-div { background: #dde; border: 1px solid #336 }
        </xhtml:style>
    </xhtml:head>
    <xhtml:body>

        <xhtml:p>
            The eXist Sandbox uses the eXist REST API to perform Insert, Query and Delete operations.
        </xhtml:p>

        <xhtml:div>
            <xforms:output ref="instance('control-instance')/error" mediatype="text/html"/>
        </xhtml:div>

        <xforms:group>
            <xforms:setvalue ev:event="DOMFocusIn" ref="instance('control-instance')/error"/>

            <xhtml:div class="query-div">
                <xhtml:table>
                    <xhtml:tr>
                        <xhtml:td>
                            <xforms:select1 ref="instance('control-instance')/operation">
                                <xforms:label>Operation</xforms:label>
                                <xforms:item>
                                    <xforms:label>Insert</xforms:label>
                                    <xforms:value>insert</xforms:value>
                                </xforms:item>
                                <xforms:item>
                                    <xforms:label>Query</xforms:label>
                                    <xforms:value>query</xforms:value>
                                </xforms:item>
                                <!-- TODO -->
                                <!--<xforms:item>-->
                                    <!--<xforms:label>Update</xforms:label>-->
                                    <!--<xforms:value>update</xforms:value>-->
                                <!--</xforms:item>-->
                                <xforms:item>
                                    <xforms:label>Delete</xforms:label>
                                    <xforms:value>delete</xforms:value>
                                </xforms:item>
                            </xforms:select1>
                        </xhtml:td>
                        <xhtml:td>
                            <xhtml:span>
                                <xforms:input ref="instance('control-instance')/resource" class="sandbox-url-input">
                                    <xforms:label>Resource URL</xforms:label>
                                </xforms:input>
                            </xhtml:span>
                        </xhtml:td>
                        <xhtml:td>
                            <xforms:trigger class="sandbox-send-trigger">
                                <xforms:label>Send</xforms:label>
                                <xforms:action ev:event="DOMActivate">
                                    <xforms:send if="instance('control-instance')/operation = 'query'" submission="query-submission"/>
                                    <xforms:action if="instance('control-instance')/operation = 'insert'">
                                        <xforms:insert nodeset="instance('insert-instance')" origin="saxon:parse(instance('control-instance')/insert)/*"/>
                                        <xforms:send submission="insert-submission"/>
                                    </xforms:action>
                                    <xforms:send if="instance('control-instance')/operation = 'delete'" submission="delete-submission"/>
                                </xforms:action>
                            </xforms:trigger>
                        </xhtml:td>
                    </xhtml:tr>
                </xhtml:table>
            </xhtml:div>

            <xforms:group ref="instance('control-instance')/query" appearance="xxforms:fieldset">
                <xforms:label>XQuery to execute</xforms:label>
                <xforms:textarea ref="instance('query-instance')/exist:text" appearance="xxforms:autosize" incremental="true">
                    <xforms:label></xforms:label>
                </xforms:textarea>
            </xforms:group>

            <xforms:group ref="instance('control-instance')/insert" appearance="xxforms:fieldset">
                <xforms:label>Document to insert</xforms:label>
                <xforms:textarea ref="." appearance="xxforms:autosize" incremental="true">
                    <xforms:label></xforms:label>
                </xforms:textarea>
            </xforms:group>

            <xforms:group appearance="xxforms:fieldset">
                <xforms:label>Result</xforms:label>
                <xforms:output ref="instance('control-instance')/formatted-result" mediatype="text/html"/>
            </xforms:group>

        </xforms:group>
    </xhtml:body>
</xhtml:html><commit_msg>Set default query.<commit_after><!--
    Copyright (C) 2006 Orbeon, Inc.
  
    This program is free software; you can redistribute it and/or modify it under the terms of the
    GNU Lesser General Public License as published by the Free Software Foundation; either version
    2.1 of the License, or (at your option) any later version.
  
    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
    without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    See the GNU Lesser General Public License for more details.
  
    The full text of the license is available at http://www.gnu.org/copyleft/lesser.html
-->
<xhtml:html xmlns:xforms="http://www.w3.org/2002/xforms"
            xmlns:ev="http://www.w3.org/2001/xml-events"
            xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
            xmlns:f="http://orbeon.org/oxf/xml/formatting"
            xmlns:xhtml="http://www.w3.org/1999/xhtml"
            xmlns:xi="http://www.w3.org/2001/XInclude"
            xmlns:exist="http://exist.sourceforge.net/NS/exist">
    
    <xhtml:head>
        <xhtml:title>eXist Sandbox</xhtml:title>
        <xforms:model>

            <xforms:instance id="control-instance">
                <control xmlns="">
                    <operation>query</operation>
                    <resource>/db/orbeon/bookcast/data/</resource>
                    <query/>
                    <insert/>
                    <error/>
                    <formatted-result/>
                </control>
            </xforms:instance>

            <xforms:bind nodeset="instance('control-instance')">
                <xforms:bind nodeset="query" relevant="../operation = 'query'"/>
                <xforms:bind nodeset="insert" relevant="../operation = 'insert'"/>
                <xforms:bind nodeset="formatted-result"
                        calculate="if (instance('response-instance')/*)
                                   then xxforms:serialize(xxforms:call-xpl('oxf:/ops/utils/formatting/format.xpl', 'data', instance('response-instance')/*[1], 'data')/*, 'html')
                                   else ''"/>
            </xforms:bind>


            <xforms:instance id="query-instance">
                <exist:query><!-- start="first item to be returned"  max="max items to be returned" -->
                    <exist:text>&lt;report>
{
    for $foo in collection() return $foo//book
}
&lt;/report></exist:text>
                    <!--<exist:properties>-->
                        <!--<exist:property name="name1" value="value1"/>-->
                    <!--</exist:properties>-->
                </exist:query>
            </xforms:instance>

            <xforms:instance id="insert-instance">
                <exist:result/><!-- hits="2628" start="1" count="10" -->
            </xforms:instance>

            <xforms:instance id="response-instance">
                <exist:result/><!-- hits="2628" start="1" count="10" -->
            </xforms:instance>

            <xforms:instance id="delete-instance">
                <dummy/>
            </xforms:instance>

            <xforms:submission id="query-submission" ref="instance('query-instance')"
                               action="/exist/rest/{instance('control-instance')/resource}" method="post"
                               replace="instance" instance="response-instance"/>

            <xforms:submission id="insert-submission" ref="instance('insert-instance')"
                               action="/exist/rest/{instance('control-instance')/resource}" method="put"
                               replace="none"/>

            <xforms:submission id="delete-submission" ref="instance('delete-instance')"
                               action="/exist/rest/{instance('control-instance')/resource}" method="delete"
                               replace="none"/>

            <xforms:setvalue ev:event="xforms-submit-error" ref="instance('control-instance')/error" value="event('response-body')"/>
        </xforms:model>
        <xhtml:style type="text/css">
            .sandbox-url-input input { width: 30em }
            .xforms-label { margin-right: 1em }
            .query-div { background: #dde; border: 1px solid #336 }
        </xhtml:style>
    </xhtml:head>
    <xhtml:body>

        <xhtml:p>
            The eXist Sandbox uses the eXist REST API to perform Insert, Query and Delete operations.
        </xhtml:p>

        <xhtml:div>
            <xforms:output ref="instance('control-instance')/error" mediatype="text/html"/>
        </xhtml:div>

        <xforms:group>
            <xforms:setvalue ev:event="DOMFocusIn" ref="instance('control-instance')/error"/>

            <xhtml:div class="query-div">
                <xhtml:table>
                    <xhtml:tr>
                        <xhtml:td>
                            <xforms:select1 ref="instance('control-instance')/operation">
                                <xforms:label>Operation</xforms:label>
                                <xforms:item>
                                    <xforms:label>Insert</xforms:label>
                                    <xforms:value>insert</xforms:value>
                                </xforms:item>
                                <xforms:item>
                                    <xforms:label>Query</xforms:label>
                                    <xforms:value>query</xforms:value>
                                </xforms:item>
                                <!-- TODO -->
                                <!--<xforms:item>-->
                                    <!--<xforms:label>Update</xforms:label>-->
                                    <!--<xforms:value>update</xforms:value>-->
                                <!--</xforms:item>-->
                                <xforms:item>
                                    <xforms:label>Delete</xforms:label>
                                    <xforms:value>delete</xforms:value>
                                </xforms:item>
                            </xforms:select1>
                        </xhtml:td>
                        <xhtml:td>
                            <xhtml:span>
                                <xforms:input ref="instance('control-instance')/resource" class="sandbox-url-input">
                                    <xforms:label>Resource URL</xforms:label>
                                </xforms:input>
                            </xhtml:span>
                        </xhtml:td>
                        <xhtml:td>
                            <xforms:trigger class="sandbox-send-trigger">
                                <xforms:label>Send</xforms:label>
                                <xforms:action ev:event="DOMActivate">
                                    <xforms:send if="instance('control-instance')/operation = 'query'" submission="query-submission"/>
                                    <xforms:action if="instance('control-instance')/operation = 'insert'">
                                        <xforms:insert nodeset="instance('insert-instance')" origin="saxon:parse(instance('control-instance')/insert)/*"/>
                                        <xforms:send submission="insert-submission"/>
                                    </xforms:action>
                                    <xforms:send if="instance('control-instance')/operation = 'delete'" submission="delete-submission"/>
                                </xforms:action>
                            </xforms:trigger>
                        </xhtml:td>
                    </xhtml:tr>
                </xhtml:table>
            </xhtml:div>

            <xforms:group ref="instance('control-instance')/query" appearance="xxforms:fieldset">
                <xforms:label>XQuery to execute</xforms:label>
                <xforms:textarea ref="instance('query-instance')/exist:text" appearance="xxforms:autosize" incremental="true">
                    <xforms:label/>
                </xforms:textarea>
            </xforms:group>

            <xforms:group ref="instance('control-instance')/insert" appearance="xxforms:fieldset">
                <xforms:label>Document to insert</xforms:label>
                <xforms:textarea ref="." appearance="xxforms:autosize" incremental="true">
                    <xforms:label/>
                </xforms:textarea>
            </xforms:group>

            <xforms:group appearance="xxforms:fieldset">
                <xforms:label>Result</xforms:label>
                <xforms:output ref="instance('control-instance')/formatted-result" mediatype="text/html"/>
            </xforms:group>

        </xforms:group>
    </xhtml:body>
</xhtml:html>
{'fraction_non_alphanumeric': 0.13583463609518848, 'fraction_numerical': 0.006021654797058653, 'mean_word_length': 1.4720194647201947, 'pattern_counts': {'":': 0, '<': 300, '<?xml version=': 0, '>': 302, 'https://': 0, 'lorem ipsum': 0, 'www.': 10, 'xml': 22}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 34, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '664100', 'n_tokens_mistral': 4586, 'n_tokens_neox': 4255, 'n_words': 714}