I have got below given XML output:
<?xml version="1.0"?>
<navigation path="/english">
<resources>
<Copyright>© 2009 mysite. All Rights Reserved.</Copyright>
</resources>
<node title="010. Terms and Conditions" id="tcm:233-242834-64" url="termscondition.aspx" compTitle="Terms and Conditions"/>
<node title="Root" id="tcm:233-38288-4" url="/">
<node title="040. Skywards" id="tcm:233-38448-4" url="/Skywards/skywards.aspx" indexpage="tcm:233-192262-64" compTitle="Skywards" imageSrcOn="/english/Images/skywards_on_tcm233-191728.gif" imageSrcOff="/english/Images/skywards_off_tcm233-191727.gif" imageSrcSelected="/english/Images/skywards_sel_tcm233-191730.gif" imageSrcSelectedOn="/english/Images/skywards_on2_tcm233-191729.gif" accessKey="S" Group="SB">
<node title="010. Membership Tiers" id="tcm:481-38882-4" url="/Skywards/membership_tiers/membership_tiers.aspx" indexpage="tcm:481-194317-64" compTitle="Membership Tiers"/>
<node title="020. Earning Miles" id="tcm:481-38883-4" url="/Skywards/earning_miles/earning_miles.aspx" indexpage="tcm:481-194318-64" compTitle="Earning Skywards Miles"/>
<node title="030. Travel Rewards" id="tcm:481-38884-4" url="/Skywards/travel_rewards/travel_rewards.aspx" indexpage="tcm:481-194320-64" compTitle="Travel Rewards"/>
</node>
<node title="H030. Search" id="tcm:233-38483-4" url="/search/search.aspx" indexpage="tcm:233-214259-64" compTitle="Search" localTitle="Search" accessKey="3" Group="SB"/>
<node title="H010. Homepage" id="tcm:233-192367-64" url="/index.aspx" localTitle="Home" accessKey="0" Group="Home"/>
<node title="H020. Skyward Homepage" id="tcm:233-143367-64" url="/index.aspx" localTitle="Home" accessKey="0" Group="Home"/>
</node>
<node title="footer">
<node title="F010. 000. Sitemap" id="tcm:233-192374-64" url="/sitetools/sitemap.aspx" accessKey="4" compTitle="Sitemap"/>
<node title="F060. Accessibility" id="tcm:233-192369-64" url="/sitetools/accessibility.aspx" compTitle="Accessibility Statement"/>
<node title="F030. Operational Updates" id="tcm:233-192370-64" url="/sitetools/operational_updates.aspx" compTitle="Operational Updates"/>
<node title="F050. Privacy Policy" id="tcm:233-192371-64" url="/sitetools/privacy_policy.aspx" compTitle="Privacy Policy"/>
<node title="F040. Terms & Conditions" id="tcm:233-192449-64" url="/sitetools/terms_and_conditions.aspx" compTitle="Terms & Conditions"/>
</node>
</navigation>
Now want to write an xslt which will group the nodes on the basis of attribute “Group” with their value and add them in seperate node so that my ouput will be as given below:
<?xml version="1.0"?>
<navigation path="/english">
<resources>
<Copyright>© 2009 mysite. All Rights Reserved.</Copyright>
</resources>
<node title="010. Terms and Conditions" id="tcm:233-242834-64" url="termscondition.aspx" compTitle="Terms and Conditions"/>
<node title="Root" id="tcm:233-38288-4" url="/">
<node title="040. Skywards" id="tcm:233-38448-4" url="/Skywards/skywards.aspx" indexpage="tcm:233-192262-64" compTitle="Skywards" imageSrcOn="/english/Images/skywards_on_tcm233-191728.gif" imageSrcOff="/english/Images/skywards_off_tcm233-191727.gif" imageSrcSelected="/english/Images/skywards_sel_tcm233-191730.gif" imageSrcSelectedOn="/english/Images/skywards_on2_tcm233-191729.gif" accessKey="S" Group="SB">
</node>
<node title="H030. Search" id="tcm:233-38483-4" url="/search/search.aspx" indexpage="tcm:233-214259-64" compTitle="Search" localTitle="Search" accessKey="3" Group="SB"/>
<node title="H010. Homepage" id="tcm:233-192367-64" url="/index.aspx" localTitle="Home" accessKey="0" Group="Home"/>
<node title="H020. Skyward Homepage" id="tcm:233-143367-64" url="/index.aspx" localTitle="Home" accessKey="0" Group="Home"/>
</node>
<node title="footer">
<node title="F010. 000. Sitemap" id="tcm:233-192374-64" url="/sitetools/sitemap.aspx" accessKey="4" compTitle="Sitemap"/>
<node title="F060. Accessibility" id="tcm:233-192369-64" url="/sitetools/accessibility.aspx" compTitle="Accessibility Statement"/>
<node title="F030. Operational Updates" id="tcm:233-192370-64" url="/sitetools/operational_updates.aspx" compTitle="Operational Updates"/>
<node title="F050. Privacy Policy" id="tcm:233-192371-64" url="/sitetools/privacy_policy.aspx" compTitle="Privacy Policy"/>
<node title="F040. Terms & Conditions" id="tcm:233-192449-64" url="/sitetools/terms_and_conditions.aspx" compTitle="Terms & Conditions"/>
</node>
<node GroupTitle="SB">
<nodes>
<node title="040. Skywards" id="tcm:233-38448-4" url="/Skywards/skywards.aspx" indexpage="tcm:233-192262-64" compTitle="Skywards" imageSrcOn="/english/Images/skywards_on_tcm233-191728.gif" imageSrcOff="/english/Images/skywards_off_tcm233-191727.gif" imageSrcSelected="/english/Images/skywards_sel_tcm233-191730.gif" imageSrcSelectedOn="/english/Images/skywards_on2_tcm233-191729.gif" accessKey="S" Group="SB">
</node>
<node title="H030. Search" id="tcm:233-38483-4" url="/search/search.aspx" indexpage="tcm:233-214259-64" compTitle="Search" localTitle="Search" accessKey="3" Group="SB"/>
</nodes>
</node>
<node GroupTitle="Home">
<nodes>
<node title="H010. Homepage" id="tcm:233-192367-64" url="/index.aspx" localTitle="Home" accessKey="0" Group="Home"/>
<node title="H020. Skyward Homepage" id="tcm:233-143367-64" url="/index.aspx" localTitle="Home" accessKey="0" Group="Home"/>
</nodes>
</node>
</navigation>
Please suggest!!
This stylesheet should do the trick:
The second template makes use of a technique known as Muenchian grouping. It can be a little complex at first to understand should you not be familiar with XSLT and XPath, but once you get it, it becomes a great tool. There’s a thorough explanation of it here.
EDIT: you could write the second template like this, if you find it more legible:
EDIT 2: okay, I hope this will do what you need: