Subject: [xsl] Fwd: Flat XML File to Hierarchical ... best approach? From: "Mary McRae" <fiberartisan@xxxxxxxxx> Date: Sat, 18 Nov 2006 19:55:41 -0500 |
First, I've been to the FAQ site and read each of the entries of Flat File to Hierarchical. I didn't find anything that quite addressed my problem.
My source data is flat but properly sequenced. There are two elements whose values, if identical, imply parent/child relationship -- DocumentItemID and ParentID.
Input XML: <Items> <Item> (should correspond to Items/Item) <DocumentItemID>aaaaa</DocumentItemID> <ParentID>0000</ParentID> ... </Item> <Note> (should correspond to Items/Item/Note) <DocumentItemID>11111</DocumentItemID> <ParentID>aaaaa</ParentID> ... </Note> <Item> (should correspond to Items/Item/Item) <DocumentItemID>bbbbb</DocumentItemID> <ParentID>aaaaa</ParentID> ... </Item> <Item> (should correspond to Items/Item/Item/Item) <DocumentItemID>ccccc</DocumentItemID> <ParentID>bbbbb</ParentID> ... </Item>
Output XML: <Item1> <DocumentItemID>aaaaa</DocumentItemID> <ParentID>0000</ParentID> ... <Note> <DocumentItemID>11111</DocumentItemID> <ParentID>aaaaa</ParentID> ... </Note> <Item2> <DocumentItemID>bbbbb</DocumentItemID> <ParentID>aaaaa</ParentID> ... <Item3> <DocumentItemID>ccccc</DocumentItemID> <ParentID>bbbbb</ParentID> ... </Item3> </Item2> </Item1> </Items>
There can be as many as 8 levels of Item. There are 4 other elements that are similar to Note and must always be a child of an Item(1-8) element. My thought was that I could capture the Item/DocumentItemID each time I encounter an Item element, and then each time I encounter a Note or other child element of Item compare its child ParentID to the Item/DocumentID and if they match output the child elements ...
I keep either suppressing output of everything but the Item elements or repeating the Note elements in each instance of an Item element ...
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Looking for some basic gu, Irum Rauf | Thread | SV: [xsl] Fwd: Flat XML File to Hie, Per Osnes |
RE: [xsl] Looking for some basic gu, Michael Kay | Date | RE: [xsl] Looking for some basic gu, Irum Rauf |
Month |