tags:

views:

731

answers:

2

Hi I have a XML below

<?xml version="1.0" encoding="utf-8" ?>
<siteMap>
    <siteMapNode id="tcm:11-5821-64" 
        parentid="tcm:11-5-4"
        depth="0" 
        url="/"
        title="Home" 
        showLeftNav="true" 
        page_type="false" 
        showSecureContent="false" 
        navOrderSGTitle="Root"
        externalURL="" 
        target="_self" 
        accessRight="" />
    <siteMapNode id="tcm:11-577-64" 
        parentid="tcm:11-149-4"
        depth="1"
        url="/dentists" 
        title="Dentists"
        showLeftNav="true" 
        page_type="true"
        showSecureContent="false"
        navOrderSGTitle="010Dentists"
        externalURL=""
        target="_self" 
        accessRight="" />
    <siteMapNode id="tcm:11-164-4" 
        parentid="tcm:11-164-4" 
        depth="2"
        url="/dentists/mybda" 
        title="My BDA"
        showLeftNav="true" 
        page_type="false" 
        showSecureContent="true" 
        navOrderSGTitle="010My BDA"
        externalURL="/MyBDA/index.aspx" 
        target="_self" 
        accessRight="Member Only" />
</siteMap>

and the xslt used for formatting is here:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
<xsl:output method="html" indent="yes"/>
<xsl:param name="currentpageid"></xsl:param>
<xsl:param name="securecontent"></xsl:param>
<xsl:param name="maxdepth"></xsl:param>
<xsl:param name="ismember"></xsl:param>

<xsl:template match="/">
  <div id="contentleft">
  <xsl:variable name="varcheckurl" select="//siteMapNode[@id=$currentpageid]/@url"/>      
  <xsl:choose>

    <xsl:when test="contains($varcheckurl,'.aspx')">

      <xsl:variable name="parentnode" select="//siteMapNode[@id=$currentpageid]/parent::*"/>

      <xsl:variable name="parentpageid" select="$parentnode/@id"/>

      <xsl:if test="//siteMapNode[@id=$parentpageid]/@depth &gt; 0">
        <xsl:attribute name="class">cont-top</xsl:attribute>
        <h2>
          <xsl:value-of select="//siteMapNode[@id=$parentpageid]/@title"/>
        </h2>
      </xsl:if>

      <div id="contentNav" class="contentnav-home">
        <ul>
          <xsl:apply-templates select="//siteMapNode[@id=$parentpageid]/siteMapNode[@showLeftNav='true']" >
            <xsl:sort select="@navOrderSGTitle" order="ascending"/>
            <xsl:with-param name="varpageid" select="$parentpageid"/>
          </xsl:apply-templates>
        </ul>
      </div>
    </xsl:when>


    <xsl:otherwise>
      <xsl:if test="//siteMapNode[@id=$currentpageid]/@depth &gt; 0">
        <xsl:attribute name="class">cont-top</xsl:attribute>
        <h2>
          <xsl:value-of select="//siteMapNode[@id=$currentpageid]/@title"/>
        </h2>
      </xsl:if>
      <div id="contentNav" class="contentnav-home">
        <ul>
          <xsl:apply-templates select="//siteMapNode[@id=$currentpageid]/siteMapNode[@showLeftNav='true']" >
            <xsl:sort select="@navOrderSGTitle" order="ascending"/>
            <xsl:with-param name="varpageid" select="$currentpageid"/>
          </xsl:apply-templates>
        </ul>
      </div>
    </xsl:otherwise>
  </xsl:choose>
</div>

<xsl:choose>
  <xsl:when test="@showSecureContent='true' and @accessRight='Member Only'">
    <xsl:if test="$securecontent='true'  and $ismember='true'">
      <li>
        <xsl:if test="count(.//siteMapNode[@id=$varpageid]) &gt; 0 or @id=$currentpageid">
          <xsl:attribute name="class">active</xsl:attribute>
        </xsl:if>
        <a href="#">
          <xsl:attribute name="title">
            <xsl:value-of select="@title"/>
          </xsl:attribute>
            <xsl:if test="@externalURL='' and @target='_self'">
    <xsl:attribute name="href">
    <xsl:value-of select="@url"/>
    </xsl:attribute>
    <xsl:attribute name="target">_self</xsl:attribute>
            </xsl:if>

            <xsl:if test="@externalURL='' and @target='_blank'">
    <xsl:attribute name="href">
    <xsl:value-of select="@url"/>
    </xsl:attribute>
    <xsl:attribute name="target">_blank</xsl:attribute>
            </xsl:if>

   <xsl:if test="@externalURL!=''and @target='_self'">
    <xsl:attribute name="href">
    <xsl:value-of select="@externalURL"/>
    </xsl:attribute>
    <xsl:attribute name="target">_self</xsl:attribute>
            </xsl:if>

            <xsl:if test="@externalURL!=''and @target='_blank'">
    <xsl:attribute name="href">
    <xsl:value-of select="@externalURL"/>
    </xsl:attribute>
    <xsl:attribute name="target">_blank</xsl:attribute>
            </xsl:if>     

          <xsl:value-of select="@title"/>
        </a>
      </li>
    </xsl:if>
  </xsl:when>


  <xsl:when test="@showSecureContent='true' and @accessRight!='Member Only'">
    <xsl:if test="$securecontent='true'">
      <li>
      <xsl:if test="count(.//siteMapNode[@id=$varpageid]) &gt; 0 or @id=$currentpageid">
        <xsl:attribute name="class">active</xsl:attribute>
      </xsl:if>
      <a href="#">
          <xsl:attribute name="title">
            <xsl:value-of select="@title"/>
          </xsl:attribute>
            <xsl:if test="@externalURL='' and @target='_self'">
    <xsl:attribute name="href">
    <xsl:value-of select="@url"/>
    </xsl:attribute>
    <xsl:attribute name="target">_self</xsl:attribute>
            </xsl:if>

            <xsl:if test="@externalURL='' and @target='_blank'">
    <xsl:attribute name="href">
    <xsl:value-of select="@url"/>
    </xsl:attribute>
    <xsl:attribute name="target">_blank</xsl:attribute>
            </xsl:if>

   <xsl:if test="@externalURL!=''and @target='_self'">
    <xsl:attribute name="href">
    <xsl:value-of select="@externalURL"/>
    </xsl:attribute>
    <xsl:attribute name="target">_self</xsl:attribute>
            </xsl:if>

            <xsl:if test="@externalURL!=''and @target='_blank'">
    <xsl:attribute name="href">
    <xsl:value-of select="@externalURL"/>
    </xsl:attribute>
    <xsl:attribute name="target">_blank</xsl:attribute>
            </xsl:if>   
        <xsl:value-of select="@title"/>
      </a>
    </li>
    </xsl:if>
  </xsl:when>


  <xsl:when test="@showSecureContent!='true' and @accessRight='Member Only'">
    <xsl:if test="$ismember='true'">
      <li>
        <xsl:if test="count(.//siteMapNode[@id=$varpageid]) &gt; 0 or @id=$currentpageid">
          <xsl:attribute name="class">active</xsl:attribute>
        </xsl:if>
        <a href="#">
          <xsl:attribute name="title">
            <xsl:value-of select="@title"/>
          </xsl:attribute>
            <xsl:if test="@externalURL='' and @target='_self'">
    <xsl:attribute name="href">
    <xsl:value-of select="@url"/>
    </xsl:attribute>
    <xsl:attribute name="target">_self</xsl:attribute>
            </xsl:if>

            <xsl:if test="@externalURL='' and @target='_blank'">
    <xsl:attribute name="href">
    <xsl:value-of select="@url"/>
    </xsl:attribute>
    <xsl:attribute name="target">_blank</xsl:attribute>
            </xsl:if>

   <xsl:if test="@externalURL!=''and @target='_self'">
    <xsl:attribute name="href">
    <xsl:value-of select="@externalURL"/>
    </xsl:attribute>
    <xsl:attribute name="target">_self</xsl:attribute>
            </xsl:if>

            <xsl:if test="@externalURL!=''and @target='_blank'">
    <xsl:attribute name="href">
    <xsl:value-of select="@externalURL"/>
    </xsl:attribute>
    <xsl:attribute name="target">_blank</xsl:attribute>
            </xsl:if>
          <xsl:value-of select="@title"/>
        </a>
      </li>
    </xsl:if>
  </xsl:when>


  <xsl:otherwise>
    <li>
      <xsl:if test="count(.//siteMapNode[@id=$varpageid]) &gt; 0 or @id=$currentpageid">
        <xsl:attribute name="class">active</xsl:attribute>
      </xsl:if>
      <a href="#">
          <xsl:attribute name="title">
            <xsl:value-of select="@title"/>
          </xsl:attribute>
            <xsl:if test="@externalURL='' and @target='_self'">
    <xsl:attribute name="href">
    <xsl:value-of select="@url"/>
    </xsl:attribute>
    <xsl:attribute name="target">_self</xsl:attribute>
            </xsl:if>

            <xsl:if test="@externalURL='' and @target='_blank'">
    <xsl:attribute name="href">
    <xsl:value-of select="@url"/>
    </xsl:attribute>
    <xsl:attribute name="target">_blank</xsl:attribute>
            </xsl:if>

   <xsl:if test="@externalURL!=''and @target='_self'">
    <xsl:attribute name="href">
    <xsl:value-of select="@externalURL"/>
    </xsl:attribute>
    <xsl:attribute name="target">_self</xsl:attribute>
            </xsl:if>

            <xsl:if test="@externalURL!=''and @target='_blank'">
    <xsl:attribute name="href">
    <xsl:value-of select="@externalURL"/>
    </xsl:attribute>
    <xsl:attribute name="target">_blank</xsl:attribute>
            </xsl:if>   
        <xsl:value-of select="@title"/>
      </a>
    </li>
  </xsl:otherwise>
</xsl:choose>

</xsl:template>

</xsl:stylesheet>

Problem is that I want if page_type=false in XML then it should have class="active" and should come in left navigation part.

+3  A: 

It doesn't appear that you're actually testing for page_type in the XSL, or at least I can't find where you are. You need something like this:

<xsl:if test="@page_type='true'">
    <xsl:attribute name="class">active</xsl:attribute>
</xsl:if>
Philip Morton
I didn't have added any condition with "page_type". But the above condition written by you will not work as it become specific for page_type. there are more other conditions with it. I need to work it with all conditions.
MKS
Then you can use an 'or' or 'and' statement in the 'test'.
Philip Morton
no its not like that we need to check all the conditions given in xslt. Please have a look into xslt and xml.
MKS
A: 

hi i have a proble with xml and xslt i have one xml file with some comment i want to uncomment it example -->

i want to uncomment this commented tag please help me in advance i am very new in xslt thanks in advance

vivek4075