Copied to clipboard

Flag this post as spam?

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


  • Maxime Dupierreux 5 posts 25 karma points
    Mar 23, 2012 @ 10:51
    Maxime Dupierreux
    0

    Loading Xslt: Value was either too large or too small for an Int32.

    Hi,

    I've upgraded my Umbraco from 4.5.2 to 4.7.11 and one of my macro is now giving me this error :

    Value was either too large or too small for an Int32.
    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 System.Xml.Xsl.CompiledQuery.Query.<xsl:template match="/">(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current, Double {urn:schemas-microsoft-com:xslt-debug}position, Double {urn:schemas-microsoft-com:xslt-debug}last, IList`1 {urn:schemas-microsoft-com:xslt-debug}namespaces) in C:\inetpub\website\xslt\WidgetLatestNewsWithNewsletter.xslt:line 57
      at System.Xml.Xsl.CompiledQuery.Query.<xsl:apply-templates>(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator , Double , Double )
      at System.Xml.Xsl.CompiledQuery.Query.Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
      at System.Xml.Xsl.CompiledQuery.Query.Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
      at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer)
      at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results)
      at umbraco.macro.GetXsltTransformResult(XmlDocument macroXML, XslCompiledTransform xslt, Dictionary`2 parameters)
      at umbraco.macro.loadMacroXSLT(macro macro, MacroModel model, Hashtable pageElements)

     

    here's the xslt file :


    <?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"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">


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

      <xsl:param name="currentPage"/>


      <xsl:template match="/">
        <xsl:if test="$currentPage/@level &gt; 1">

          <xsl:variable name="fixedHref" >
            <xsl:call-template name="fixRssHref">
              <xsl:with-param name="niceUrl">
                <xsl:value-of select="umbraco.library:NiceUrl($currentPage/ancestor-or-self::* [@level = 2]//NewsArea/NewsPage/@id)" />

              </xsl:with-param>
            </xsl:call-template>
          </xsl:variable>

          <xsl:variable name="newsletterPage" select="$currentPage/ancestor-or-self:: * [@isDoc and @level = 2]//NewsLetterPage/@id"/>
          <!-- Classic Dual header -->
          <div class="mod classic lastnews">

            <b class="top">
              <b class="tl">
                <xsl:text> </xsl:text>
              </b>
              <b class="tr">
                <xsl:text> </xsl:text>
              </b>
            </b>
            <div class="inner shadow">

              <div class="hd newspaper">
                <a href="{concat($fixedHref, '/newsrss.aspx')}" class="rssLink">
                  <xsl:value-of select="umbraco.library:GetDictionaryItem('rss')"/>
                </a>
                <h3>
                  <xsl:value-of select="umbraco.library:GetDictionaryItem('latest_news')"/>
                </h3>
              </div>
              <div class="bd">
                <div class="preview">
                  <xsl:for-each select="$currentPage/ancestor-or-self:: * [@isDoc and @level = 2]//NewsItem[string(umbracoNaviHide) != '1']">
                    <xsl:sort select="date" order="descending"/>
                    <xsl:if test="position() = 1">
                      <img src="/umbraco/imagegen.ashx?image={umbraco.library:GetMedia(image,'false')//umbracoFile}&amp;width=205&amp;height=136&amp;pad=true"  width="205" height="136" alt="{@nodeName}" />
                    </xsl:if>
                  </xsl:for-each>
                  <xsl:text> </xsl:text>
                </div>

                <div class="cnt">
                  <ul>
                    <xsl:for-each select="$currentPage/ancestor-or-self:: * [@isDoc and @level = 2]//NewsItem[string(umbracoNaviHide) != '1']">
                      <xsl:sort select="date" order="descending"/>

                      <xsl:if test="position() &lt; 4">
                        <li>
                          <!--<strong>
                            <xsl:value-of select="umbraco.library:FormatDateTime(date,'dd MMMM yyy')"/>
                          </strong>-->
                          <strong><a href="{umbraco.library:NiceUrl(@id)}">
                            <xsl:value-of select="@nodeName"/>
                            </a></strong>
                          <a href="{umbraco.library:NiceUrl(@id)}">
                            <xsl:value-of select="intro"/>
                            </a>
                        </li>

                      </xsl:if>
                    </xsl:for-each>
                  </ul>

                </div>
                <a href="{umbraco.library:NiceUrl($currentPage/ancestor-or-self:: * [@isDoc and @level = 2]//NewsArea/@id)}" class="moreLnk">
                  <xsl:value-of select="umbraco.library:GetDictionaryItem('see_all_news')"/>
                </a>
                <div style="clear:both;">
                  <xsl:text> </xsl:text>
                </div>
              </div>

              <div class="hd secondHd bubbles">
                <h3>
                  <xsl:value-of select="umbraco.library:GetDictionaryItem('newsletter_keepinformed')"/>
                </h3>
              </div>
              <div class="bd">

                <label>
                  <xsl:value-of select="umbraco.library:GetDictionaryItem('newsletter_subscribe')"/> :
                </label>
                <input type="text" id="email" name="email" class="text labelify">
                  <xsl:attribute name="title">
                  <xsl:value-of select="umbraco.library:GetDictionaryItem('newsletter_email')"/>
                  </xsl:attribute>
                </input>

                <button onclick="document.location.href='{umbraco.library:NiceUrl($newsletterPage)}?email=' + document.getElementById('email').value;return false;">
                  <span>
                    <xsl:value-of select="umbraco.library:GetDictionaryItem('general_go')"/>
                  </span>
                </button>


              </div>

            </div>
            <b class="bottom">
              <b class="bl">
                <xsl:text> </xsl:text>
              </b>
              <b class="br">
                <xsl:text> </xsl:text>
              </b>
            </b>
          </div>
          <!-- /Classic Dual header -->

        </xsl:if>
      </xsl:template>


      <xsl:template name="fixRssHref">
        <xsl:param name="niceUrl" />
        <xsl:variable name="indexOfAspx" select="umbraco.library:LastIndexOf($niceUrl, '.aspx')" />

        <xsl:variable name="fixedHref" >
          <xsl:choose>
            <xsl:when test="$indexOfAspx != -1">
              <xsl:value-of select="umbraco.library:Replace($niceUrl, '.aspx', '')" />
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="$niceUrl" />
            </xsl:otherwise>
          </xsl:choose>
        </xsl:variable>

        <xsl:value-of select="$fixedHref" />

      </xsl:template>

    </xsl:stylesheet>

     

    Can you tell me what's the problem with it?

     

    Thank you.

  • Grant Thomas323 karma points
    Mar 23, 2012 @ 11:09
    Grant Thomas
    0

    Do you think you could cut down the XSLT to be a short, but complete example that would reproduce the problem?

    You could take the time to isolate exactly where the error is occuring, helping us help you by allowing concentration on the actual prooblem, without having to read every line of your code (most of which will be irrelevant).

  • Maxime Dupierreux25 karma points
    Mar 23, 2012 @ 11:11
    Maxime Dupierreux
    0

    If I comment those lines, the macro is displaying.

    <div class="preview">
                  <xsl:for-each select="$currentPage/ancestor-or-self:: * [@isDoc and @level = 2]//NewsItem[string(umbracoNaviHide) != '1']">
                    <xsl:sort select="date" order="descending"/>
                    <xsl:if test="position() = 1">
                      <img src="/umbraco/imagegen.ashx?image={umbraco.library:GetMedia(image,'false')//umbracoFile}&amp;width=205&amp;height=136&amp;pad=true"  width="205" height="136" alt="{@nodeName}" />
                    </xsl:if>
                  </xsl:for-each>
                  <xsl:text> </xsl:text>
     </div>

     

  • Rodion Novoselov838 karma points
    Mar 23, 2012 @ 11:37
    Rodion Novoselov
    0

    Hi. This error in validation-time is almost always caused by the GetMedia method. You can wrap the piece of Xslt calling it with an "if" statement to get rid of the error message. Like this:

    <xsl:if test="image">
       <img src="/umbraco/imagegen.ashx?image={umbraco.library:GetMedia(image,'false')//umbracoFile}&amp;width=205&amp;height=136&amp;pad=true"  width="205" height="136" alt="{@nodeName}" />
    </xsl:if>

    The reason is that Xslt as being saved is validated against some real site page (afaik the root of the site) that doesn't necessary have all supposed properties (e.g. "image" in your case).

  • Maxime Dupierreux25 karma points
    Mar 23, 2012 @ 11:56
    Maxime Dupierreux
    0

    Ok, I added an "if" like you said but it seems that it's missing something to test "image" with, because it's still trying to execute the GetMedia method.

     

  • Rodion Novoselov838 karma points
    Mar 23, 2012 @ 12:16
    Rodion Novoselov
    0

    Ok. Try a bit different than:

    <xsl:if test="string(image) != ''">

     

  • Maxime Dupierreux25 karma points
    Mar 23, 2012 @ 13:13
    Maxime Dupierreux
    0

    Ok, it seems to be alright, the macro is rendered even if there is no image to display. I'll have to try with an image to display now.

    Do you know why the xslt was working on 4.5.2 and not on 4.7.11?

    Thank you for your help !

  • Rodion Novoselov838 karma points
    Mar 23, 2012 @ 13:39
    Rodion Novoselov
    0

    No idea. My first one was 4.6. Perhaps someone of elders can tell it.

Please Sign in or register to post replies

Write your reply to:

Draft
Our.umbraco.org is the community mothership for Umbraco, the open source asp.net cms. With a friendly forum for all your questions, a comprehensive documentation and a ton of packages from the community. This site is running Umbraco version 7.3.0-RC