On 14.10.2010 23:10, charlieo0(_at_)comcast(_dot_)net wrote:
I seem to have a constant problem with getting the correct results with
grouping. I have a problem I could use help with that is either a sort or
grouping problem. Possibly both.
Or rather none of them. Here's a solution using just apply-templates:
<xsl:template match="fgc_list">
<xsl:copy>
<xsl:apply-templates select="fnc"/>
</xsl:copy>
</xsl:template>
<xsl:template match="fnc">
<xsl:copy-of select="." />
<xsl:copy-of select="../figure[(_at_)parent-id eq current()/@id]" />
</xsl:template>
Desired Result:
<fgc_list>
<fnc code="01" id="fgc1"/>
<fnc code="0101" id="fgc1.1" parent-id="fgc1"/>
<figure figid="1" parent-id="fgc1.1"/>
<figure figid="2" parent-id="fgc1.1"/>
<fnc code="02" id="fgc2"/>
<fnc code="0201" id="fgc2.1" parent-id="fgc2"/>
<fnc code="020101" id="fgc2.1.1" parent-id="fgc2.1"/>
<figure figid="3" parent-id="fgc2.1"/>
The proposed solution inserts figure3 at another position than
specified: just after its parent fgc2.1, rather than after fgc2.1.1. Is
this ok? I couldn't devise a rule that inserts figure4 immediately
after its parent fgc2.1.2, while figure3 won't be inserted immediately
after its parent but after the first of fgc2.1's two children.
<fnc code="020102" id="fgc2.1.2" parent-id="fgc2.1"/>
<figure figid="4" parent-id="fgc2.1.2"/>
</fgc_list>
I need the<fnc> element to remain in the current order, but insert the sibling<figure> elements with
the attribute "parent-id" where that value matches the "id" attribute of the preceding<fnc>.
Proposed solution seems to be in accordance with this rule.
-Gerrit
Charles
--~------------------------------------------------------------------
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>
--~--