B
Bostonasian
I don't even know where to begin this as hierarchy is always confusing
to construct dynamically in any form(query, xslt,etc). However it is
very easy to follow when it's presented. I've done breaking a linear
doc to 2 levels of hierarchy before, but that case had fixed level(its
depth didn't go any further than 2).
I have xml doc in attribute oriented format as following :
<Root>
<Survey ID="1" ControlType="Label" ParentID="1" Text="1. Commute"/>
<Survey ID="2" ControlType="Label" ParentID="1" Text="How do you
commute?"/>
<Survey ID="3" ControlType="DropDown" ParentID="2" Text="Car"/>
<Survey ID="4" ControlType="DropDown" ParentID="2" Text="Subway"/>
<Survey ID="5" ControlType="DropDown" ParentID="2" Text="Commuter
Rail"/>
<Survey ID="5" ControlType="DropDown" ParentID="2" Text="Bus"/>
<Survey ID="7" ControlType="DropDown" ParentID="2" Text="Walk"/>
<Survey ID="8" ControlType="Label" ParentID="1" Text="How long is
your commute?"/>
<Survey ID="9" ControlType="DropDown" ParentID="8" Text="-30min"/>
<Survey ID="10" ControlType="DropDown" ParentID="8" Text="30min - 1
hour"/>
<Survey ID="11" ControlType="DropDown" ParentID="8" Text="1 hour+"/>
<Survey ID="12" ControlType="Label" ParentID="12" Text="2. Your
company"/>
<Survey ID="13" ControlType="TextBox" ParentID="12" Text="Company
name"/>
<Survey ID="14" ControlType="TextBox" ParentID="12" Text="Employer"/>
<Survey ID="15" ControlType="TextBox" ParentID="15" Text="3. Other
comment"/>
</Root>
What I need to do is to format above in heirarchy form. If attribute
"ID" and "ParentID" are equal, it means that that node comes on top
level. So far, the depth of the hierarchy doesn't go any deeper than 3
levels. But I can't count on it. So ultimately what I want to have is
following :
<Root>
<Survey ID="1" ControlType="Label" Text="1. Commute">
<Survey ID="2" ControlType="Label" Text="How do you commute?">
<Survey ID="4" ControlType="DropDown" Text="Subway"/>
<Survey ID="5" ControlType="DropDown" Text="Commuter Rail"/>
<Survey ID="5" ControlType="DropDown" Text="Bus"/>
<Survey ID="7" ControlType="DropDown" Text="Walk"/>
</Survey>
<Survey ID="8" ControlType="Label" Text="How long is your commute?">
<Survey ID="9" ControlType="DropDown" Text="-30min"/>
<Survey ID="10" ControlType="DropDown" Text="30min - 1 hour"/>
<Survey ID="11" ControlType="DropDown" Text="1 hour+"/>
</Survey>
</Survey>
<Survey ID="12" ControlType="Label" Text="2. Your company">
<Survey ID="13" ControlType="TextBox" Text="Company name"/>
<Survey ID="14" ControlType="TextBox" Text="Employer"/>
</Survey>
<Survey ID="15" ControlType="TextBox" Text="3. Other comment"/>
</Root>
Has anyone does anything like this? If anyone know how to format
hierarchy in any depth, that'd be great, but I'd like know 3 levels at
least.
Thanks in advance.
to construct dynamically in any form(query, xslt,etc). However it is
very easy to follow when it's presented. I've done breaking a linear
doc to 2 levels of hierarchy before, but that case had fixed level(its
depth didn't go any further than 2).
I have xml doc in attribute oriented format as following :
<Root>
<Survey ID="1" ControlType="Label" ParentID="1" Text="1. Commute"/>
<Survey ID="2" ControlType="Label" ParentID="1" Text="How do you
commute?"/>
<Survey ID="3" ControlType="DropDown" ParentID="2" Text="Car"/>
<Survey ID="4" ControlType="DropDown" ParentID="2" Text="Subway"/>
<Survey ID="5" ControlType="DropDown" ParentID="2" Text="Commuter
Rail"/>
<Survey ID="5" ControlType="DropDown" ParentID="2" Text="Bus"/>
<Survey ID="7" ControlType="DropDown" ParentID="2" Text="Walk"/>
<Survey ID="8" ControlType="Label" ParentID="1" Text="How long is
your commute?"/>
<Survey ID="9" ControlType="DropDown" ParentID="8" Text="-30min"/>
<Survey ID="10" ControlType="DropDown" ParentID="8" Text="30min - 1
hour"/>
<Survey ID="11" ControlType="DropDown" ParentID="8" Text="1 hour+"/>
<Survey ID="12" ControlType="Label" ParentID="12" Text="2. Your
company"/>
<Survey ID="13" ControlType="TextBox" ParentID="12" Text="Company
name"/>
<Survey ID="14" ControlType="TextBox" ParentID="12" Text="Employer"/>
<Survey ID="15" ControlType="TextBox" ParentID="15" Text="3. Other
comment"/>
</Root>
What I need to do is to format above in heirarchy form. If attribute
"ID" and "ParentID" are equal, it means that that node comes on top
level. So far, the depth of the hierarchy doesn't go any deeper than 3
levels. But I can't count on it. So ultimately what I want to have is
following :
<Root>
<Survey ID="1" ControlType="Label" Text="1. Commute">
<Survey ID="2" ControlType="Label" Text="How do you commute?">
<Survey ID="4" ControlType="DropDown" Text="Subway"/>
<Survey ID="5" ControlType="DropDown" Text="Commuter Rail"/>
<Survey ID="5" ControlType="DropDown" Text="Bus"/>
<Survey ID="7" ControlType="DropDown" Text="Walk"/>
</Survey>
<Survey ID="8" ControlType="Label" Text="How long is your commute?">
<Survey ID="9" ControlType="DropDown" Text="-30min"/>
<Survey ID="10" ControlType="DropDown" Text="30min - 1 hour"/>
<Survey ID="11" ControlType="DropDown" Text="1 hour+"/>
</Survey>
</Survey>
<Survey ID="12" ControlType="Label" Text="2. Your company">
<Survey ID="13" ControlType="TextBox" Text="Company name"/>
<Survey ID="14" ControlType="TextBox" Text="Employer"/>
</Survey>
<Survey ID="15" ControlType="TextBox" Text="3. Other comment"/>
</Root>
Has anyone does anything like this? If anyone know how to format
hierarchy in any depth, that'd be great, but I'd like know 3 levels at
least.
Thanks in advance.