[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Putting parameter into XPATH expression
Thanks all, Yes I was indeed passing in a string instead of a number. (My dumb mistake). Not putting single quotes around the param is the right answer. (For those older folks on the list, you will find some irony in a recent problem that I was having where I was missing single quotes. I guess I'll learn soon enough or I'll have to get an anonymous email address like "xslayer@xxxxxxxxxxx" perhaps and stop embarassing myself.) Wendell Piez's asks "But why not just write a stylesheet that traverses the tree in the normal way?". His point is quite valid and I fully agree that one should usually let XSL do its thing and have its rules fired by the XML data as it occurs. (Tom P had a similar comment.) In the example that I posted, I had removed a lot of code to demonstrate the trouble I was having with those single quotes. Because of the simplification it was no longer obvious to any one reading it that I have to control the flow of the output using logic in the stylesheet. But do I have to control the flow? Hmm. Since we are now on the topic of design patterns. Perhaps someone would care to comment on my approach to my problem? I have exactly 6 list boxes on an HTML page that I am using as jump menus. The XML structure looks basically like this (Note that Menus can contain Menus. This approach is taken so that if someone decides to replace the listboxes with cascading menus, we will be able to have an arbitrary number of menus containing menus containing menus): <Menus> <Menu> <EnglishName>Menu One</EnglishName> <FrenchName>Le Menu Un</FrenchName> <Menu> <EnglishName>Item One</EnglishName> <FrenchName>L'item Un</FrenchName> <EnglishUrl>itemOne.html</EnglishUrl> <FrenchUrl<fitemOne.html</FrenchUrl> </Menu> <Menu> <EnglishName>Item Two</EnglishName> <FrenchName>L'item Deux</FrenchName> <EnglishUrl>itemTwo.html</EnglishUrl> <FrenchUrl<fitemTwo.html</FrenchUrl> </Menu> <!-- bunch more items in menu one --> </Menu> <Menu> <EnglishName>Menu Two</EnglishName> <FrenchName>Le Menu Deux</FrenchName> <Menu> <!-- bunch of menu items for menu two --> </Menu> <!-- exactly six <Menu>'s belong to the <Menus> node --> </Menus> On the output page each of these six menus has different HTML code around it. I have written the XSL so that it manually pulls the menu data in: <xs:template> <!-- put out HTML until the first menu --> <!-- call template that reads in first menu data and puts out the HTML menu --> <!-- put out HTML between the first and second menu --> <!-- call template that reads in second menu data and puts out the HTML menu --> <!-- put out HTML between the second and third menu --> <!-- call template that reads in third menu data and puts out the HTML menu --> <!-- and so on until the code after the sixth menu is put out... --> </xsl:template> It is because the HTML between the menus can be quite arbitrary, that I went with the pull approach. Thanks all, James MacEwan Software Developer Investors Group Inc. mailto:James.MacEwan@xxxxxxxxxxxxxxxxxx v: (204) 956-8515 f: (204) 943-3540 "I don't know, lad. It's like no cheese I've ever tasted." -- Wallace XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|