[xsl] Re: Grouping following siblings (recursive template?)

Subject: [xsl] Re: Grouping following siblings (recursive template?)
From: John Dunning <jm_dunning@xxxxxxxxx>
Date: Mon, 15 Mar 2010 11:39:05 -0700 (PDT)
Hi all,

I'm attempting to process SVG graphics that may or may not contain other graphics.

Given this file:


<!-- this should be the first graphic -->

   <rect height="190" x="113" y="356" rx="22" ry="22" fill="#FFFFFF" width="176" stroke="#808040" stroke-width="1"/>
       <text x="201" y="366" fill="#000000" font-size="10" font-family="Arial" text-anchor="middle">Parent1</text>

   <rect height="142" x="140" y="396" rx="16" ry="16" fill="#FFFFFF" width="130" stroke="#808040" stroke-width="1"/>
       <text x="205" y="406" fill="#000000" font-size="10" font-family="Arial" text-anchor="middle">Child</text>

   <rect height="67" x="154" y="463" rx="8" ry="8" fill="#FFFFFF" width="95" stroke="#808040" stroke-width="1"/>
       <text x="201" y="474" fill="#000000" font-size="10" font-family="Arial" text-anchor="middle">Grandchild</text>

<!-- this should be the second -->

   <rect height="169" x="507" y="371" rx="11" ry="11" fill="#FFFFFF" width="89" stroke="#808040" stroke-width="1"/>
       <text x="551" y="382" fill="#000000" font-size="10" font-family="Arial" text-anchor="middle">Parent2</text>

<!-- this should be the third -->

   <rect height="54" x="678" y="452" rx="6" ry="6" fill="#FFFFFF" width="87" stroke="#808040" stroke-width="1"/>
       <text x="722" y="463" fill="#000000" font-size="10" font-family="Arial" text-anchor="middle">Parent3</text>
</svg>


I would like to produce 3 output files, the first containing 'Parent1', 'Child', and 'Grandchild', the second and third producing 'Parent2' and 'Parent3' respectively.

The logic is to take the @height from the first <rect> and then add the @height of following <rect> siblings until it exceeds the parent, at which time start a new file; I will also have to do some comparison of X and Y coordinates as 
well.  I'm having trouble creating the recursive function/named template to do this.  Any ideas?

TIA,
John

Current Thread