XSLT select all items that contain text

dulkMaydayMon

New Member
I haven't touched XSLT in half a decade, and I can't remember how one would do this. Essentially, I have an XML structure that looks like this:\[code\]<xml> <MenuDataResult> <Item name="firstlayeritem"> <Item></Item> <Item></Item> <Item name="secondlayeritem"> <Item name="thirdlayeritem"> <ItemSelected>true</ItemSelected> </Item> </Item> <Item></Item> <Item></Item> </Item> </MenuDataResult></xml>\[/code\]This XSLT is building a UL out of this structure, but only at the second level of Items (This is for a secondary navigation bar on the left of a page that only contains the second-order navigation items). This used to be a maximum of two layers deep, so a simple check for the ItemSelected node in the second level would allow us to add a class to that node's LI element of "current" or similar to enable CSS highlighting of that element in the navigation.Now they want to add a third layer, like above. The trick here is, the third layer isn't actually shown in the unordered list, ONLY the second layer items are, so the second layer item needs to be the one to get the class of "current" even though the "ItemSelected" node is in one of it's children.We used to do this check:\[code\]<xsl:variable name="SelectedMenu" select="ItemSelected/text()" /><xsl:if test="contains('true', $SelectedMenu)">...</xsl:if>\[/code\]And then check if that was equal to true to add the class. But now I need it to look not just at the current item, but at all sub-Items as well to see if any of them have "true" in them.Can someone help me figure out what needs to be done to do that? I don't remember any of the nuances of XSLT or how to do this sort of thing...
 
Back
Top