14.8.2.2 Generating XML tags for each level
Check each index entry for colons: level separators that indicate a new index level. When a colon is encountered, close the XML element for the current level, and increment the level number:
The unary length operator in line 2 gets the length of the preceding value of variable $$IXtext, so the <$_while> expression works correctly; see:
§28.6.4 Using control structures in expressions
§28.6.5 Specifying substrings in expressions.
Assignment statements by default do not produce output, so only the value of the $$IXpart variable on line 5 actually ends up as content between the XML <indexn> tags, which are output on line 3 and line 8; see:
§28.3.2 Assigning values to macro variables
§28.6.3 Displaying expression results in output.
> 14 Converting to generic XML > 14.8 Converting index entries to generic XML > 14.8.2 Defining macros to process index content > 14.8.2.2 Generating XML tags for each level