posted 18 years ago
Hello,
Is there some XSLT equivalent to "for i = 0; i < max; i++", even without having access to the index inside the loop? I'm trying to transform an xml file representing a nested lists into html, and have the HTML output for each element indented based on the depth of the element. For a quick example,
With indentation set at 4 spaces per level, the HTML output would have b indented 4 spaces, c and d indented 8 spaces, and so on. The stylesheet should have no idea what to expect aside from categories under categories, some of them containing documents. The indentation should be done based on how deep in the tree the categories and documents are encountered.
Currently I keep track of the depth by passing parameters to templates, but the actual indentation is a terrible hack which noticeably slows down the transformation (iterating over dummy nodes in the XML, writing the spaces if position() < $indentLevel). Is there a better way to do this?
Note that the output will probably be presented using tables, so the natural indentation of HTML lists cannot be used.
Thank you,
Yuriy