Copied to clipboard

Flag this post as spam?

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


  • Nicky Christensen 19 posts 40 karma points
    Dec 10, 2009 @ 09:48
    Nicky Christensen
    0

    Getting an xslt error on this, why ?

    Im getting a XSLT error on this:

    <xsl:variable name="GalleryImages" select="$currentPage/data [@alias='Media']" /> 
    <xsl:variable name="GalleryImagesContent" select="umbraco.library:GetMedia($GalleryImages/data/@id, 'true')"/>

     

  • Nicky Christensen 19 posts 40 karma points
    Dec 10, 2009 @ 09:50
    Nicky Christensen
    0

    The error is this:

    (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    at Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results)
    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.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, TextWriter 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)

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Dec 10, 2009 @ 10:30
    Lee Kelleher
    0

    Hi Nicky,

    Do you only get this error when you edit the XSLT via the editor in the back-office?  Does it save fine if you tick the "Skip testing" checkbox?

    ... and then it runs with no errors on the front-end?

    Usually this error is with the validator in the XSLT editor.  From your snippet, I'm guessing it's because the $GalleryImages variable needs to be cast as a numeric.

    For example:

    <xsl:variable name="GalleryImages" select="number($currentPage/data[@alias='Media'])" />

    If that doesn't work... try casting it in the GetMedia call:

    <xsl:variable name="GalleryImagesContent" select="umbraco.library:GetMedia(number($GalleryImages/data/@id), 'true')"/>

    Hopefully that should sort it.

    Good luck, Lee.

  • Laurence Gillian 600 posts 1219 karma points
    Dec 10, 2009 @ 12:00
    Laurence Gillian
    0

    Do many people use the 'skip testing' function, I've never had to use this.

    Casting the GetMedia call should fix this though as Lee says, 

    /L

  • Nicky Christensen 19 posts 40 karma points
    Dec 10, 2009 @ 12:15
    Nicky Christensen
    0

    I've tried doing both solution now, and it still reports and error - When Skipping errors, then in the Frontend, it says "Error parsing gallery.xslt

    The whole 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:variable name="GalleryImages" select="$currentPage/data[@alias='Media']" />
     <xsl:variable name="GalleryImagesContent" select="umbraco.library:GetMedia(number($GalleryImages/data/@id), 'true')"/>
     
     <div class="gallleryimages">
      <div class="main_image">&#160;</div>
      <div class="navi">&#160;</div>
      
      <div class="gallery_main">
       <a class="prev gav_nav">Forrige</a>
     
       <div class="scrollable">
        <ul class="items">
         <!-- Start mit loop gennem billeder fra mappen der er tilknyttet produktet-->
         <xsl:for-each select="$GalleryImagesContent/node [@nodeTypeAlias = 'Image']">
          <xsl:if test="string(current()/data [@alias='umbracoFile']) != ''">
           <li>
            <a>
             <xsl:attribute name="href">
              <xsl:text>/umbraco/ImageGen.ashx?image=</xsl:text>
              <xsl:value-of select="./data [@alias = 'umbracoFile']" />
              <xsl:text>&amp;height=400&amp;compression=100</xsl:text>
             </xsl:attribute>
             <img alt="{current()/@nodeName}">
              <xsl:attribute name="src">
               <xsl:text>/umbraco/ImageGen.ashx?image=</xsl:text>
               <xsl:value-of select="./data [@alias = 'umbracoFile']" />
               <xsl:text>&amp;width=288&amp;compression=100</xsl:text>
              </xsl:attribute>
             </img>
            </a>
           </li>
          </xsl:if>

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

    </xsl:template>
    </xsl:stylesheet>

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Dec 10, 2009 @ 13:00
    Chriztian Steinmeier
    0

    Hi Nicky - taking a wild guess here, I think you need to convert your $GalleryImagesContent result to a node-set (with the msxml:node-set() extension function) because when you get a folder of nodes back (as far as I can see).

    Just wrap the variable in the for-each statement's select attribute to try it out:

    <xsl:for-each select="msxml:node-set($GalleryImagesContent)/node [@nodeTypeAlias = 'Image']">

    /Chriztian 

  • Tommy Poulsen 514 posts 708 karma points
    Dec 10, 2009 @ 13:57
    Tommy Poulsen
    1

    Hi Nicky, you should test the input to GetMedia for not being empty, thus e.g. replace your original

    <xsl:variable name="GalleryImagesContent" select="umbraco.library:GetMedia($GalleryImages/data/@id, 'true')"/>

    with something like this (maybe adding a default):

     <xsl:variable name="GalleryImagesContent">
       <xsl:if test="$GalleryImages/data/@id != ''">
         <xsl:value-of select="umbraco.library:GetMedia(number($GalleryImages/data/@id), 'true')"/>
       </xsl:if>
     </xsl:variable>
  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Dec 10, 2009 @ 13:58
    Lee Kelleher
    0

    Hi Nicky,

    On the front-end, could you take a look at the debug/trace details, to see what might be causing the error?

    Add: ?umbDebugShowTrace=true to the end of the URL

    Any error messages should be in red - just do a quick scroll down the page to see if there are any errors.

    Apart from that, you can try viewing what is in the $GalleryImages and $GalleryImagesContent variables?

    Add this to your XSLT, straight after the variables:

    <xmp>
        <xsl:copy-of select="$GalleryImages" />
    </xmp>
    <xmp>
        <xsl:copy-of select="$GalleryImagesContent" />
    </xmp>
    
    You'll need to delete/hide the rest of the XSLT template, as that will still be throwing an error.
    If that throws an error... then check what value you are passing through in the "Media" property.
    Keep us posted.
    Good luck, Lee.
  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Dec 10, 2009 @ 13:59
    Lee Kelleher
    1

    On a side note, I wrote up a blog post last week about the common pitfalls of using GetMedia in XSLT, it might be useful?

    http://blog.leekelleher.com/2009/11/30/how-to-use-umbraco-library-getmedia-in-xslt/

Please Sign in or register to post replies

Write your reply to:

Draft