Quantcast
Viewing all articles
Browse latest Browse all 7205

ASPxNavBar - How to bind a control to an XML file by using an XSLT file

When the ASPxNavBar is bound to XmlDataSource, the latter should suit the following structure:

[XML]
<Root><GroupText="Reports"><ItemText=" ... "NavigateUrl="..."ImageUrl="..."/></Group></Root>

In this case, XmlDataSource can retrieve and synchronize the Text, NavigateUrl and ImageUrl XML attributes with ASPxNavBar properties. However, in real applications, data seldom suits this structure. Most often, an XML schema contains several sub- nodes that describe some element. For instance:

[XML]
<Menus><Menutext="abc1"><ProductID>193</ProductID><ProductName>090 - Introduction</ProductName><PTName>Video</PTName></Menu></Menus>

XmlDataSource cannot parse such a schema. However, XmlDataSource allows specifying an XSLT file where you can define a transformation that will be applied to the specified DataFile. In this case, it is necessary to utilize the GroupContentTemplate. For example:

[XML]
<xsl:stylesheetversion="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:templatematch="/"><Menus><xsl:for-eachselect="//Menus/*"><MenuText="{ProductName}"ProductID="{ProductID}"></Menu></xsl:for-each></Menus></xsl:template></xsl:stylesheet><GroupContentTemplate> ProductID:<asp:LabelID="Label1"runat="server"Text='<%# DataBinder.Eval(Container.Group.DataItem, "ProductID") %>'></asp:Label></GroupContentTemplate>

You can learn more about XML transformation files from the following sources:

Using XSLT files with the new XMLDataSource control
XSLT - Transformation

Question Comments

Added By: Ken Post 2 at: 9/24/2015 12:09:07 PM    

Various links are broken...

Added By: Alessandro (DevExpress Support) at: 9/24/2015 12:40:29 PM    Hi,

Thank you for pointing out this issue. I have corrected the broken link.

Viewing all articles
Browse latest Browse all 7205

Trending Articles