I have a dynamic XML document which represents a tree structure of categories, but does so using path separated attributes in arbitrary order - like this:>
Sure, no problem:
Output on my system:
Note that the whole solution is based on the assumption that all the paths are canonical and do not contain trailing backslashes.
Also note that any unmatched/orphaned "record" elements will not be in the output (unless they are at the root level, of course).
One more thing: The template mode ("recurse") is not strictly necessary. I included it because the template is doing something rather special, and there might be the chance that there is another template in your solution that matches "record" nodes. In this case this solution can be dropped in without breaking anything else. For a standalone solution, the template modes can be dropped anytime.
Oh, and the last thing: If you want the result document to be ordered by Name, include an
(both occurrences), like so: