xsl-list
[Top] [All Lists]

[xsl] impossible to implement this algorithm in xslt?

2008-07-24 16:29:40
I'm beginning to despair in the possibility that it may be impossible to
implement this algorithm in xslt. Perhaps one of you battle-hardened vets
could shed some light...
 
Input doc:
<doc>
        <sect depth="3">heading</sect>
        <A level="1">
                <B level="2">xx</B>
        </A>
        <sect depth="7">heading2</sect>
        <C level="1">
                <D level="2">yy</D>
        </C>
</doc>

Desired output:
<doc>
        <sect depth="3">heading</sect>
        <A level="4">
                <B level="5">xx</B>
        </A>
        <sect depth="7">heading2</sect>
        <C level="8">
                <D level="9">yy</D>
        </C>
</doc>

Note how the 'level' attributes in the output represent the sum of their
value in the input and the value of the 'depth' attribute of the <sect>
which precedes it.

Given the recursive processing paradigm of xslt, without the ability for a
template to return a value or to set a global variable, I can't figure out
how I can process the <sect>s and make the value of their 'depth'
attributes available for the processing of the other elements.

Would someone please tell me I'm missing something?!?

Thanks very much

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>