Creating Hiearchical structure from flat structure of elemen

Hello,

I am faced with a task of building up a hierachy from a list of elements which contain child nodes with ID’s pointing to elements in the list. I am given a root node to start with (Theme - SEC) and i need to generate an XML file that contains the concrete hierachy of elements that are its decendants from the list.

following is a sample of elements from the list



Theme
SEC

Missions






Mission
MMS

Functional Decomposition






Mission
MagCon

Functional Decompostion







What my goal is to create a structure such as the following



Theme
SEC

Missions

Mission
MMS

Functional Decomposition





Mission
MagCon

Functional Decompostion









A recursive user-defined function would do the trick, but what I understand is that XQuery4 does not yet support user-defined function.

following is the query i was begining to formulate to perform this task


for $capability in input()/Capability
return

{ $capability/@id }
{ $capability/type, $capability/name }

{
for $child in $capability/collection/child
return
{
recurse-child($child)
}
}




recurse-child would look something like this (not sure about define function syntax)


define function recurse-child($child){
for $capability in input()/Capability where $capability/@id = $child/@capability_id
return

{ $capability/@id }
{ $capability/type, $capability/name }

{
for $child in $capability/collection/child
return
{
recurse-child($child)
}
}


}



Can you please help me figure out how this can be done.

I have attached the list of elements that I extracted from Tamino that I am working with.


Thank you in advance for your help.


–joey

X-Application Version: 4.1.1
Tamino Version : 4.1.1
Platform : Win2k
WebContainer : Tomcat 4.1.24
JDK Version : 1.4.1

capabilities.xml (12.8 KB)

As far as I can see, this kind of recursive query is beyond the capabilities of the current XQuery implementation in Tamino.

I would suggest extracting the data in “flat” form, and then processing it outside the database using XSLT.

(In fact, even when Tamino does support this kind of query, this might turn out to be the best strategy from a performance point of view - unless Tamino can optimize the query, which in this case is probably unlikely, it may well be better to do the work in the client or application tier rather than in the database engine.)

If you need advice on how to do this transformation with XSLT, I’ll be happy to help - when I get back from holiday!

Michael Kay

Thanks Michael,
I would appriciate any help that you or anyone else can offer.

–joey

X-Application Version: 4.1.1
Tamino Version : 4.1.1
Platform : Win2k
WebContainer : Tomcat 4.1.24
JDK Version : 1.4.1

Hi Joey,

the map2object functionality of Tamino supports recursion. It can be used in some combinations (not all, I am afraid) with XQuery.

Regards

Harald

Hi Harald,

I am not familiar with map2object. Where can i find out more about it. I searched on the softwareag website but didnt not get any results.

Maybe you can give me a quick description of what map2object is and what it does.

Thanks…

–joey

X-Application Version: 4.1.1
Tamino Version : 4.1.1
Platform : Win2k
WebContainer : Tomcat 4.1.24
JDK Version : 1.4.1

Hi Joey,

sorry, I was not precise in naming. The feature I wanted to refer to is called “Object reference”. See the section “Composition by object reference” in the Tamino documentation.

Hope this helps

Regards

Harald

To save a few searches… this section can be found somewhere around here:

   C:\Program Files\Software AG\Tamino\Tamino 4.1.1.1\Documentation\advconc\DocumentComposition.htm#Compositionbyobjectreference


Greetings,
Trevor.

Harald, Trevor,

Thanks for informing me about “Object References” within Tamino. I will haveto give this a try and see how it works.

Thanks again.

–joeycz

X-Application Version: 4.1.1
Tamino Version : 4.1.1
Platform : Win2k
WebContainer : Tomcat 4.1.24
JDK Version : 1.4.1