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
  • 1.  converting from attribute to element

    Posted Wed August 27, 2003 02:39 PM

    Hello

    is it possible in Tamino to convert the contents of an attribute into the contents of an element?

    For example I would like to read out an @id attribute and place the contents into a tag in the result.

    Thank you in advance


    Michal Ziemski


    #API-Management
    #webMethods
    #Tamino


  • 2.  RE: converting from attribute to element

    Posted Wed August 27, 2003 03:08 PM

    Hi Michal,

    Using Tamino XQuery you should be able to do something like this:-

      
    declare namespace tf="http://namespaces.softwareag.com/tamino/TaminoFunction"
    for $x in input()/a
    return <a><pointer>{tf:getInoId(root($x))}</pointer>{$x/*}</a>



    This reads documents with root element and inserts a element as a child of and then inserts the child nodes of following after the element.

    Hope this helps.

    Stuart Fyffe-Collins
    Software AG (UK) Ltd.


    #API-Management
    #webMethods
    #Tamino


  • 3.  RE: converting from attribute to element

    Posted Wed August 27, 2003 04:50 PM

    Hi Stuart

    Maybe I do not understand well your suggestion but I was not thinking about Tamino’ s internal ids.
    My problem is that I have attributes from which I would like to take the values and to place (only the values) into an element, but not as attributes.

    The query I am using is like:

    let $startlist1 :=
    for $s1 in $v13
    let $tempid := $s1/@id
    return {$tempid}

    return { $startlist1 } { $v13 }

    in the end I would like to have a result like:



    (then several times the following because in $v13 might be several elements each one with an attribute)

    (here the value from the attribute)








    Any ideas?
    Thanks

    Michal


    #Tamino
    #webMethods
    #API-Management


  • 4.  RE: converting from attribute to element

    Posted Wed August 27, 2003 06:20 PM

    Hi Michal,

    Sorry I think I read the original question to quickly :slight_smile: Anyway what you are asking should still be possible. I now created a little example which should help you. I have inserted the following three documents into Tamino:

      
    <a>
    <b id="x">document 1.0</b>
    </a>
    <a>
    <b id="y">document 2.0</b>
    </a>
    <a>
    <b id="a">document 3.0</b>
    <b id="b">document 3.1</b>
    <b id="c">document 3.2</b>
    </a>
    </pre><BR><BR>Now using XQuery I want to produce a <result> element followed by some elements with the values of the id attributes (but NOT as attributes but as text) and then the child elements of <a>. So for the third example I will get something like:-<BR><BR><pre class="ip-ubbcode-code-pre">  
    <result>
    <startlist>
    <someattr>a</someattr> 
    <someattr>b</someattr> 
    <someattr>c</someattr> 
    </startlist>
    <b id="a">document 3.0</b> 
    <b id="b">document 3.1</b> 
    <b id="c">document 3.2</b> 
    </result>
    </pre><BR><BR>The XQuery I wrote is:-<BR><pre class="ip-ubbcode-code-pre">  
    for $x in input()/a
    let $y := $x/*
    let $u := for $uu in $y//@id
    return <someattr>{string($uu)}</someattr>
    return
    <result><startlist>
    {$u}
    </startlist>
    {$y}
    </result>



    I use the string() function otherwise the attribute and not the text representation is inserted into the result document.

    I hope this is nearer to what you are looking for :slight_smile:

    Stuart Fyffe-Collins
    Software AG (UK) Ltd.


    #Tamino
    #webMethods
    #API-Management


  • 5.  RE: converting from attribute to element

    Posted Thu August 28, 2003 11:07 AM

    Hello Stuart

    Thank you very much, that was exactly what I was searching for! :slight_smile:

    Greets

    Mic


    #webMethods
    #API-Management
    #Tamino