Subject: [xsl] Trouble digesting grouping From: "Flanders, Charles E (US SSA)" <charles.flanders@xxxxxxxxxxxxxx> Date: Fri, 6 Nov 2009 08:41:27 -0500 |
I'm struggling with a grouping problem. I've had some success with simpler structures, but this one has me stumped. This is an XML to XML transform. I need to eliminate the parent <para > completely, output the <table> intact, but grab the <graphic> elements, create a single <figure>, then a <subfig> wrapper element for each <graphic>. Then output the structures interspersed with the tables. I can't seem to separate the tables and figures. What I'm ending up with is a single <figure> with all the <subfig>, then the tables. <install> <proc> <step1> <para></para> </step1> </proc> <para> <table> All the table stuff </table> <graphic> <graphic> <graphic> <table> All the table stuff </table> <graphic> <graphic> <graphic> </para> </install> Output that I desire: <install> <step1> <para></para> <step1> <table> All the table stuff </table> <figure><title/> <subfig><graphic></subfig> <subfig><graphic></subfig> <subfig><graphic></subfig> </figure> <table> All the table stuff </table> <figure><title/> <subfig><graphic></subfig> <subfig><graphic></subfig> <subfig><graphic></subfig> </figure> </install> Output that I'm getting (and I've tried defining the group in various ways, this is my last iteration). <install> <step1> <para></para> </step1> <figure><title/> <subfig><graphic/></subfig> <subfig><graphic/></subfig> <subfig><graphic/></subfig> <subfig><graphic/></subfig> <subfig><graphic/></subfig> <subfig><graphic/></subfig> </figure> <table></table> <table></table> </install> My current templates: (Wendell, my apologies for just not getting this). Using XSLT 2.0. <install> <xsl:apply-templates select="descendant::step1"/> <xsl:if test="child::proc/following-sibling::para/(child::table|graphic)"> <xsl:apply-templates select="child::proc/following-sibling::para/child::table | child::para" mode="install"/> </xsl:if> </install> <xsl:template match="table" mode="install"> <table> <xsl:apply-templates/> </table> </xsl:template> <xsl:template match="install/para" mode="install"> <figure> <xsl:for-each-group select="*" group-starting-with="graphic"> <xsl:for-each select="current-group()[self::graphic]"> <subfig> <xsl:copy-of select="."/> </subfig> </xsl:for-each> </xsl:for-each-group> </figure> </xsl:template> Charles Flanders
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] The benefits of exact sel, Mukul Gandhi | Thread | Re: [xsl] Trouble digesting groupin, Martin Honnen |
RE: [xsl] The benefits of exact sel, Michael Kay | Date | Re: [xsl] Trouble digesting groupin, Martin Honnen |
Month |