Copied to clipboard

Flag this post as spam?

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


  • Floffy 26 posts 33 karma points
    Jul 23, 2011 @ 21:36
    Floffy
    0

    Translate menu to new schema

    Tryed to translat xslt 2. and 3. level menu to new schema, but with no luck.

    It renders no nodes.

    Here is my code so far:

    <?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"
      exclude-result-prefixes="msxml umbraco.library">

    <xsl:output method="xml" omit-xml-declaration="yes" />
    <xsl:param name="currentPage"/>
    <xsl:variable name="level" select="1"/>
    <xsl:template match="/">
      <xsl:call-template name="printListe">
        <xsl:with-param name="node" select="$currentPage/ancestor-or-self::*[@isDoc and @level = 2]"/>  
        <xsl:with-param name="id" select="string('leftMenu')"/>  
      </xsl:call-template>
    </xsl:template>
    <xsl:template name="printListe">
      <xsl:param name="node"/>
      <xsl:param name="id"/>
    <div id="LeftMenu"
    <ul class="sideMenu">
    <xsl:if test="$id != ''">
    <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
    </xsl:if>
    <xsl:for-each select="$node/node [@nodeTypeAlias != 'DateFolder' and @nodeTypeAlias != 'LBKnewsItem']">
    <li>
      <xsl:if test="$currentPage/ancestor-or-self::*[@isDoc]/@id = current()/@id">
        <xsl:attribute name="class">here</xsl:attribute>
      </xsl:if>
      <href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a>
      <xsl:if test="$currentPage/ancestor-or-self::*[@isDoc]/@id = current()/@id">
        <xsl:if test="current()/@level = 3">
          <xsl:if test="count(./node) &gt; 0">
            <xsl:call-template name="printListe">
              <xsl:with-param name="node" select="."/>
            </xsl:call-template>
          </xsl:if>
        </xsl:if>
      </xsl:if>
    </li>
    </xsl:for-each>
    </ul>
    </div>
    </xsl:template>
    </xsl:stylesheet>

    Any ideas?

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Jul 23, 2011 @ 23:23
    Dennis Aaen
    0

    Hi Fioffy,

    I think you are very close to a solution that works. As I see it, it's just small changes as needed if I'm right.
    You might try something like.

    <?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"
      exclude-result-prefixes="msxml umbraco.library">

    <xsl:outputmethod="xml"omit-xml-declaration="yes"/>
    <xsl:paramname="currentPage"/>
    <xsl:variablename="level"select="1"/>
    <xsl:templatematch="/">
      <xsl:call-templatename="printListe">
        <xsl:with-paramname="node"select="$currentPage/ancestor-or-self::*[@isDoc and @level = 2]"/>  
        <xsl:with-paramname="id"select="string('leftMenu')"/>  
      </xsl:call-template>
    </xsl:template>
    <xsl:templatename="printListe">
      <xsl:paramname="node"/>
      <xsl:paramname="id"/>
    <divid="LeftMenu">
    <ulclass="sideMenu">
    <xsl:iftest="$id != ''">
    <xsl:attributename="id"><xsl:value-ofselect="$id"/></xsl:attribute>
    </xsl:if>
    <xsl:for-eachselect="$node/*[@isDoc][name() != 'DateFolder' and name() != 'LBKnewsItem']">
    <li>
      <xsl:iftest="$currentPage/ancestor-or-self::*[@isDoc]/@id = current()/@id">
        <xsl:attributename="class">here</xsl:attribute>
      </xsl:if>
      <ahref="{umbraco.library:NiceUrl(@id)}"><xsl:value-ofselect="@nodeName"/></a>
      <xsl:iftest="$currentPage/ancestor-or-self::*[@isDoc]/@id = current()/@id">
        <xsl:iftest="current()/@level = 3">
          <xsl:iftest="count(./*[@isDoc]) &gt; 0">
            <xsl:call-templatename="printListe">
              <xsl:with-paramname="node"select="."/>
            </xsl:call-template>
          </xsl:if>
        </xsl:if>
      </xsl:if>
    </li>
    </xsl:for-each>
    </ul>
    </div>
    </xsl:template>
    </xsl:stylesheet>

    Hope this can help you.

    /Dennis

Please Sign in or register to post replies

Write your reply to:

Draft