Copied to clipboard

Flag this post as spam?

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


  • syn-rg 282 posts 425 karma points
    Nov 10, 2010 @ 00:12
    syn-rg
    0

    Upgrade 4.0 to 4.5 has broken my navigation

    I'm building a new site, and have updated the new instance from 4.0 to 4.5. Now my navigation XSLT is throwing errors. My top navigation uses a drop down menu and now isn't working.

    The error I receive is:

    Error occured

    System.OverflowException: Value was either too large or too small for an Int32.
    at System.Convert.ToInt32(Double value)
    at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
    at System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType xmlType, Object value, Type destinationType)
    at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args)
    at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, IList`1 parent)
    at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer, Boolean closeWriter)
    at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter results)
    at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results)
    at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)

    I think I've narrowed the problem down to this line:

    <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::node[@level=1]"/>


    I've been searching around the forums trying to find any navigation problems with the same XSLT as mine, but haven't had any success. So I'm not sure how I should write this with the new schema, can anyone help with my XSLT? Thanks in advance.

    Below is the full XSLT that I'm using for the top navigation.

    <?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"/>

    <!-- update this variable on how deep your navigation should be -->
    <xsl:variable name="maxLevel" select="5"/>

    <xsl:template match="/">
      <div class="ddsmoothmenu" id="global_nav">
        <ul>
          <xsl:call-template name="drawNodes">  
            <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::node[@level=1]"/>
            
            <!-- THIS CODE IS CAUSING THE ERROR!!!!
            
            <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::node[@level=1]"/>
            
            -->  
          </xsl:call-template>
        </ul>
      </div>
      <xsl:variable name="ddlevel">//ddlevelsmenu.setup("ddtopmenubar", "topbar");</xsl:variable>
      <xsl:value-of select="umbraco.library:RegisterClientScriptBlock('ddlevel', $ddlevel, true())"/>
        </xsl:template>
        <xsl:template name="drawNodes">
          <xsl:param name="parent"/>
          <xsl:if test="umbraco.library:IsProtected($parent/@id,
    $parent/@path) = 0 or (umbraco.library:IsProtected($parent/@id,
    $parent/@path) = 1 and umbraco.library:IsLoggedOn() = 1)"
    >
            <xsl:for-each select="$parent/node
    [string(./data [@alias='topMenu']) = '1' and @level &lt;= $maxLevel
    and (umbraco.library:IsProtected(@id, @path) = false() or
    umbraco.library:HasAccess(@id, @path) = true())]"
    >
              <xsl:variable name="liId">
                <xsl:call-template name="replaceCharsInString">
                  <xsl:with-param name="stringIn" select="@nodeName"/>
                  <xsl:with-param name="charsIn" select="' '"/>
                  <xsl:with-param name="charsOut" select="'_'"/>
                </xsl:call-template>
              </xsl:variable>
              <li>
                <xsl:attribute name="id"><xsl:value-of select="$liId" /></xsl:attribute>
                <a href="{umbraco.library:NiceUrl(@id)}">
                  <xsl:if test="$currentPage/ancestor-or-self::node/@id = @id">
                    <xsl:attribute name="class">current</xsl:attribute>
                  </xsl:if>
                  <xsl:if test="count(./node [string(./data [@alias='topMenu']) = '1' and @level &lt;= $maxLevel]) &gt; 0">
                    <xsl:attribute name="rel"><xsl:value-of select="@id" /></xsl:attribute>
                  </xsl:if>
                  <xsl:choose>
                    <xsl:when test="./data [@alias = 'topMenuImage'] != ''">
                    </xsl:when>
                    <xsl:otherwise>
                      <xsl:value-of select="@nodeName"/>
                    </xsl:otherwise>
                  </xsl:choose>
                </a>  
                <xsl:if test="count(./node [string(./data [@alias='topMenu']) = '1' and @level &lt;= $maxLevel]) &gt; 0">   
                  <ul class="ddPageTools_submenustyle" id="{@id}">
                    <xsl:call-template name="drawNodes">    
                      <xsl:with-param name="parent" select="."/>
                    </xsl:call-template>
                  </ul>
                </xsl:if>
              </li>
            </xsl:for-each>
          </xsl:if>
        </xsl:template>
        <xsl:template name="replaceCharsInString">
          <xsl:param name="stringIn"/>
          <xsl:param name="charsIn"/>
          <xsl:param name="charsOut"/>
          <xsl:choose>
            <xsl:when test="contains($stringIn,$charsIn)">
              <xsl:value-of select="concat(substring-before($stringIn,$charsIn),$charsOut)"/>
              <xsl:call-template name="replaceCharsInString">
                <xsl:with-param name="stringIn" select="substring-after($stringIn,$charsIn)"/>
                <xsl:with-param name="charsIn" select="$charsIn"/>
                <xsl:with-param name="charsOut" select="$charsOut"/>
              </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="$stringIn"/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:template>

    </xsl:stylesheet>


  • Almir Vereget 62 posts 150 karma points
    Nov 10, 2010 @ 09:27
    Almir Vereget
    0

    Hi,

    if you upgraded to v4.5 then you are using new xml schema, and your xslt won't work (there is no more "node" element).

    Your code will be something like:

    <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::*[@level=1]"/>

    Here you can see some examples with new schema, and update your xslt, or you can continue using old schema but then be shure to change UseLegacyXmlSchema setting in the config/UmbracoSettings.config file to true.

    Cheers.

     

  • Powellze 38 posts 73 karma points
    Nov 10, 2010 @ 11:43
    Powellze
    0

    Another note, When you upgrade ensure that you republish the site as the new schema might not have been updated in the DB. This was a mistake I found recently.

    It's pretty easy to upgrade the XSLT to the new version when you get the hang of it and it is much quicker to write. However be aware you may have to rewrite more XSLT documents than you realise.

    Just remember when switching between the new and old schema to republish the site.

     

    Tim

  • syn-rg 282 posts 425 karma points
    Nov 11, 2010 @ 00:15
    syn-rg
    0

    Thanks for the help Almir and Tim,

    That piece of code was needed. Then I ran the XSLT through the convertor created by Tommy Poulson. High five!

    Now I've got my Main, Side and Footer menu's all working perfectly!

    Cheers!

     

Please Sign in or register to post replies

Write your reply to:

Draft