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.
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:
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')"/>
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)
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:
If that doesn't work... try casting it in the GetMedia call:
Hopefully that should sort it.
Good luck, Lee.
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
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 " "> ]>
<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"> </div>
<div class="navi"> </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>&height=400&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>&width=288&compression=100</xsl:text>
</xsl:attribute>
</img>
</a>
</li>
</xsl:if>
</xsl:for-each>
</ul>
</div>
</div>
</div>
</xsl:template>
</xsl:stylesheet>
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:
/Chriztian
Hi Nicky, you should test the input to GetMedia for not being empty, thus e.g. replace your original
with something like this (maybe adding a default):
Hi Nicky,
On the front-end, could you take a look at the debug/trace details, to see what might be causing the error?
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:
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/
is working on a reply...