[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Hi list members,
several weeks ago, your much appreciated help enabled me to tackle my grouping problem. Now I am thinking about some refactoring, so I'll briefly resume it before asking you again for help. It's basically a classic heading-type grouping problem, but with some additional difficulties. From a flat structure like
I am building this hierarchical structure:
This is to say, each group needs specific processing. Currently I am using xsl:choose to recognize a group by its "leader":
<!-- xsl:when statements for the other two cases left out -->
<!-- template rules for copying the individual elements left out -->
My question is: Is it feasible (and reasonable) to avoid using xsl:choose here but instead select a group's treatment based on a key (because some groups might need the same kind of processing)? I think of having just a single call to the key function which would then dispatch the call to one out of a list of user-defined functions or named templates, which would finally return the resulting sequence.
Am I dreaming here of a control flow "too dynamic" to be legal in XSLT2? If not, what could the key definition and function call look like?
Yves
[xsl] XSLT2: Keys vs. xsl:choose to distinguish groups
Subject: [xsl] XSLT2: Keys vs. xsl:choose to distinguish groups From: Yves Forkl <Y.Forkl@xxxxxx> Date: Thu, 15 Mar 2007 13:31:22 +0100 |
Hi list members,
several weeks ago, your much appreciated help enabled me to tackle my grouping problem. Now I am thinking about some refactoring, so I'll briefly resume it before asking you again for help. It's basically a classic heading-type grouping problem, but with some additional difficulties. From a flat structure like
<A/> <x/> <B/> <x/> <y/> <C/> <x/>
I am building this hierarchical structure:
<part_A> <item_specific_to_A/> <A/> <x/> </part_A> <part_B> <B/> <x/> <item_specific_to_B/> <y/> </part_B> <part_C> <C/> <item_specific_to_C/> <x/> </part_C>
This is to say, each group needs specific processing. Currently I am using xsl:choose to recognize a group by its "leader":
<xsl:for-each-group select="*" group-starting-with="A|B|C"> <xsl:choose>
<xsl:when test="current-group()[1] = A"> <part_A> <item_specific_to_A/> <xsl:apply-templates select="current-group()"/> </part_A> </xsl:when>
<!-- xsl:when statements for the other two cases left out -->
</xsl:choose> </xsl:for-each-group>
<!-- template rules for copying the individual elements left out -->
My question is: Is it feasible (and reasonable) to avoid using xsl:choose here but instead select a group's treatment based on a key (because some groups might need the same kind of processing)? I think of having just a single call to the key function which would then dispatch the call to one out of a list of user-defined functions or named templates, which would finally return the resulting sequence.
Am I dreaming here of a control flow "too dynamic" to be legal in XSLT2? If not, what could the key definition and function call look like?
Yves
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Subtree Transformation, Abel Braaksma | Thread | Re: [xsl] XSLT2: Keys vs. xsl:choos, David Carlisle |
SV: Re: [xsl] fo spaces, Mati Hadi | Date | Re: [xsl] XSLT2: Keys vs. xsl:choos, David Carlisle |
Month |