Can I use XSLT to "unflatten" a list?
I've been handed some XML that's basically flat:
<foo>
<bar att="1"/>
<bar att="2"/>
<bar att="3"/>
<bar att="3"/>
<bar att="2"/>
<bar att="3"/>
<bar att="3"/>
<bar att="2"/>
</foo>
and so on. Is there a good trick for "unflattening" this list, based on the attribute, so that I can end up with something like this:
<One>
<Two>
<Three/>
<Three/>
</Two>
<Two>
<Three/>
<Three/>
</Two>
<Two/>
</One>
That attribute is consistent enough for me to use it as my guideline. I can find those. But since it's not really nested, once I find one, I'm not really sure to say "Now that I've landed on this 2, start looking at the 3s under it and stop when you get to another 2."
At each level I don't know how many children I will have, either.
|