Sunday, April 29, 2012

How the item is active based on position in xml using xslt

Here i will show how to create position  based div's from XML data source using xslt.The XML data source has parent attribute with three items .There is on click function to make the selected div as active .By default we will set the first items as active link

<?xml version="1.0" encoding="utf-8" ?> 
- <xsl:stylesheet version="1.0" xmlns:xsl="">
- <xsl:template match="/">
- <ul>
- <xsl:for-each select="Menu/Item">
- <xsl:if test="ItemType != 'Javascript'">
- <li>
- <xsl:if test="position() = 1">
- <xsl:attribute name="class">
- <a title="" onclick="return false;">
- <xsl:attribute name="href">
- <xsl:choose>
- <xsl:when test="position() = 1">
- <xsl:when test="position() = 2">
- <xsl:when test="position() = 3">
  <xsl:value-of select="ItemTitle" />

No comments: