Need help to compare two sets of nodes in xsl

hima85222

New Member
Here's piece of my xml:\[code\]<?xml version="1.0" encoding="ISO-8859-1"?><?xml-stylesheet type="text/xsl" href="http://stackoverflow.com/questions/8375252/ran.xsl"?> <Authentication isLogged="1" uid="40"> <GetUserMenu> <MenuList> <row MenuID="1" MenuTitle="menu1"/> <row MenuID="2" MenuTitle="menu2"/> <row MenuID="3" MenuTitle="menu3"/> <row MenuID="4" MenuTitle="menu4"/> </MenuList> <FunctionList> <row FunctionID="1" FunctionTitle="submenu1" MenuID="1" WorkflowName="ImportDataWithoutFile" Order="1"/> <row FunctionID="2" FunctionTitle="submenu2" MenuID="1" WorkflowName="ImportDataFromFile" Order="2"/> <row FunctionID="2" FunctionTitle="submenu2" MenuID="3" WorkflowName="ImportDataFromFile" Order="2"/> </FunctionList> </GetUserMenu> </Authentication>\[/code\]Html output should be something like this:\[code\]<div id="menu"> <div>menu1 <div class="subMenu"> <div>submenu1 </div> <div>submenu2 </div> </div> </div> <div>menu2 <div class="subMenu"> </div> </div> <div>menu3 <div class="subMenu"> <div>submenu3 </div> </div> </div> <div>menu4 <div class="subMenu"> </div> </div></div>\[/code\]and piece of xsl:\[code\]<xsl:template match="//Authentication/GetUserMenu"> <div> <xsl:for-each select="//MenuList/row"> <div><xsl:value-of select="@MenuID"/></div> tu <xsl:for-each select="//FunctionList/row["> <div><xsl:value-of select="@MenuID"/></div> </xsl:for-each> tu </xsl:for-each> </div> </xsl:template>\[/code\]I would like to make my xsl do this:[*]In outer for-each cycle xsl reads value of MenuId attribute of \[code\]<row>\[/code\] of \[code\]<MenuList>\[/code\].[*]then in inner cycle for-each my xsl compares that value to every value of MenuAttribute of \[code\]<row>\[/code\]'s of \[code\]<FunctionList>\[/code\][*]then my xsl reads the value of MenuId attribute of following \[code\]<row>\[/code\] of \[code\]<MenuList>\[/code\] and repeats second stepBy doing this i will be able to make html menu buttons and submenu buttons below corresponding button. connection between menu and submenu buttons is recognized by MenuId attributeIn normal programming language what i am trying to do (with xsl) would look like this:\[code\]foreach (xitems as xitem) foreach (yitems as yitem) if xitem == yitem do smth\[/code\]Could anyone give any advice or modify my code in order to solve my issue? I would be grateful
 
Back
Top