Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi
I have this 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:value-of select="umbraco.library:GetMedia($currentPage/data[@alias='frontPicture'], 'false')/data[@alias = 'umbracoFile']" /></xsl:template></xsl:stylesheet>--------------------------------------------------------
when i test it in the visualizer it works as I want it to - but when I try to save it I get an error:
--------------------------------------------------------(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) 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.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results) at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)--------------------------------------------------------
What is wrong?? .........
Hi,
you have 2 options here:
1: disable checking for errors upon saving
2: use the following code:
<xsl:if test="$currentPage/data[@alias='frontPicture'] != '' ">
<xsl:value-of select="umbraco.library:GetMedia($currentPage/data[@alias='frontPicture'], 'false')/data[@alias = 'umbracoFile']" />
</xsl:if>
Yeah, you should use the examplecode that Peter wrote in his post.
Otherwise, you could edit the file outside of Umbraco in some sort of code editor. I myself use Visual Studio all the time.
Yes, I think Peter's code (sol. 2) is best practice. I always do that way and never have problem.
Hi Peter [BB], yes follow what Peter D suggested, by having an IF condition around the value-of / GetMedia.
I wrote a blog post a few weeks ago about how to safely handle the GetMedia calls in XSLT - have a read...
http://blog.leekelleher.com/2009/11/30/how-to-use-umbraco-library-getmedia-in-xslt/
Cheers, Lee.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
xslt-problem with GetMedia
Hi
I have this 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:value-of select="umbraco.library:GetMedia($currentPage/data[@alias='frontPicture'], 'false')/data[@alias = 'umbracoFile']" />
</xsl:template>
</xsl:stylesheet>
--------------------------------------------------------
when i test it in the visualizer it works as I want it to - but when I try to save it I get an error:
--------------------------------------------------------
(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
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.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results)
at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)
--------------------------------------------------------
What is wrong?? .........
Hi,
you have 2 options here:
1: disable checking for errors upon saving
2: use the following code:
Yeah, you should use the examplecode that Peter wrote in his post.
Otherwise, you could edit the file outside of Umbraco in some sort of code editor. I myself use Visual Studio all the time.
Yes, I think Peter's code (sol. 2) is best practice. I always do that way and never have problem.
Hi Peter [BB], yes follow what Peter D suggested, by having an IF condition around the value-of / GetMedia.
I wrote a blog post a few weeks ago about how to safely handle the GetMedia calls in XSLT - have a read...
http://blog.leekelleher.com/2009/11/30/how-to-use-umbraco-library-getmedia-in-xslt/
Cheers, Lee.
is working on a reply...