converting from attribute to element

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

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.

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

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.

Hello Stuart

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

Greets

Mic