Copied to clipboard

Flag this post as spam?

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


  • Rachel Skuse 88 posts 118 karma points
    Jul 12, 2011 @ 18:25
    Rachel Skuse
    0

    Error parsing XSLT file but it's working in another website

    Hi,

    I am trying to reuse some code from an existing website and put it in another website as, essentially, I am after the same thing. It is basically an image slider as seen here... AGA Living

    The XSLT works fine in this site but in the new site I have copied the macro, copied the .js file and recreated the document type but it is still giving me an error. Is there something I'm missing?

      <xsl:param name="currentPage"/>

      <xsl:template match="/">

        <xsl:variable name="media1" select="umbraco.library:GetMedia($currentPage/slide1, 0)" />
        <xsl:if test="$media1">
          <a href="{umbraco.library:NiceUrl($media1/linkToRelevantPage)}">
            <img id="slide1" class="slideimg" src="{$media1/largeSlide}" alt="{$media1/overlayHeading}" />
          </a>
        </xsl:if>
        <xsl:variable name="media2" select="umbraco.library:GetMedia($currentPage/slide2, 0)" />
        <xsl:if test="$media2">
          <a href="{umbraco.library:NiceUrl($media2/linkToRelevantPage)}">
            <img id="slide2" class="slideimg" src="{$media2/largeSlide}" alt="{$media2/overlayHeading}" />
          </a>
        </xsl:if>
        <xsl:variable name="media3" select="umbraco.library:GetMedia($currentPage/slide3, 0)" />
        <xsl:if test="$media3">
          <a href="{umbraco.library:NiceUrl($media3/linkToRelevantPage)}">
            <img id="slide3" class="slideimg" src="{$media3/largeSlide}" alt="{$media3/overlayHeading}" />
          </a>
        </xsl:if>
        <xsl:variable name="media4" select="umbraco.library:GetMedia($currentPage/slide4, 0)" />
        <xsl:if test="$media4">
          <a href="{umbraco.library:NiceUrl($media4/linkToRelevantPage)}">
            <img id="slide4" class="slideimg" src="{$media4/largeSlide}" alt="{$media4/overlayHeading}" />
          </a>
        </xsl:if>
        <div class="slideoverlay">
          <xsl:if test="$media1">
            <div id="slidecontent1" class="slidecontent">
              <h2 class="slideheading">
                <xsl:value-of select="$media1/overlayHeading" />
              </h2>
              <div class="slideblurb">
                <a class="golink" href="{umbraco.library:NiceUrl($media1/linkToRelevantPage)}">Go</a>
                <xsl:value-of select="$media1/overlayCaption" />
              </div>
            </div>
          </xsl:if>
          <xsl:if test="$media2">
            <div id="slidecontent2" class="slidecontent">
              <h2 class="slideheading">
                <xsl:value-of select="$media2/overlayHeading" />
              </h2>
              <div class="slideblurb">
                <a class="golink" href="{umbraco.library:NiceUrl($media2/linkToRelevantPage)}">Go</a>
                <xsl:value-of select="$media2/overlayCaption" />
              </div>
            </div>
          </xsl:if>
          <xsl:if test="$media3">
            <div id="slidecontent3" class="slidecontent">
              <h2 class="slideheading">
                <xsl:value-of select="$media3/overlayHeading" />
              </h2>
              <div class="slideblurb">
                <a class="golink" href="{umbraco.library:NiceUrl($media3/linkToRelevantPage)}">Go</a>
                <xsl:value-of select="$media3/overlayCaption" />
              </div>
            </div>
          </xsl:if>
          <xsl:if test="$media4">
            <div id="slidecontent4" class="slidecontent">
              <h2 class="slideheading">
                <xsl:value-of select="$media4/overlayHeading" />
              </h2>
              <div class="slideblurb">
                <a class="golink" href="{umbraco.library:NiceUrl($media4/linkToRelevantPage)}">Go</a>
                <xsl:value-of select="$media4/overlayCaption" />
              </div>
            </div>
          </xsl:if>
          <div class="slideswitcher">
            <a href="#" class="prevslide">
              <img src="/media/277/slidearrowleft.gif" alt="Previous Slide" />
            </a>
            <a href="#" class="slidethumb activethumb">
              <img src='{$media1/thumbnailVersion}' alt='{$media1/overlayHeading}' />
            </a>
            <a href="#" class="slidethumb">
              <img src='{$media2/thumbnailVersion}' alt='{$media2/overlayHeading}' />
            </a>
            <a href="#" class="slidethumb">
              <img src='{$media3/thumbnailVersion}' alt='{$media3/overlayHeading}' />
            </a>
            <a href="#" class="slidethumb">
              <img src='{$media4/thumbnailVersion}' alt='{$media4/overlayHeading}' />
            </a>
            <a href="#" class="nextslide">
              <img src="/media/291/slidearrowright.gif" alt="Next Slide" />
            </a>
          </div>
        </div>

      </xsl:template>

    I have tried disecting the code but the error appears with just a single line,..

    <xsl:variable name="media1" select="umbraco.library:GetMedia($currentPage/slide1, 0)" /> 

    Thanks,
    Rach

  • Rich Green 2246 posts 4008 karma points
    Jul 12, 2011 @ 18:35
    Rich Green
    0

    Hey Rach,

    If  you tick the 'Skip Testing' checkbox does the code still work?

    To get rid of the errors you might need to change these lines to 

    <xsl:if test="$media1">

    To

    <xsl:if test="$media1 > 0">

    Rich

  • Rachel Skuse 88 posts 118 karma points
    Jul 12, 2011 @ 18:44
    Rachel Skuse
    0

    Hi Rich,

    I have to tick the 'Skip Testing' checkbox to actually be able to save the code but then I still get the error message :(

    Thanks,
    Rach

  • Rachel Skuse 88 posts 118 karma points
    Jul 13, 2011 @ 13:13
    Rachel Skuse
    0

    Hi,

    I have fixed the error by changing

    umbraco.library:GetMedia($currentPage/slide1, 0)

    to

    umbraco.library:GetMedia($currentPage/data[@alias='slide1'], 0)

    and although I am no longer getting an error it is not displaying all of my media items and I can't figure out why. I have checked that all the alias's are correct.

    The test page for the image slider is here... Test Page but it should look like this... Working Example

    My full code is below... any suggestions as to where I am going wrong would be much appreciated :)

      <xsl:param name="currentPage"/>

      <xsl:template match="/">

        <xsl:variable name="media1" select="umbraco.library:GetMedia($currentPage/data[@alias='slide1'], 0)" />
        <xsl:if test="$media1 > 0">
          <a href="{umbraco.library:NiceUrl($media1/data[@alias='linkToRelevantPage'])}">
            <img id="slide1" class="slideimg" src="{$media1/data[@alias='largeSlide']}" alt="{$media1/data[@alias='overlayHeading']}" />
          </a>
        </xsl:if>
        <xsl:variable name="media2" select="umbraco.library:GetMedia($currentPage/data[@alias='slide2'], 0)" />
        <xsl:if test="$media2 > 0">
          <a href="{umbraco.library:NiceUrl($media2/data[@alias='linkToRelevantPage'])}">
            <img id="slide2" class="slideimg" src="{$media2/data[@alias='largeSlide']}" alt="{$media2/data[@alias='overlayHeading']}" />
          </a>
        </xsl:if>
        <xsl:variable name="media3" select="umbraco.library:GetMedia($currentPage/data[@alias='slide3'], 0)" />
        <xsl:if test="$media3 > 0">
          <a href="{umbraco.library:NiceUrl($media3/data[@alias='linkToRelevantPage'])}">
            <img id="slide3" class="slideimg" src="{$media3/data[@alias='largeSlide']}" alt="{$media3/data[@alias='overlayHeading']}" />
          </a>
        </xsl:if>
        <xsl:variable name="media4" select="umbraco.library:GetMedia($currentPage/data[@alias='slide4'], 0)" />
        <xsl:if test="$media4 > 0">
          <a href="{umbraco.library:NiceUrl($media4/data[@alias='linkToRelevantPage'])}">
            <img id="slide4" class="slideimg" src="{$media4/data[@alias='largeSlide']}" alt="{$media4/data[@alias='overlayHeading']}" />
          </a>
        </xsl:if>
        <div class="slideoverlay">
          <xsl:if test="$media1 > 0">
            <div id="slidecontent1" class="slidecontent">
              <h2 class="slideheading">
                <xsl:value-of select="$media1/data[@alias='overlayHeading']" />
              </h2>
              <div class="slideblurb">
                <a class="golink" href="{umbraco.library:NiceUrl($media1/data[@alias='linkToRelevantPage'])}">Go</a>
                <xsl:value-of select="$media1/data[@alias='overlayCaption']" />
              </div>
            </div>
          </xsl:if>
          <xsl:if test="$media2 > 0">
            <div id="slidecontent2" class="slidecontent">
              <h2 class="slideheading">
                <xsl:value-of select="$media2/data[@alias='overlayHeading']" />
              </h2>
              <div class="slideblurb">
                <a class="golink" href="{umbraco.library:NiceUrl($media2/data[@alias='linkToRelevantPage'])}">Go</a>
                <xsl:value-of select="$media2/data[@alias='overlayCaption']" />
              </div>
            </div>
          </xsl:if>
          <xsl:if test="$media3 > 0">
            <div id="slidecontent3" class="slidecontent">
              <h2 class="slideheading">
                <xsl:value-of select="$media3/data[@alias='overlayHeading']" />
              </h2>
              <div class="slideblurb">
                <a class="golink" href="{umbraco.library:NiceUrl($media3/data[@alias='linkToRelevantPage'])}">Go</a>
                <xsl:value-of select="$media3/data[@alias='overlayCaption']" />
              </div>
            </div>
          </xsl:if>
          <xsl:if test="$media4 > 0">
            <div id="slidecontent4" class="slidecontent">
              <h2 class="slideheading">
                <xsl:value-of select="$media4/data[@alias='overlayHeading']" />
              </h2>
              <div class="slideblurb">
                <a class="golink" href="{umbraco.library:NiceUrl($media4/data[@alias='linkToRelevantPage'])}">Go</a>
                <xsl:value-of select="$media4/data[@alias='overlayCaption']" />
              </div>
            </div>
          </xsl:if>
          <div class="slideswitcher">
            <a href="#" class="prevslide">
              <img src="/media/722278/slidearrowleft.gif" alt="Previous Slide" />
            </a>
            <a href="#" class="slidethumb activethumb">
              <img src="{$media1/data[@alias='thumbnailVersion']}" alt="{$media1/data[@alias='overlayHeading']}" />
            </a>
            <a href="#" class="slidethumb">
              <img src="{$media2/data[@alias='thumbnailVersion']}" alt="{$media2/data[@alias='overlayHeading']}" />
            </a>
            <a href="#" class="slidethumb">
              <img src="{$media3/data[@alias='thumbnailVersion']}" alt="{$media3/data[@alias='overlayHeading']}" />
            </a>
            <a href="#" class="slidethumb">
              <img src="{$media4/data[@alias='thumbnailVersion']}" alt="{$media4/data[@alias='overlayHeading']}" />
            </a>
            <a href="#" class="nextslide">
              <img src="/media/722272/slidearrowright.gif" alt="Next Slide" />
            </a>
          </div>
        </div>


      </xsl:template>

    Thanks,

    Rachel

  • Rich Green 2246 posts 4008 karma points
    Jul 13, 2011 @ 13:18
    Rich Green
    0

    Rachel,

    It seems your problems are stemming from the fact that your Umbraco versions are different.

    This code is from Umbraco > 4.5 

    umbraco.library:GetMedia($currentPage/slide1,0)

    This code is for a < 4.5 version of umbraco

    umbraco.library:GetMedia($currentPage/data[@alias='slide1'],0)

    (Unless one site has useLegacyXML set to true)

    Is it the same website, or different?

    Rich

  • Rachel Skuse 88 posts 118 karma points
    Jul 13, 2011 @ 13:34
    Rachel Skuse
    0

    Hi,

    It's a different website and they are on different versions of Umbraco.

    I think the main problem is that the images within the if statements are not displaying eg...

        <xsl:iftest="$media1 > 0">
         
    <ahref="{umbraco.library:NiceUrl($media1/data[@alias='linkToRelevantPage'])}">
           
    <imgid="slide1"class="slideimg"src="{$media1/data[@alias='largeSlide']}"alt="{$media1/data[@alias='overlayHeading']}"/>
         
    </a>
       
    </xsl:if>

    So I think there is an issue with $media1 > 0

    :(

    Thanks,

    Rachel

  • Rachel Skuse 88 posts 118 karma points
    Jul 13, 2011 @ 13:59
    Rachel Skuse
    0

    This is the error I'm getting in the xslt visualizer...

    Error parsing the XSLT:

    System.Xml.Xsl.XslLoadException: The variable or parameter 'media1' is either not defined or it is out of scope. An error occurred at (17,1). at System.Xml.Xsl.XslCompiledTransform.LoadInternal(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver) at System.Xml.Xsl.XslCompiledTransform.Load(XmlReader stylesheet, XsltSettings settings, XmlResolver stylesheetResolver) at umbraco.macro.CreateXsltTransform(XmlTextReader xslReader, Boolean debugMode) at umbraco.presentation.umbraco.developer.Xslt.xsltVisualize.visualizeDo_Click(Object sender, EventArgs e)

    But surely it's defined as a variable here...

    <xsl:variable name="media1" select="umbraco.library:GetMedia($currentPage/data[@alias='slide1'], 0)" />

    Thanks, Rachel

  • Carlos 338 posts 472 karma points
    Jan 17, 2012 @ 20:11
    Carlos
    0

    I know this post is old and didn't know if you had found anything yet.

    Try adding /umbracoFile after your ]

    <xsl:variablename="media1"select="umbraco.library:GetMedia($currentPage/data[@alias='slide1']/umbracoFile, 0)"/>

     

    Also saw that your xsl if statement has no space between the "iftest=" should be "if test="

    Did you find a solution?

Please Sign in or register to post replies

Write your reply to:

Draft