Copied to clipboard

Flag this post as spam?

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


  • rasb 162 posts 218 karma points
    Jan 17, 2010 @ 00:16
    rasb
    0

    Saving Xslt Crashes IIS

    Hi Guys,

    I am experiencing something a little bit strange. I have this Xslt Macro that I am trying to save. But saving this Xslt crashes my entire IIS. At first I saw that a process called DW20.exe was fired off in up to five instances and hogged all CPU power. I found out that this was caused by Windows Error Reporting. So I disabled that and installed the Debug Diagnostics Tool from Microsoft. I do get a dump report, but I can't really find anything in there.

    I think it is a rather extreme way to handle the error. So I tried to load the Umbraco source and run that in Debug mode and see what happened. But I couldn't really figure out how to do that... (do I need to do anything special?)

    Anyhow... I am running out of ideas here, and can't really get an error message that can help me resolve this issue. My Xslt looks like this:

    In my Document Type I have 5 content pickers, that each are used to select a featured page:

    <xsl:variable name="F1_id" select="$currentPage/data [@alias = 'Feature1']" />

    I have tried to add checks to ensure that a content item is actually selected.

     

    <xsl:if test="number($F1_id) &gt; 0">

    And then make sure that it actually is a content node.

     

    <xsl:variable name="F1" select="umbraco.library:GetXmlNodeById(number($F1_id))" />
    
    <xsl:if test="string-length($F1/@nodeName) &gt; 0">

    This is my entire Xslt:

    <?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:variable name="F1_id" select="$currentPage/data [@alias = 'Feature1']" />
        <xsl:variable name="F2_id" select="$currentPage/data [@alias = 'Feature2']" />
        <xsl:variable name="F3_id" select="$currentPage/data [@alias = 'Feature3']" />
        <xsl:variable name="F4_id" select="$currentPage/data [@alias = 'Feature4']" />
        <xsl:variable name="F5_id" select="$currentPage/data [@alias = 'Feature5']" />
    
        <div id="home_featured">
          <div class="main_image">
    
            <xsl:if test="number($F1_id) &gt; 0">
    
              <xsl:variable name="F1" select="umbraco.library:GetXmlNodeById(number($F1_id))" />
    
              <xsl:if test="string-length($F1/@nodeName) &gt; 0">
    
              <!-- create a variable to store the media ID -->
              <xsl:variable name="mediaId" select="$F1/data [@alias='Thumbnail']" />
    
              <!-- now check the ID is a number -->
              <xsl:choose>
                <xsl:when test="number($mediaId) &gt; 0">
                  <!-- Now we know we have an ID, store the umbraco.library:GetMedia() in a variable, this way we can reuse it -->
                  <!-- Note here we have an additional parameter, when set to false() it will return just that node, if set to true it    will return that node and it's children, this is useful for getting media folders -->
                  <xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, false())" />
    
                  <!-- Now check that the retrieved media url string has a length otherwise we will be outputting a blank string -->
                  <!-- This is held in the "/data[@alias = 'umbracoFile']" as GetMedia returns a media node-->
                  <xsl:if test="string-length($mediaNode/data[@alias = 'umbracoFile']) &gt; 0">
                    <!-- output our safely found media url into our link, using inline XSLT between the {...} -->
    
                    <xsl:variable name="image" select="$mediaNode/data[@alias = 'umbracoFile']" />
    
                    <img>
                      <xsl:attribute name="src">
                        <xsl:text>/umbraco/ImageGen.ashx?image=</xsl:text>
                        <xsl:value-of select="$image"/>
                        <xsl:text>&amp;width=614&amp;height=381</xsl:text>
                      </xsl:attribute>
                    </img>
    
                  </xsl:if>
                </xsl:when>
              </xsl:choose>
    
              <div class="desc">
                <a href="#" class="collapse">Close Me!</a>
    
                <div class="block">
                  <h2>
                    <a href="{umbraco.library:NiceUrl($F1/@id)}" title="{$F1/@nodeName}">
                      <xsl:value-of select="$F1/@nodeName"/> ...
                    </a>
                  </h2>
                  <p>
                    <xsl:value-of select="$F1/data [@alias = 'Abstract']"/> ...<br /><a href="{umbraco.library:NiceUrl($F1/@id)}" title="{$F1/@nodeName}">Read More...</a>
                  </p>
                </div>
              </div>
    
              </xsl:if>
            </xsl:if>
    
          </div>
          <!-- main_image -->
    
          <div class="image_thumb">
              <ul>
    
                <xsl:if test="number($F1_id) &gt; 0">
                  <xsl:apply-templates select="umbraco.library:GetXmlNodeById($currentPage/data [@alias = 'Feature1'])" />
                </xsl:if>
                <xsl:if test="number($F2_id) &gt; 0">
                  <xsl:apply-templates select="umbraco.library:GetXmlNodeById($currentPage/data [@alias = 'Feature2'])" />
                </xsl:if>
                <xsl:if test="number($F3_id) &gt; 0">
                  <xsl:apply-templates select="umbraco.library:GetXmlNodeById($currentPage/data [@alias = 'Feature3'])" />
                </xsl:if>
                <xsl:if test="number($F4_id) &gt; 0">
                  <xsl:apply-templates select="umbraco.library:GetXmlNodeById($currentPage/data [@alias = 'Feature4'])" />
                </xsl:if>
                <xsl:if test="number($F5_id) &gt; 0">
                  <xsl:apply-templates select="umbraco.library:GetXmlNodeById($currentPage/data [@alias = 'Feature5'])" />
                </xsl:if>
    
              </ul>
            </div>
            <!-- image_thumb -->
          </div>
        <!-- home_featured -->
    
      </xsl:template>
    
      <xsl:template match="node">
        <li>
          <!-- create a variable to store the media ID -->
          <xsl:variable name="mediaId" select="data [@alias='Thumbnail']" />
    
          <!-- now check the ID is a number -->
          <xsl:choose>
            <xsl:when test="number($mediaId) &gt; 0">
              <!-- Now we know we have an ID, store the umbraco.library:GetMedia() in a variable, this way we can reuse it -->
              <!-- Note here we have an additional parameter, when set to false() it will return just that node, if set to true it    will return that node and it's children, this is useful for getting media folders -->
              <xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, false())" />
    
              <!-- Now check that the retrieved media url string has a length otherwise we will be outputting a blank string -->
              <!-- This is held in the "/data[@alias = 'umbracoFile']" as GetMedia returns a media node-->
              <xsl:if test="string-length($mediaNode/data[@alias = 'umbracoFile']) &gt; 0">
                <!-- output our safely found media url into our link, using inline XSLT between the {...} -->
    
                <xsl:variable name="image" select="$mediaNode/data[@alias = 'umbracoFile']" />
    
                <a>
                  <xsl:attribute name="href">
                    <xsl:text>/umbraco/ImageGen.ashx?image=</xsl:text>
                    <xsl:value-of select="$image"/>
                    <xsl:text>&amp;width=614&amp;height=381</xsl:text>
                  </xsl:attribute>
    
                  <img>
                    <xsl:attribute name="src">
                      <xsl:text>/umbraco/ImageGen.ashx?image=</xsl:text>
                      <xsl:value-of select="$image"/>
                      <xsl:text>&amp;width=50&amp;height=38</xsl:text>
                    </xsl:attribute>
                  </img>
                </a>
    
              </xsl:if>
            </xsl:when>
          </xsl:choose>
    
          <div class="block">
            <h2>
              <a href="{umbraco.library:NiceUrl(@id)}" title="{@nodeName}">
                <xsl:value-of select="@nodeName"/> ...
              </a>
            </h2>
            <small>July 15, 2009</small>
            <p>
              <xsl:value-of select="data [@alias = 'Abstract']"/> ...<br /><a href="{umbraco.library:NiceUrl(@id)}" title="{@nodeName}">Read More...</a>
            </p>
          </div>
        </li>
      </xsl:template>
    
    </xsl:stylesheet>
  • Daniel Lindstrom 454 posts 271 karma points
    Jan 18, 2010 @ 00:31
    Daniel Lindstrom
    0

    Have you tried commenting out selected parts of the xslt to isolate the line that causes the crash?

  • Sebastiaan Janssen 5044 posts 15475 karma points MVP admin hq
    Jan 18, 2010 @ 09:06
    Sebastiaan Janssen
    0

    Well, this really isn't a problem in your XSLT crashing IIS. It sounds like IIS is incorrectly installed or configured at the moment. Maybe your application pool is running with too little memory? More likely though is that you have a corrupt IIS somehow.

    Be sure to check the windows event log, the "Application" section should be showing critical errors all over the place.

  • Casey Neehouse 1339 posts 483 karma points MVP 2x admin
    Jan 18, 2010 @ 10:32
    Casey Neehouse
    0

    My guess is that you have a call-template or apply-template that is somewhat recursive ... IE, the never ending loop.

    It is easy enough to do in xslt.

  • rasb 162 posts 218 karma points
    Jan 19, 2010 @ 12:57
    rasb
    0

    Hi Guys,

    Thanks for all the input. I am getting closer to a solution... I think. At least I have started getting error messages instead of crashing IIS ;-)

    I changed the apply-templates to a call-template, just to make sure that I wasn't doing anything recursive. I didn't think I was, but you never know.

    So my call to the template looks like this:

            <xsl:if test="number($F1_id) &gt; 0">
                <xsl:call-template name="feature">
                  <xsl:with-param name="feat" select="umbraco.library:GetXmlNodeById($F1_id)" />
                </xsl:call-template>
            </xsl:if>

    This works fine for four of my features. But for some reason it won't work for Feature2. So I repeat that five times, one for each property in my document type. I replace F1 with F2, F3, F4 and F5. If I have the snippet for F2 in the Xslt I get an error "System.OverflowException: Value was either too large or too small for an Int32. "

    As far as I can tell there is absolutely no difference between Feature 2 and the rest. But it won't save if I put in Feature 2. I thought the xsl:if statement would ensure that I did not get that error, but apparently not.

    I am at a bit of a loss here.

    /RasB

  • rasb 162 posts 218 karma points
    Jan 19, 2010 @ 13:11
    rasb
    0

    Hmmm... so I tried renaming the alias for the property Feature 2. That did the trick, so perhaps I have a duplicate property alias somewhere. 

    Would that cause this behaviour?

    /RasB

  • rasb 162 posts 218 karma points
    Jan 19, 2010 @ 13:26
    rasb
    0

    Nope that wasn't it.. I couldn't find any other property with that alias, and I tried renaming it back to the original name, and now it works as intended.

    Very strange indeed... but problem solved, so I guess I am satisfied ;-)

    /RasB

  • Daniel Lindstrom 454 posts 271 karma points
    Jan 19, 2010 @ 20:06
    Daniel Lindstrom
    0

    I bet you originally had misspelled the node property. Thats why it worked when you renamed it, and also when you changed back to the old name, this time correctly spelled.

    The error message suggests that the variable did not contain any value. A good place to start debugging these kind of errors is to print out the value of the variable to make sure it really contains what you expect. 

  • rasb 162 posts 218 karma points
    Jan 19, 2010 @ 21:10
    rasb
    0

    Hmmm... I don't thank that was the case Daniel. I renamed the node by adding another "2" at the end of the name in both places, and then removing it again. So I didn't rewrite the entire name. 

    I suspect that the property might not have been created correctly in the first place. I am not sure what went wrong when I created it, but if it for some reason wasn't created correctly I am sure it could cause all kinds of trouble.

    The good thing is that I ran into ELMAH and got that set up. That is a cool tool.

    /RasB

  • Chad Rosenthal 272 posts 474 karma points
    Nov 09, 2010 @ 22:46
    Chad Rosenthal
    0

    Did you ever figure this out?

Please Sign in or register to post replies

Write your reply to:

Draft