[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Tricky transformation task

Subject: Tricky transformation task
From: Jimmy <jimmy@xxxxxxxxxxxxxx>
Date: Wed, 11 Jul 2007 16:41:57 +0200
 Tricky transformation task
I have the following XML structure which shows me links between objects (O1/O2).

<LINKS>
     <LINK ID="2" O1-ID="1" O2-ID="3"/>
     <LINK ID="10" O1-ID="1" O2-ID="11"/>
     <LINK ID="14" O1-ID="11" O2-ID="15"/>
     <LINK ID="18" O1-ID="2" O2-ID="4"/>
     <LINK ID="22" O1-ID="2" O2-ID="8"/>
     <LINK ID="26" O1-ID="8" O2-ID="17"/>
       ...
</LINKS>

I need to transform this into another XML structure showing me witch objects (O1/O2) and links (ID) are in the same subgraph. So I have to add something like another ID identifying which of the objects and links belong to the same graph (SUBG-ID).

this is the structure I would like to have:

<SUBG-ITEMS>
        <ITEM SUBG-ID="0" ITEM-ID="1" ITEM-TYPE="O" NAME="Object"/>
        <ITEM SUBG-ID="0" ITEM-ID="3" ITEM-TYPE="O" NAME="Object"/>
        <ITEM SUBG-ID="0" ITEM-ID="11" ITEM-TYPE="O" NAME="Object"/>
        <ITEM SUBG-ID="0" ITEM-ID="15" ITEM-TYPE="O" NAME="Object"/>
        <ITEM SUBG-ID="0" ITEM-ID="2" ITEM-TYPE="L" NAME="Link"/>
        <ITEM SUBG-ID="0" ITEM-ID="10" ITEM-TYPE="L" NAME="Link"/>
        <ITEM SUBG-ID="0" ITEM-ID="14" ITEM-TYPE="L" NAME="Link"/>

        <ITEM SUBG-ID="1" ITEM-ID="18" ITEM-TYPE="O" NAME="Object"/>
        <ITEM SUBG-ID="1" ITEM-ID="2" ITEM-TYPE="O" NAME="Object"/>
         ...
</SUBG-ITEMS>

I have thought about different ways on how to achieve this but they seem way too difficult or too time consuming at runtime. I need an easy way to give out ID's, how could I do this besides counting or maybe use the position() inside for-each? And I thought about checking previous links to see if an object is already present, if so the same SUBG-ID (count?) would have to be used.

Any hints on how to optimize this task would be very helpful. (XSL1 or 2)

Cheers
Jimmy

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.