Uses an XQuery language expression to query an XML document.

Syntax

<xquery>
    [<xq-param name="xquery_param_name" [type="xquery_param_type"]>
        body as xquery parameter value
    </xq-param>] *
    <xq-expression>
        body as xquery language construct
    </xq-expression>
</xquery>

Attributes

Name Required Default Description
name yes Name of XQuery parameter
type no node() Type of XQuery parameter - one of the values: node(), integer, long, float, double, boolean, string, node()*, integer*, long*, float*, double*, boolean*, string*.

It is allowed to optionally specify multiple external parameters for the query. In most cases at least one, containing XML document is needed. For every specified xquery parameter the declaration inside the xq-expression in the form:
declare variable $<xquery_param_name> as <xquery_param_type> external;
is required in order to match the name and type of proceeded parameter. Valid parameter types supported by Web-Harvest are: node(), integer, long, float, double, boolean, string and analog sequence types: node()*, integer*, long*, float*, double*, boolean*, string*. If not specified, default XQuery parameter is node().

Example

<xquery>
    <xq-param name="doc">
        <html-to-xml>
            <http url="${sys.fullUrl(startUrl, articleUrl)}"/>
        </html-to-xml>
    </xq-param>
    <xq-expression><![CDATA[
        declare variable $doc as node() external;

        let $author := data($doc//div[@class="byline"])
        let $title := data($doc//h1)
        let $text := data($doc//div[@id="articleBody"])
            return
                <article>
                    <title>{$title}</title>
                    <author>{$author}</author>
                    <text>{$text}</text>
                </article>
    ]]></xq-expression>
</xquery>

The xquery is applied to the downloaded page resulting XML containing information about newspaper's articles.