Hi All,
Below is the XML snippet
<site-map>
<segment>
<node visible-in-breadcrumbs="true"><name>Product</name>
<node visible-in-breadcrumbs="true"><name>Academic</name>
<ExternalLink>
http://web.lis.com/</ExternalLink></node>
<node visible-in-breadcrumbs="true"><name>back Screening one</name>
<ExternalLink>
http://www.acc.com</ExternalLink></node>
<node visible-in-breadcrumbs="true"><name>acc</name>
<ExternalLink>
http://www.acc.com</ExternalLink></node>
</node>
<node visible-in-breadcrumbs="true"><name>About</name>
<node visible-in-breadcrumbs="true"><name>history</name>
<ExternalLink>
http://web.his.com/</ExternalLink></node>
<node visible-in-breadcrumbs="true"><name>Careers</name>
<ExternalLink>
http://www.acc.com/careers</ExternalLink></node>
</node>
</segment>
</site-map>
I want to display all the child node of "Products". Secondly, I would like to render HTML output as below:
A
academy
Accuratez
B
back Screening
Conditions are:
1. Grouping all the node under their respective initial.
2. <Name> tag value starting with small letters should appear first. But if say "Johan" and "johan" are two different values then "johan" shall appear before "Johan".
3. If visible-in-breadcrumbs value is true then only parent node shall be selected and respectively based on the same child nodes shall be displayed.
Based on the below snippet, only 10 node values are getting displayed but as I enter the 11 node value, XSLT gets corrupted. Not sure about where things went wrong.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->
<xsl:stylesheet version="1.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"><xsl:variable name="vLower" select= "'abcdefghijklmnopqrstuvwxyz'"/>
<xsl:variable name="vUpper" select= "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
<xsl:key name="kInitial" match="node/node[
@visible-in-breadcrumbs='true']" use="translate(substring(label, 1, 1), $vLower, $vUpper)" />
<xsl:template match="/">
<xsl:apply-templates select="/site-map/segment/node/node[
@visible-in-breadcrumbs='true']">
<xsl:sort select="label"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="node/node[
@visible-in-breadcrumbs='true']">
<xsl:variable name="initial" select="translate(substring(label, 1, 1), $vLower, $vUpper)" />
<xsl:variable name="courses" select="key('kInitial', $initial)" />
<xsl:if test="generate-id() = generate-id($courses[1])">
<xsl:if test="ancestor-or-self::node/label='Products'">
<xsl:value-of select="$initial" disable-output-escaping="yes"/>
</xsl:if>
</xsl:if>
<xsl:choose>
<xsl:when test="ancestor-or-self::node/label='Products'">
<!--xsl:value-of select="ancestor-or-self::node" / -->
<xsl:apply-templates select="node/node[
@visible-in-breadcrumbs='true']">
<xsl:copy>
<xsl:apply-templates select="node/node[
@visible-in-breadcrumbs='true']">
<xsl:sort select="label"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:apply-templates>
<xsl:copy>
<xsl:copy-of select="
@visible-in-breadcrumbs"/><xsl:copy-of select="
@id"/>
<xsl:apply-templates select="node/node[
@visible-in-breadcrumbs='true']" />
<li><a><xsl:attribute name="href"><xsl:value-of select="position()"/></xsl:attribute><xsl:value-of select="label"/></a></li>
</xsl:copy>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
It would be great if anyone can provide me solution based on the above requirement would be highly appreciated. On the second hand, basically I am trying to achieve this functionality using sitemap component but no luck on that area so though to create one of my kind to meet the requirement.
Regards,
Ace