Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • dwarakesh 50 posts 69 karma points
    Sep 13, 2011 @ 12:14
    dwarakesh
    0

    xslt help

    Hi

    <xsl:if test="$currentPage/descendant::* [@level=1]">                    
                        <xsl:text>current</xsl:text>
                      </xsl:if>

    Wat will be the value of current

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Sep 13, 2011 @ 13:50
    Chriztian Steinmeier
    0

    Hi dwarakesh,

    The way you're using it, current is just a piece of text that you're injecting, so it carries no "value" other than "current".

    The test you're performing though, will only return true(), when tested in the XSLT visualizer, because that's the only place $currentPage will point to something above level 1 pages (if you pick the "Content" node as $currentPage).

    So, in effect, if that piece of XSLT is running in your site, you won't get any "current" output...

    What are you trying to do?

    /Chriztian

  • dwarakesh 50 posts 69 karma points
    Sep 13, 2011 @ 14:11
    dwarakesh
    0

    Hey

    This is XSlt i m using for Multi level navigation.. i m getting the output which i intended to.. but keeps me wondering how it comes. Check the bolded part of Xslt.. i dont know wats its doing ..

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
     version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:msxml="urn:schemas-microsoft-com:xslt"
     xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:tagsLib="urn:tagsLib" xmlns:BlogLibrary="urn:BlogLibrary"
     exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib BlogLibrary ">


    <xsl:output method="xml" omit-xml-declaration="yes" />

    <xsl:param name="currentPage"/>

    <!-- Input the documenttype you want here -->
    <!-- Typically '1' for topnavigtaion and '2' for 2nd level -->
    <!-- Use div elements around this macro combined with css -->
    <!-- for styling the navigation -->
    <xsl:variable name="level" select="1"/>

    <xsl:template match="/">

     
    <ul id="jsddm">

      <li>
           <xsl:attribute name="class">
             <xsl:if test="$currentPage/@level=$level">
              <xsl:text>current</xsl:text>
              </xsl:if>
         </xsl:attribute>
         

     </li>
     
      <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']"> 
      <li>
         <xsl:attribute name="class">
             <xsl:if test="$currentPage/@id=@id">
              <xsl:text>current</xsl:text>
              </xsl:if>
         </xsl:attribute>
       
       
        <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a>   
        <!-- Drop Down Menu -->
        <xsl:if test="count(./* [@isDoc and string(umbracoNaviHide) != '1']) &gt; 0">
           <ul>
             <xsl:for-each select="./* [@isDoc and string(umbracoNaviHide) != '1']">
                 <li>
                  
                    <xsl:attribute name="class">
                       <xsl:if test="$currentPage/descendant::* [@level=1]">                   
                        <xsl:text>current</xsl:text>
                      </xsl:if>
                    </xsl:attribute>
                  
                   <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a></li>
             </xsl:for-each>
           </ul>
        </xsl:if>
      <!-- End of Drop Down Menu -->
       
      </li>
      </xsl:for-each>
      </ul>

    </xsl:template>

    </xsl:stylesheet>

     


     

     

     

  • Rich Green 2246 posts 4008 karma points
    Sep 13, 2011 @ 14:23
    Rich Green
    0

    The code you are refering adds an class to the <li> tag named 'current', the idea being that you can style the item in your navigation to show the user which page they are currently on.

    Rich

  • dwarakesh 50 posts 69 karma points
    Sep 14, 2011 @ 12:05
    dwarakesh
    0

    Hey

     Wats the functionality of below line used in XSlt .  Especially that select part

           <xsl:for-each select="./* [@isDoc and string(umbracoNaviHide) != '1']">

     

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
     version="1.0"
     xmlns:xsl="www.w3.org/1999/XSL/Transform"
     xmlns:msxml="urn:schemas-microsoft-com:xslt"
     xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:tagsLib="urn:tagsLib" xmlns:BlogLibrary="urn:BlogLibrary"
     exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib BlogLibrary ">


    <xsl:output method="xml" omit-xml-declaration="yes" />

    <xsl:param name="currentPage"/>

    <!-- Input the documenttype you want here -->
    <!-- Typically '1' for topnavigtaion and '2' for 2nd level -->
    <!-- Use div elements around this macro combined with css -->
    <!-- for styling the navigation -->
    <xsl:variable name="level" select="1"/>

    <xsl:template match="/">

     
    <ul id="jsddm">

      <li>
           <xsl:attribute name="class">
             <xsl:if test="$currentPage/@level=$level">
              <xsl:text>current</xsl:text>
              </xsl:if>
         </xsl:attribute>
         

     </li>
     
      <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']"> 
      <li>
         <xsl:attribute name="class">
             <xsl:if test="$currentPage/@id=@id">
              <xsl:text>current</xsl:text>
              </xsl:if>
         </xsl:attribute>
       
       
        <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a>   
        <!-- Drop Down Menu -->
        <xsl:if test="count(./* [@isDoc and string(umbracoNaviHide) != '1']) &gt; 0">
           <ul>
             <xsl:for-each select="./* [@isDoc and string(umbracoNaviHide) != '1']">
                 <li>
                  
                    <xsl:attribute name="class">
                       <xsl:if test="$currentPage/descendant::* [@level=1]">                   
                        <xsl:text>current</xsl:text>
                      </xsl:if>
                    </xsl:attribute>
                  
                   <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a></li>
             </xsl:for-each>
           </ul>
        </xsl:if>
      <!-- End of Drop Down Menu -->
       
      </li>
      </xsl:for-each>
      </ul>

    </xsl:template>

    </xsl:stylesheet>

     


     

     

     

     

     

Please Sign in or register to post replies

Write your reply to:

Draft