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
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format