Skip to content
mgladkova edited this page Nov 14, 2015 · 4 revisions

MwsQuery is the raw query method that the MathWebSearch system can process. It is not a query language at its basis, but rather an extension of MathML which introduces a few query specific tags and attributes.

The introduced tags are query, expr and qvar, all defined in the mws namespace. The root element of a MwsQuery is always a mws:query and it can take the following attributes:

  • limitmin - offset within the range of solutions (INT)
  • answsize - the maximum number of solutions to be returned (INT)
  • totalreq - boolean showing if a total count is requested besides the specified number of solutions ("yes"/"no")
  • output - format of the MwsAnswerSet ("xml"|"json")

The children of a mws:query are mws:expr nodes which contain the actual Math, encoded as ContentMathML. The important addition is that within the ContentMathML, one can freely use mws:qvar tags to specify universal variables. Note that the text content of a mws:qvar is considered its name and qvars with the same name will match to the same expressions.

The children of a mws:query are mws:expr nodes which contain the actual Math, encoded as ContentMathML. The important addition is that within the ContentMathML, one can freely use mws:qvar tags to specify universal variables. Note that the text content of a mws:qvar is considered its name and qvars with the same name will match to the same expressions.

Here are a few MwsQuery examples:

<?xml version="1.0" ?>
<!--
    Query for operators of arity 3, having first 2 parameters equal.
    -->
<mws:query
  xmlns:mws="http://www.mathweb.org/mws/ns"
  xmlns:m="http://www.w3.org/1998/Math/MathML"
  limitmin="0"
  answsize="30"
  totalreq="yes"
  output="json"
  >
    <mws:expr>
        <m:apply>
            <mws:qvar>op</mws:qvar>
            <mws:qvar>x</mws:qvar>
            <mws:qvar>x</mws:qvar>
            <mws:qvar>y</mws:qvar>
        </m:apply>
    </mws:expr>
</mws:query>
<?xml version="1.0" ?>
<!--
    Query for all limits approaching 0.
    -->
<mws:query
  xmlns:mws="http://www.mathweb.org/mws/ns"
  xmlns:m="http://www.w3.org/1998/Math/MathML"
  limitmin="0"
  answsize="30"
  totalreq="yes"
  output="json"
  >
    <mws:expr>
        <m:apply>
            <m:apply>
                <m:csymbol cd="ambiguous">subscript</m:csymbol>
                <m:limit/>
                <m:apply>
                    <m:ci>→</m:ci>
                    <mws:qvar>x</mws:qvar>
                    <m:cn type="integer">0</m:cn>
                </m:apply>
            </m:apply>
            <mws:qvar>y</mws:qvar>
        </m:apply>
    </mws:expr>
</mws:query>
<?xml version="1.0" ?>
<!--
    Query for specific constant (δ_0)
    -->
<mws:query
  xmlns:mws="http://www.mathweb.org/mws/ns"
  xmlns:m="http://www.w3.org/1998/Math/MathML"
  limitmin="0"
  answsize="30"
  totalreq="yes"
  output="json"
  >
    <mws:expr>
        <m:apply>
            <m:csymbol cd="ambiguous">subscript</m:csymbol>
            <m:ci>δ</m:ci>
            <m:cn type="integer">0</m:cn>
        </m:apply>
    </mws:expr>
</mws:query>

Clone this wiki locally