[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Help using recursion on descendants of siblings

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

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>

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

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

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

</menu>


I want output records that look like this:

<meal>
<appetizer>Nachos</appetizer>
<entree>Tacos</entree>
<dessert><Strawberry cheesecake</dessert>
</meal>


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?

 Thanks,

 Joe

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.