DataPower

DataPower

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  Xquery

    Posted Mon January 11, 2021 10:17 AM

    Hi there,

    Could you please help me with below error, I am getting while executing xquery to fetch some values on xml. I am getting error when i am using AND in where query.

    PFB details related to xquery

    <xsl:variable name="xquery">

    for $x in RoutingConfiguration/Endpoint

    where $x/resource[='<xsl:value-of select="$methodVar" />'] '&amp' and $x/resource[='<xsl:value-of select="$uriVar"/>']

    return $x

    </xsl:variable>

    <dp:set-variable name="'var://context/xquery'" value="string($xquery)" />

    <xsl:copy-of select="dp:xquery-transform('var://context/xquery',$routingFileVar)" />

    Error- mpgw (Inbound_HMAC_MPGW): dp:xquery-transform(): Fatal Error at /temp_37897:3: [XPST0003] An expression is not a valid instance of the grammar defined for XQuery. Lexical analysis failed at column 104, Error detected at token: & Given the ampersand in quote delimited string content, expected a character reference. Ampersands can be escaped by using "&amp;".10:14:53 AMxqueryerror19443360192.168.1.780x80a002a0xmlmgr (Inbound_HMAC_XMLMgr): xformng: Request failed to compile. Fatal Error at /temp_37897:3: [XPST0003] An expression is not a valid instance of the grammar defined for XQuery. Lexical analysis failed at column 104, Error detected at token: & Given the ampersand in quote delimited string content, expected a character reference. Ampersands can be escaped by using "&amp;". Referenced by xa35://tmp/temp_37897.

    Many thanks



    #DataPower
    #Support
    #SupportMigration


  • 2.  RE: Xquery
    Best Answer

    Posted Tue January 12, 2021 10:21 PM

    I don't now what you want to achieve, but definitely it is no XQuery syntax. Removing "amp", this is valid XQuery 1.0 and compiles fine:

    for $x in RoutingConfiguration/Endpoint where $x/resource[='<xsl:value-of select="$methodVar" />'] and $x/resource[='<xsl:value-of select="$uriVar"/>'] return $x

    #DataPower
    #Support
    #SupportMigration


  • 3.  RE: Xquery
    Best Answer

    Posted Wed January 13, 2021 10:14 AM

    Hey Hermann,

    Thanks for reply.

    My bad I have tried with "and" only , since it was throwing error tried with &amp,

    My original query is below and error is below

    Query-:

    <xsl:variable name="xquery"> for $x in RoutingConfiguration/Endpoint where $x/resource[='<xsl:value-of select="$methodVar" />'] and $x/resource[='<xsl:value-of select="$uriVar"/>'] return $x </xsl:variable>

    Error-:

    mpgw (Inbound_HMAC_MPGW): dp:xquery-transform(): Fatal Error at /temp_44288:3: [XPST0003] An expression is not a valid instance of the grammar defined for XQuery. Lexical analysis failed at column 104, Error detected at token: & Given the ampersand in quote delimited string content, expected a character reference. Ampersands can be escaped by using "&amp;".10:10:25 AMxqueryerror21575168192.168.1.780x80a002a0xmlmgr (Inbound_HMAC_XMLMgr): xformng: Request failed to compile. Fatal Error at /temp_44288:3: [XPST0003] An expression is not a valid instance of the grammar defined for XQuery. Lexical analysis failed at column 104, Error detected at token: & Given the ampersand in quote delimited string content, expected a character reference. Ampersands can be escaped by using "&amp;". Referenced by xa35://tmp/temp_44288.

    DataPower version-:

    Serial0000000 VersionIDG.2018.4.1.11 Build320653 Build dateMay 6, 2020 7:35:59 PM Delivery typeLong-term support Watchdog buildIDG.2018.4.1.11 Installed DPOSIDG.2018.4.1.11 Running DPOSIDG.2018.4.1.11 XML acceleratorEmbedded Machine type5725 Model typeT09



    #DataPower
    #Support
    #SupportMigration


  • 4.  RE: Xquery
    Best Answer

    Posted Wed January 13, 2021 01:09 PM

    The error messag does not match your changed Query -- there is no ampersand in the Xquery. You have not updated where needed, obviously the previous Xquery got processed and emitted that ampersand error



    #DataPower
    #Support
    #SupportMigration


  • 5.  RE: Xquery
    Best Answer

    Posted Wed January 13, 2021 04:30 PM

    Hey Hermann,


    Further analyzing the problem, I found out, this error I get only Whenever I am using GET operation from Client(with query parameter ). For POST operation it works fine.



    I am calling the as a template. Don't know where it is getting GET "&" in the xquery


    <xsl:variable name="queryResult">

    <xsl:call-template name="FetchRoutingInfo">

    <xsl:with-param name="methodVar" select="$operation" />

    <xsl:with-param name="uriVar" select="$URI" />

    <xsl:with-param name="routingFileVar" select="$confFileRoute" />

    </xsl:call-template>

    </xsl:variable>




    <xsl:template name="FetchRoutingInfo">

    <xsl:param name="methodVar" />

    <xsl:param name="uriVar" />

    <xsl:param name="routingFileVar" />

    <xsl:variable name="xquery">

    for $x in RoutingConfiguration/Endpoint

    where $x/resource[='<xsl:value-of select="$methodVar" />'] and $x/resource[='<xsl:value-of select="$uriVar"/>']

    return $x

    </xsl:variable>

    <dp:set-variable name="'var://context/xquery'" value="string($xquery)" />

    <xsl:copy-of select="dp:xquery-transform('var://context/xquery',$routingFileVar)" />

    </xsl:template>



    Many thanks


    Sumit Kanojia





    #DataPower
    #Support
    #SupportMigration


  • 6.  RE: Xquery
    Best Answer

    Posted Wed January 13, 2021 10:00 PM

    Issue solved Now,


    I was sending the var://service/URI in parameter which had & in query, not the updated variable with modified URI without &,


    Thanks Hermann.






    #DataPower
    #Support
    #SupportMigration