Jump to content

How To Create Xml dynamic Menu


Gokulanand

Recommended Posts

Hi,Can anybody suggest me how to create xml dynamic menu.In a web application there are hundred menus and ten users only very few of them will have the access (RIGHTS) to the all menus, remaining will have some restriction. They may not have rights(that menu also should not be displayed)all these menus are going to be java classes.When a user is logged in, he will be having rights to access to use some menus, only that classes should loaded and only that menus should get displayed.Using Xml Dynamic menu i want to do this.Suggest me OR Guide i am a newbiee to Xml.Thank u

Link to comment
Share on other sites

I can't suggest much without knowing the full server side's system... hmm...A thing you might do, would be to add an attribute to each menu about which group should have acces to it. Example:

<menu>  <item access="admin">    <title>Site control panel</title>    <link>http://example.com/admin/</link>  </item>  <item>    <title>Home</title>    <link>http://example.com</link>  </item></menu>

Then use the server side script to generate only the menus that have the corresponding attribute(s). You may use XSLT too, but there's a tricky point here for dealing with security. Hmm... you may use the server side to generate the appropriate XML and apply a fixed XSLT that would render the menus there.Again... nothing is certain. There are many ways to do the things, but it all depends on the rest of the system.

Link to comment
Share on other sites

I did something similar to this in a relational database once.Applying xml to it, you could have a relational list of menu items and users which you could administer with an xsl form.For the menu:

<menu>   <item id="homepage">      <text>Home page</text>      <link>"http://someotherwebpage.htm"</link>   </item> ..</menu>

For the users:

<users>  <user>   <name>A User Name</name>   <password>Cillitbangpassword</password>   <loginname>user login</loginname>  </user></users>

Then have another xml document which is like this:

<usermenuitem>  <item>selectedmenuitem</item>  <userid>selecteduser</userid>  <privelege>useraccesslevel</privelege></usermenuitem>

You can then link the values through xsl on the other documents containing the users and menu items:

<xsl:template match="usermenuitem"><select id="menuitem">  <xsl:for-each select="document('menuitems.xml')//menu/item">    <option>      <xsl:attribute name="value">        <xsl:value-of select="link" />      </xsl:attribute >      <xsl:value-of select="text">     </option>  </xsl:for-each></select><select id="linktouser">  <xsl:for-each select="document('users.xml')//users/user">    <option>      <xsl:attribute name="value">        <xsl:value-of select="loginname" />      </xsl:attribute >      <xsl:value-of select="name">     </option>  </xsl:for-each></select></xsl:template>

This would then link the user and menu items into a single file and allow you to add or remove priveleges (with some code) by using drop downs looking at the menu items and the user lists.Then you can use an xsl:for-each element to load the link information from the menu document into the web page.Using the "document()" xpath function allows you to gather information from other documents on the server and isolate each bit of information you want to store.I hope this helps, if it doesn't I apologise :) .Dooberry

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...