IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

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
Expand all | Collapse all

help with xquery function

  • 1.  help with xquery function

    Posted Fri August 11, 2006 12:28 PM

    i am new to xquery and i am using it with Saxon on a derivative of FpML that is specific to my organisation ,and called IBML.

    i have written a very basic xquery function which is here

    
    xquery version "1.0";
    
    declare function local:order-val($po as element(trade))
    as element()* {
    return 
    $po/*:tradeHeader
    
    };
    local:order-val(//*:trade) 

    The actual xml(ibml) that i am running this query is

    
    <?xml version="1.0" encoding="UTF-8"?>
    <FpML xmlns="http://www.fpml.org/2005/FpML-4-2" 
    xmlns:ibml="http://ibml.jpmorgan.com/2005" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://ibml.jpmorgan.com/2005 C:/software/ibml141/IBML-1-4-1/xsd/IBML-1-4-1.xsd"
    xsi:type="ibml:CreateTradeRequest" 	
    version="4-2"
    ibmlVersion="1-1">	
    <header>
    <conversationId 
    conversationIdScheme="http://www.jpmorgan.com/coding-scheme/conversationId">EquityShare987</conversationId>
    <messageId 
    messageIdScheme="http://www.jpmorgan.com/coding-scheme/messageId">EquityShare456a789b</messageId>
    <sentBy 
    partyIdScheme="http://www.jpmorgan.com/coding-scheme/partyId">msdw</sentBy>
    <creationTimestamp>2000-08-01T08:57:00-00:00</creationTimestamp>
    </header>
    
    <trade>
    <tradeHeader>
    <partyTradeIdentifier>
    <partyReference href="PartyA"/>
    <tradeId 
    tradeIdScheme="http://www.PartyA.com/coding-scheme/tradeId">1234</tradeId>
    </partyTradeIdentifier>
    <tradeDate id="TradeDate">2005-07-13</tradeDate>
    </tradeHeader>
    <ibml:equityContract>
    <productType 
    productTypeScheme="http://ibml.jpmorgan.com/coding-scheme/product-type">Equity</productType>
    <buyerPartyReference href="PartyB"/>
    <sellerPartyReference href="PartyA"/>
    <ibml:numberOfUnits>10000</ibml:numberOfUnits>
    <ibml:unitPrice>
    <currency>USD</currency>
    <amount>78.20</amount>
    </ibml:unitPrice>
    <ibml:settlementDate>				
    <relativeDate>
    <periodMultiplier>3</periodMultiplier>
    <period>D</period>
    <dayType>Business</dayType>
    <businessDayConvention>NONE</businessDayConvention>
    <businessCenters>
    <businessCenter>EUTA</businessCenter>
    </businessCenters>
    <dateRelativeTo href="TradeDate"/>
    </relativeDate>
    </ibml:settlementDate>
    <ibml:settlementCurrency>USD</ibml:settlementCurrency>
    <ibml:equity>
    <instrumentId 
    instrumentIdScheme="http://www.reuters.com/coding-scheme/instrumentid">STM-FP</instrumentId>
    <description>STMicroelectronics N.V. ordinary shares</description>
    <exchangeId 
    exchangeIdScheme="http://www.fpml.org/schemes/4.1/exchangeId">NSE</exchangeId>
    </ibml:equity>
    </ibml:equityContract>
    </trade>
    
    <ibml:party id="PartyA">
    <partyId>Party A</partyId>
    </ibml:party>
    <ibml:party id="PartyB">
    <partyId>Party B</partyId>
    </ibml:party>
    
    </FpML>

    i get this error from saxon

    
    Error on line 6 column 3 
    XPST0003: XQuery syntax error in #...as element()* { return $po#:
    expected "}", found "$"
    Exception in thread "main" net.sf.saxon.trans.StaticError: One or more static errors were reported during query analysis
    at net.sf.saxon.query.QueryParser.parseQuery(QueryParser.java:260)
    at net.sf.saxon.query.QueryParser.makeXQueryExpression(QueryParser.java:103)
    at net.sf.saxon.query.StaticQueryContext.compileQuery(StaticQueryContext.java:475)
    at net.sf.saxon.query.StaticQueryContext.compileQuery(StaticQueryContext.java:505)
    at Test.main(Test.java:62)

    Can some one pls help with this.I am new to xquery and have hit this roadblock.


    #webMethods
    #API-Management
    #Tamino


  • 2.  RE: help with xquery function

    Posted Fri August 11, 2006 12:49 PM

    Hi Chetan,

    an XQuery function expression evaluates to what is provided within the
    function’s body, i.e. between the curly brackets. So the function does
    evaluate to something and not return something. Get rid of the ‘return’.

    Regards,
    Juliane.


    #Tamino
    #API-Management
    #webMethods