[xsl] Help using recursion on descendants of siblings

Subject: [xsl] Help using recursion on descendants of siblings
From: joseph.a.gilvary@xxxxxxxxxx
Date: Wed, 5 Dec 2007 12:23:13 -0500

First, I apologize if I overlooked an XSLT 1.0 solution for this in the 
FAQ. I did spend some time searching before deciding to post.

I have an input file with a structure like this one's.


<menu-item name="appetizer">
<value>Potato skins</value>

<menu-item name="entree">
<value>Chicken pot pie</value>
<value>Steak and potatoes</value>

<menu-item name="dessert">
<value>Blueberry pie</value>
<value>Chocolate ice cream</value>
<value>Strawberry cheesecake</value>


I want output records that look like this:

<dessert><Strawberry cheesecake</dessert>

I want to generate a record for each of the 24 possible meals that one 
could prepare (without regard to palatability!) in combinations of 
distinct values from each <menu-item>. My real world problem has a much 
larger input file (many more nodes at the <menu-item> level with far more 
<value> nodes for each) which itself has potential to increase over the 
life of the solution. For something this small, I could hard code the 
references to the particular <menu-item> values, but that's not feasible 
for my real-world problem. Somewhat better would be a stylesheet to 
produce that hard coded spreadsheet and thereby support later inputs with 
more <menu-item> nodes, but that still strikes me as a very procedural way 
to approach this.

I just don't see how to get past carrying context related to position 
within the value collection for each of the following-siblings.

Is my procedural mindset (Thank you, Java!) blinding me to a general 
declarative solution? I'm using Xalan now. Would moving to Saxon for XSLT 
2 open possibilities that don't exist for XSLT 1.0?



Current Thread