OSB: xquery as input to xquery

Hi
i have stored an xml as xquery. <customer><name>swa</name><name>neh</name></customer>
i have written another xquery (named result.xquery) which takes input from above xml and produces result. ex: if (data($customer/name)='swa' then 'osb' else '')
i am assigning customer.xquery to a variable CUSTOMER and applying result transformation.
since my xml (customer.xquery) is static and reside within OSB only, can i pass it to result.xquery without assigning it to CUSTOMER.
In short can I pass an xquery as an input to another xquery?
p.s.: Issue may seem trivial, but in my case i need to get quite a lot static xmls in code and i am instructed not to use java callout.

In short can I pass an xquery as an input to another xquery?No. You cannot do so.
i am assigning customer.xquery to a variable CUSTOMER and applying result transformation.Actually when you are assigning a XQuery into variable then OSB internally executes the XQuery and assigns the output of XQuery to the variable. So your variable does not actually hold the reference of the XQuery rather it holds the output of XQuery which you are passing as input to another XQuery.
You may consider storing mappings into DB and use result caching feature with JCA DB adapter BS to retrieve the mapping's value at runtime.
Regards,
Anuj

Similar Messages

  • In OSB , xquery issue with large volume data

    Hi ,
    I am facing one problem in xquery transformation in OSB.
    There is one xquery transformation where I am comparing all the records and if there are similar records i am clubbing them under same first node.
    Here i am reading the input file from the ftp process. This is perfectly working for the small size input data. When there is large input data then also its working , but its taking huge amount of time and the file is moving to error directory and i see the duplicate records created for the same input data. I am not seeing anything in the error log or normal log related to this file.
    How to check what is exactly causing the issue here,  why it is moving to error directory and why i am getting duplicate data for large input( approx 1GB).
    My Xquery is something like below.
    <InputParameters>
                    for $choice in $inputParameters1/choice              
                     let $withSamePrimaryID := ($inputParameters1/choice[PRIMARYID eq $choice/PRIMARYID])                
                     let $withSamePrimaryID8 := ($inputParameters1/choice[FIRSTNAME eq $choice/FIRSTNAME])
                     return
                      <choice>
                     if(data($withSamePrimaryID[1]/ClaimID) = data($withSamePrimaryID8[1]/ClaimID)) then
                     let $claimID:= $withSamePrimaryID[1]/ClaimID
                     return
                     <ClaimID>{$claimID}</ClaimID>                
                     else
                     <ClaimID>{ data($choice/ClaimID) }</ClaimID>

    HI ,
    I understand your use case is
    a) read the file ( from ftp location.. txt file hopefully)
    b) process the file ( your x query .. although will not get into details)
    c) what to do with the file ( send it backend system via Business Service?)
    Also noted the files with large size take long time to be processed . This depends on the memory/heap assigned to your JVM.
    Can say that is expected behaviour.
    the other point of file being moved to error dir etc - this could be the error handler doing the job ( if you one)
    if no error handlers - look at the timeout and error condition scenarios on your service.
    HTH

  • OSB - XQuery - line 7, col 2: {err}FORG0005: expected exactly 1 item, got 0

    Hi,
    I am trying to execute the below sample XQuery. Eclipse designer does not show any error. However on executing the XQuery, I get the following error "+Error executing the XQuery transformation: line 7, column 2: {err}FORG0005: expected exactly one item, got 0 items+". Appreciate your help.
    xquery version "1.0" encoding "UTF-8";
    declare namespace xf = "http://tempuri.org/OSB%20Project%201/Ids/";
    declare function xf:Ids()
    as element() {*
    *     let $abc := <catalog><product dept="MEN"><number>784</number><name language="en">Cotton Dress Shirt</name><colorChoices>white gray</colorChoices><desc>Our favorite shirt!</desc></product></catalog>*
    *     for $product in $abc/catalog/product*
    *     let $name := $product/name*
    *     where $product/@dept = "ACC"*
    *     order by $name*
    *     return $name*
    xf:Ids()

    Thanks, for the answer.
    I just tweeked my XQuery:Var = $abc a little and ended up with same issue. Request your help again.
    xquery version "1.0" encoding "UTF-8";
    declare namespace xf = "http://tempuri.org/OSB%20Project%201/Ids/";
    declare function xf:Ids() as element(*)? {
    let $abc := +<catalog><product dept="MEN" xmlns="http://datypic.com/prod"><number>784</number><name language="en">Cotton Dress Shirt</name><colorChoices>white gray</colorChoices><desc>Ou<i>favorite</i> shirt! </desc></product><product dept="ACC"><number>563</number><name language="en">Floppy Sun Hat</name></product><product dept="ACC"><number>443</number><name language="en">Deluxe Travel Bag</name></product><product dept="MEN"><number>784</number><name language="en">Cotton Dress Shirt</name><colorChoices>white gray</colorChoices><desc>Ou<i>favorite</i> shirt! </desc></product><product dept="WMN"><number>557</number><name language="en">Fleece Pullover</name><colorChoices>navy black</colorChoices></product></catalog>+
    --(:<catalog><product dept="ACC"><number>784</number><name language="en">Cotton Dress Shirt</name><colorChoices>white gray</colorChoices><desc>Our favorite shirt!</desc></product></catalog>:)--
    for $product in $abc/product
    let $name := $product/name
    where $product/@dept = "ACC"
    order by $name
    return $name
    xf:Ids()

  • How to use typeswitch in osb xquery ?

    Hi all,
    I couldnt understand the syntax of the x query type switch used in osb.Can anybody kindly explain it or give links to examples.
    typeswitch (())
    case $case-var as element(*) return ()
    default ()
    1) what should be given inside the typeswitch (()) ?
    2) what should be given as this variable $case-var ?
    3) what is the meaning of sequence type element(*) ?
    4) Is the typeswitch in x query used to avoid multiple nested if or is it something else ?
    Thank you.
    Edited by: Arun Vikram on Jul 18, 2010 11:47 PM
    Edited by: Arun Vikram on Jul 19, 2010 12:00 AM

    Hi Arun,
    See the section "2.11 Operations on Datatypes" of below doc -
    http://www.w3.org/TR/2001/WD-xquery-20010607/
    typeswitch is explained with an example in this section. typeswitch is similar concept as "switch" in Java.
    1) what should be given inside the typeswitch (()) ?The expression whose dynamic type is being tested.
    2) what should be given as this variable $case-var ?Each CASE clause specifies the name of a type, which must be a subtype of the static type of the operand expression, followed by a RETURN expression.
    3) what is the meaning of sequence type element(*) ?Any XML node
    4) Is the typeswitch in x query used to avoid multiple nested if or is it something else ?As said,The typeswitch expression of XQuery allows users to write queries that are sensitive to dynamic type, yes it helps to avoid multiple nested if to fulfill this use case.
    Regards,
    Anuj
    Edited by: Anuj Dwivedi, TCS on Jul 19, 2010 12:32 PM

  • OSB XQuery Maps

    Greetings!
    1]. I use OSB 10.3 with Eclipse (OSB Workshop that comes with OSB 10.3 installabe) IDE for doing mapping.
    I draw lines from Source to Target structure in XQuery Transformation. I see the source code getting build. When I close the XQuery and open it again in the IDE, I see all the source to target lines in the design view disappear. However the source code is still there. Any ideas what might be wrong here?
    2] In my XQuery transformation target structure for elements when I mounse over I see the Nodename, Namespace prefix and Namespace URI. However for some elements I see the namespace URI but no namespace prefix. This is causing problem because in the source code and in the output it produces there are elements without namespace prefix rendering the output invalid. I cant think of why for some elements there are no namespace prefixes. Any advise?
    Only think I can think of is that the target structure seem to have a cyclic reference in the schema.. pls see below example. Is this a problem?
    <a:element1>
    <b:element2>
    <a:element3>
    </b:element>
    </a:element1>
    3] I generated XQuery using mapforce for a map and when I tried to use it in OSB, it errored stating Recursive XQueryies are not supported in OSB. Any thots?
    Thanks in advance

    +2] In my XQuery transformation target structure for elements when I mounse over I see the Nodename, Namespace prefix and Namespace URI. However for some elements I see the namespace URI but no namespace prefix. This is causing problem because in the source code and in the output it produces there are elements without namespace prefix rendering the output invalid. I cant think of why for some elements there are no namespace prefixes. Any advise?+
    Only think I can think of is that the target structure seem to have a cyclic reference in the schema.. pls see below example. Is this a problem?
    +<a:element1>+
    +<b:element2>+
    +<a:element3>+
    +</b:element>+
    +</a:element1>+
    Schema cyclic reference was causing the problem with empty namespace. I had to go in to the XQuery and manually add the namespace and prefic and qualify the elements. After this data gets mapped

  • OSB XQuery transformation help in Proxy Service

    Hi,
    Need help in transformation of the below input to a proxy service
    <soapenv:Body  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
       <InputParams>
         <queryParams>
           <quer:query-params  xmlns:quer="http://www.example.org/QueryParams">
            <param name="test51" value="val3353" />
            <param name="test1" value="val2" />
            <param name="test3" value="val3" />
            <param name="test4" value="val4" />
            <param name="test1" value="val1" />
            <param name="test1" value="val11" />
            <param name="test8" value="val33" />
            <param name="test1" value="val34" />
            <param name="test8" value="val33" />
            <param name="test81" value="val33" />
            <param name="test1" value="val333" />
            <param name="test38" value="val33" />
           </quer:query-params>
         </queryParams>
       </InputParams>
    </soapenv:Body> and want to have the below output after running the below XQuery transformation
    <ns0:mparams>
      <ns0:param name="test1" value="val2" />
      <ns0:param name="test1" value="val1" />
      <ns0:param name="test1" value="val11" />
      <ns0:param name="test1" value="val34" />
      <ns0:param name="test1" value="val333" />
    </ns0:mparams>this is the xquery transformation file
    (:: pragma  parameter="$InputQuery" type="anyType" ::)
    (:: pragma bea:global-element-return element="ns0:mparams" location="../xsd/TargetParams.xsd" ::)
    declare namespace ns0 = "http://www.example.org/QueryParams";
    declare namespace xf = "http://tempuri.org/Simple/transformation/listparams/";
    declare function xf:listparams($InputQuery as element(*))
        as element(ns0:mparams) {
            <ns0:mparams>
                { $InputQuery/ns0:params/param[@name="test1"] }
            </ns0:mparams>
    declare variable $InputQuery as element(*) external;
    xf:listparams($InputQuery)and here is the input to the above .qs
    $body/InputParams/queryParams/qp:query-paramsbut it's the output is always empty and here is what it comes out no matter what the input I give even tried the below inputs but no use
    $body/InputParams/queryParams/qp:query-params
    $body/InputParams/queryParamshere is the output it always prints when logging in the log file
    <quer:mparams xmlns:quer="http://www.example.org/QueryParams"/>Any help is appreciated.
    Thanks

    $InputQuery/ns0:params/param[@name="test1"]Input doesn't have a ns0:params node ..so the xpath here should be $InputQuery/param[@name="test1"]

  • OSB XQuery Issue

    Hi,
    I have an xml A containing 100 elements.
    I have an xml B containing 500 elements out of which 75 are mandatory while rest are optional.
    I am transforming from xml A to xml B using XQuery Transformation.
    While transforming, the mandatory ones in xml B are coming perfectly, but the optional ones are coming empty.
    For example:
    Incoming xml:
    <Name>
    <FirstName>John</FirstName>
    </Name>
    Expected Response:
    <NAME>
    <FNAME>John</FNAME>
    </NAME>
    If element <FirstName> is not present I get the empty node in my transformed xml.
    Eg.
    <NAME>
    <FNAME/>
    </NAME>
    Is there any way to avoid the empty node tag without specifically adding IF ELSE conditions.
    I am working on OSB 11.1.1.5
    Please help.
    Regards,
    Karthik

    Hi Karthik,
    There is no if/then/else in xquery, in xquery you use FLOWR.
    http://www.w3schools.com/xquery/xquery_flwor.asp
    <NAME>
    for $a in (/Name/FirstName)
    return
    <FNAME>data($a)</FNAME>
    </NAME>This will omit the FNAME if there is no FirstName...
    Note that I didn't verify the syntax, but I think you'll get the idea...
    Cheers,
    Vlad

  • OSB - XQuery - Sample Switch Case

    Hi,
    Can some one pls give me a sample XQ, with Switch Case statement in it, which [Syntax] works in OSB.
    Regards,
    Kaleem...

    I am really afraid that OSB 11g supports XQuery 1.0
    http://download.oracle.com/docs/cd/E21764_01/doc.1111/e15867/xquery.htm
    while the switch statement is introduced only in XQuery 1.1
    http://www.w3.org/TR/2009/WD-xquery-11-20091215/#id-switch
    for the time being, you will have to resort to a cascade of if - then - else :o(

  • OSB - XQuery - line 24, col 1 {err}FORG0005: expected 1 item, got 2 or mor

    In the below XQ, I am trying to learn making calls to local functions. I have tweaked my earlier XQ, which had a local variable defined [in xf:getCost() function] as XPath to Quantity. Now, I have modified the XQ to make a call to xf:getQty() from xf:getCost(), to get the desired Quantity.
    On executing the below code I get Error occurred while executing XQuery: line 24, column 1: {err}FORG0005: expected exactly one time, got 2+ items. Either the XQuery is invalid or .... Request Help
    xquery version "1.0" encoding "Cp1252";
    (:: pragma parameter="$anyType1" type="xs:anyType" ::)
    (:: pragma type="xs:anyType" ::)
    declare namespace xf = "http://tempuri.org/purchaseOrder/";
    declare function xf:getCost()
    as xs:double {
    let $po := <purchase-order>
    <red-tape/>
    <order-item product="p010" price="10.50" quantity="3"/>
    <order-item product="p020" price="18.10" quantity="8"/>
    <order-item product="p020" price="11.10" quantity="8"/>
    </purchase-order>
    let $s1 := $po/order-item/@price
    let $s2 := $po/order-item/@quantity
    let $s3 := sum(for $el at $i in $s1 return $s1[$i] * xf:getQty($i))
    return $s3
    declare function xf:getQty($index as xs:decimal)
    as xs:decimal {
    let $po := <purchase-order>
    <red-tape/>
    <order-item product="p010" price="10.50" quantity="3"/>
    <order-item product="p020" price="18.10" quantity="8"/>
    <order-item product="p020" price="11.10" quantity="8"/>
    </purchase-order>
    return ($po/order-item/@quantity[$index])
    xf:getCost()

    return ($po/order-item[$index]/@quantity)
    not
    return ($po/order-item/@quantity[$index])

  • OSB - Xquery - Eclipse shows warning when a repeating node is repeated

    Hi,
    I have a requirement where a node needs to be repeated. This cannot go into a FOR LOOP as data to be mapped to Target XSD, are constants.
    For this, I repeated the node, by just changing the data in the Name and Value field. When I do this, eclipse, shows me a warning and highlights all the lines. Next time, when I switch to design view and add some direct mapping, eclipse warns me and on proceeding, removes all the lines with warning. Any help, on how I should attempt to solve this issue.
    Give below is the example xquery. Target has the node defined as repeating.
    declare namespace ns1 = "http://abc.com/abc/source";
    declare namespace ns0 = "http://abc.com/abc/target";
    declare namespace xf = "http://tempuri.org/XSD/mapping/";
    declare function xf:mapping($requestMessage1 as element(ns1:requestMessage))
    +as element(ns0:target) {+
    +<ns0:targetHeader>+
    +<ns0:RepeatingNode>+
    +<ns0:Name>Name1</ns0:Name>+
    +<ns0:Value>XPATH to Source field</ns0:Value>+
    +</ns0:RepeatingNode>+
    +<ns0:RepeatingNode>+
    +<ns0:Name>Name2</ns0:Name>+
    +<ns0:Value>Hard coded Value</ns0:Value>+
    +</ns0:RepeatingNode>+
    +<ns0:RepeatingNode>+
    +<ns0:Name>Name3</ns0:Name>+
    +<ns0:Value>Hard coded Value</ns0:Value>+
    +</ns0:RepeatingNode>+
    +<ns0:RepeatingNode>+
    +<ns0:Name>Name4</ns0:Name>+
    +<ns0:Value>XPATH to Source field</ns0:Value>+
    +</ns0:RepeatingNode>+
    +<ns0:RepeatingNode>+
    +<ns0:Name>Name5</ns0:Name>+
    +<ns0:Value>Hard coded Value</ns0:Value>+
    +</ns0:RepeatingNode>+
    +</ns0:targetHeader>+
    Regards.
    Edited by: 874988 on Jul 25, 2011 7:01 PM

    design mode is OK until you start customizing by hand your xquery... if you muck around the mapping sometimes is lost.
    I would suggest you to complete your mapping by hand!

  • ALSB (OSB) xquery support for fn:error

    Hi all,
    I've got a function which performs a check and eventually raise a fn:error
    In my IDE works fine and stop the transformation reporting the error, in Workshop it doesn't and complete the transformation anyway.
    Is there anything to enable? Is it supported? What other options I have?
    Thanks in advance

    Please refer -
    Re: XQuery fn:error function Issue
    Regards,
    Anuj

  • OSb-XQuery-TypeConversion(decimal to int)

    Hi all,
    I need some help in Xquery Transformation
    Source element type is decimal
    target element type is int
    I need to convert to decimal to int in Xquery.
    Actually I tried like this way
    <targetElement>{xs:int($sourceElement)}</targetElement>
    <error>Error occurred while executing XQuery: {err}XP0021: "100.00": can not cast to {http://www.w3.org/2001/XMLSchema}integer: error: integer: Invalid integer value: 100.00. Either the XQuery is invalid or it contains custom XQuery functions. Try using the web test console to test this XQuery (Right click on the XQuery file and select Run As ->Run On Server) </error>
    Can u help on this ,Which function do I need to use for type casting in Xquery.
    Regards
    Krishna.

    It's tricky because when you convert from xs:string to xs:integer decimal point is not allowed... So you have to go around and convert to xs:decimal first...
    <targetElement>{xs:int(xs:decimal($sourceElement))}</targetElement>
    Hope this answers your question...
    Cheers,
    Vlad

  • OSB, xquery and Assign issue

    Hello all
    I have an issue that I cannot quite understand...
    I have a very simple proxy service, that I would like to receive an xml of this form:
    <SO so_att1="soatt" xsi:noNamespaceSchemaLocation="Split.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <MLI mli_att1="mli1att">
              <LI li_att1="li1_att1">
                   <name>String</name>
                   <value>String</value>
                   <action>String</action>
              </LI>
              <LI li_att1="li2_att1">
                   <name>String</name>
                   <value>String</value>
                   <action>String</action>
              </LI>
              <LI li_att1="li3_att1">
                   <name>String</name>
                   <value>String</value>
                   <action>String</action>
              </LI>
              <LI li_att1="li4_att1">
                   <name>String</name>
                   <value>String</value>
                   <action>String</action>
              </LI>
              <LI li_att1="li5_att1">
                   <name>String</name>
                   <value>String</value>
                   <action>String</action>
              </LI>
              <name>String</name>
              <value>String</value>
              <action>String</action>
         </MLI>
    </SO>
    in order to transform it to a general data model of this form:
    <CDM>
         <Item so_att="soatt" mli_att="mli1att">
              <name>MLI1_name</name>
              <value>MLI1_value</value>
              <action>MLI1_action</action>
         </Item>
         <Item so_att="soatt" mli_att="mli1att" li_att="li1att">
              <name>LI1_name</name>
              <value>LI1_value</value>
              <action>LI1_action</action>
         </Item>
         <Item so_att="soatt" mli_att="mli1att" li_att="li2att">
              <name>LI2_name</name>
              <value>LI2_value</value>
              <action>LI2_action</action>
         </Item>
         <Item so_att="soatt" mli_att="mli1att" li_att="li3att">
              <name>LI3_name</name>
              <value>LI3_value</value>
              <action>LI3_action</action>
         </Item>
         <Item so_att="soatt" mli_att="mli1att" li_att="li4att">
              <name>LI4_name</name>
              <value>LI4_value</value>
              <action>LI4_action</action>
         </Item>
         <Item so_att="soatt" mli_att="mli1att" li_att="li5att">
              <name>LI5_name</name>
              <value>LI5_value</value>
              <action>LI5_action</action>
         </Item>
    </CDM>
    The common idea is to split the XML in to pieces with attributes inheritance. I have created 3 Assign actions. the 1st one has the xquery for seperating the MLI nodes with the correct attribues:
    for $i in (1 to fn:count($body/MLI))
    return
    <Item so_att1 = "{ data($body/@so_att1) }"
    mli_att1 = "{ data($body/MLI[$i]/@mli_att1) }">
    for $name in $body/MLI[$i]/name
    return
    <name>{ data($name) }</name>
    for $value in $body/MLI[$i]/value
    return
    <value>{ data($value) }</value>
    for $action in $body/MLI[$i]/action
    return
    <action>{ data($action) }</action>
    </Item>
    And it is saved in variable MLI
    The 2nd one is similar to this and saves to variable LI while the 3rd assign concats the variables like this: fn:concat('<CDM>', $MLI, $LI, '</CDM>') and saves in new variable...
    My problem comes, when I run on server the proxy. It is echoing (of course, cause there is no routing) but the incoming message passes only from third assign, ignoring the first and the second... Any idea why this is happening? The xqueries while tested inside the XQuery editor, works like charm...
    Thank you in advance

    Not sure if this is what you mean, but if you want to store elements in a variable during your XQuery you can use the "let" command.
    This way you can use them during your Xquery but it doesn't replace the Assign or Replace action in your message flow.
    let $x := 1
    let $y := $x + 1

  • OSB & xquery: when use text() or data(...)

    Hi all,
    I'm a beginner on xquery and I'm wondering when use text() or data(...).
    For example I've this simple xml document:
    <book>
    <author>A</author>
    <year>2010</year>
    <price currency="CHF" >100.123</price>
    </book>
    for retrieving attribute value I have to use data(/book/price/@currency)
    but for for retrieving tag value I've two possibilities:/book/price/text() or data(/book/price)
    Are those two expressions the same ? Or ones is evaluated faster than the others ?

    Text() - always returns the String.
    data() - accepts a sequence of items and returns their typed values (return type is xs:anyAtomicType). Calling this function is often unnecessary because the typed value of a node is extracted automatically (in a process known as atomization) for many XQueryXPath 2.0 expressions, including comparisons, arithmetic operations and function calls. The most common use case for the fn:data function is in XQuery element constructors.
    Regards,
    Anuj

  • OSB - XQuery

    How can i use XQuery to grab an xml structure in variable ($VarTargetData)  without all the namespaces appearing ?
    I tried $VarTargetData/* but it grabs all the namespaces also

    If needed: same for XSLT:
    <xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="xml" omit-xml-declaration="no" indent="yes" encoding="UTF-8" />
        <xsl:template match="comment()|processing-instruction()">
            <xsl:copy>
                <xsl:apply-templates />
            </xsl:copy>
        </xsl:template>
        <xsl:template match="*">
            <xsl:element name="{name()}" namespace="{namespace-uri()}">
                <xsl:apply-templates select="@*|node()" />
            </xsl:element>
        </xsl:template>
        <xsl:template match="@*">
            <xsl:attribute name="{name()}">
                <xsl:value-of select="." />
            </xsl:attribute>
        </xsl:template>
    </xsl:stylesheet>

Maybe you are looking for

  • Creation of multiple inspection points

    Hello experts, I try to figure out how to create multiple inspection points for one operation at process order release. It means that the release of the process order triggers: - inspection lot creation (lot origin 03) - inspection points creation fo

  • Function module to get material characteristics and coresponding value

    Hi experts,       I have got one problem...when we go to t code MM03..we select the views for a specific material for Basic Data1,Basic Data2 and Classification..in classification we get the material description and its corresponding values... These

  • HT5449 How do I delete last entry in dictate?

    I like using dictate but was wondering how to delete a word or phrase by dictating?

  • DB_CRYPTO_PASSWORD and Unicode

    Hi, with DB_CRYPTO_PASSWORD you get different encodings for the same cleartext-pwd on unicode- and non-unicode-systems I suppose it depends on the different byte-code of char in unicode and non-unicode. You can convert chars from ascii to utf-8 and b

  • Downloaded music gone after authorizing computer?? Where is it??

    I recently purchased a new Dell laptop with Windows 8 and downloaded I Tunes. I had it on my old laptop & everything worked just fine. I had been purchasing music from the  I Tunes store but had not had a chance to sync my I Pod Nano lately. I tried