0

I would ordinarily like to set different <xsl:accumulator>s in response to the results of <xsl:if test="foo">.

Problem: <xsl:accumulator> must be a child of <xsl:stylesheet> or <xsl:transform>.

Said another way, the accumulator cannot be in a template where condition tests could be performed.

Question: Is there a way to change accumulator specs at run time, based on what is found in the source document?

The accumulator is similar to:

<xsl:accumulator 
    name="f:accumulate-string-length"
    post-descent="f:accum-string-length"
    as="xs:integer"
    initial-value="0">
    <xsl:accumulator-rule 
        match="*" 
        new-value="$value + string-length()"/>
</xsl:accumulator>

What I'd like to change at run time based on the source document is the @match="".

Update (response to comments): If the document tests to have a article/div structure, I would like the accumulator @match to be article/div, if the document tests to have section/div structure, I'd want the accumulator @match to be section/div.

Sometimes my documents vary, and like like to adjust on the fly.

4

0 回答 0