Page 1 of 1

Finding depth in output tree?

Posted: Thu Apr 12, 2012 8:10 pm
by alyxandr
Hi all,

count(ancestor-or-self::*) yields your current depth in the input tree -- is there anything similar that will tell you at what level in the output tree the current template is generating tags? Or would this require some sort of precognition in the XSLT processor?

(I'm asking on behalf of an imported template, which doesn't necessarily know much about the transform that imported it.)

Thanks, --alex.

Re: Finding depth in output tree?

Posted: Wed Apr 18, 2012 5:36 pm
by adrian
Hi,

Unfortunately there isn't a function or axis that tells you the depth of the output. One possible solution would be to keep the output in a variable instead of actually outputting it, and then analyze the contents of that variable. But this is not useful in your situation since you have an unaware template.

Regards,
Adrian

Re: Finding depth in output tree?

Posted: Wed Apr 18, 2012 7:11 pm
by alyxandr
Thanks! I've ended up being able to pass a parameter, which gets one added to it when calling apply-templates, but it's comforting to know that i wasn't missing something obvious. --alex.