Your iteration on the $mm/node is incorrect if you're using the v4.5 new xml schema syntax!
Always forget the xml that's returned from the GetMedia() call, but that's a no-brainer to get the xml in a <textarea> field to check how to format the xpath to iterate the images in a specific folder.
The problem is probably that you're trying to match "node", which is used in the legacy scehma used by Umbraco 4.0.x and below. Since Umbraco 4.5 the XML schema has changed. So unless you have told Umbraco to use the old legacy schema in the UmbracoSettings.config file it uses the new schema.
Therefore I suggest you try to write $mm/*[@IsDoc] in your for-each statement.
In you variable I think it should be enough to write umbraco.library:GetMedia(@id)
System.OverflowException: Value was either too large or too small for an Int32.
at System.Convert.ToInt32(Double value)
at System.Double.System.IConvertible.ToInt32(IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType xmlType, Object value, Type destinationType)
at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args)
at (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)
at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable
input, XsltArgumentList arguments, XmlWriter results, XmlResolver
documentResolver)
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)
No difference in logic, but as './@id' doesn't get an actual value until runtime, the statement is considered invalid (that's just because when saving the xslt, it's also parsed). Best practise to always add an extra <xls:if> statement (Alternatively, check the 'Skip error' box)
Images from af specific folder
Hi
How do i get my images from a specific folder in Media?
I have tried this:
In my html it only writes
My images folders id is 1115.
I use umbraco v 4.5.2 and that may be my problem :-)
Can anybody help?
Hi Kate,
It looks like you are using the old XML scheme, you may want to try something like this:
Matt
Kate,
Your iteration on the $mm/node is incorrect if you're using the v4.5 new xml schema syntax!
Always forget the xml that's returned from the GetMedia() call, but that's a no-brainer to get the xml in a <textarea> field to check how to format the xpath to iterate the images in a specific folder.
<xsl:variable name="mm" select="umbraco.library:GetMedia(1115, true())" /> <textarea><xsl:value-of select="$mm" /></textarea>
So, what's the ouput from above snippet?
Cheers,
/Dirk
Hi Kate
The problem is probably that you're trying to match "node", which is used in the legacy scehma used by Umbraco 4.0.x and below. Since Umbraco 4.5 the XML schema has changed. So unless you have told Umbraco to use the old legacy schema in the UmbracoSettings.config file it uses the new schema.
Therefore I suggest you try to write $mm/*[@IsDoc] in your for-each statement.
In you variable I think it should be enough to write umbraco.library:GetMedia(@id)
You can see some good examples on how to use the GetMedia extension in the wiki reference here: http://our.umbraco.org/wiki/reference/umbracolibrary/getmedia
Maybe you can just install this package to get a list of your media files? http://our.umbraco.org/projects/website-utilities/media-iterator
Hope this helps.
/Jan
I'm just too slow...
/Jan
Hi Matt
I can´t save my file. It gives me an error.
I think it has something to do with this line:
This is the error
Error occured
System.Xml.Xsl.XslTransformException: Extension object 'urn:umbraco.library' does not contain a matching 'GetMedia' method that has 1 parameter(s).
at System.Xml.Xsl.Runtime.XmlExtensionFunction.Bind()
at System.Xml.Xsl.Runtime.XmlExtensionFunctionTable.Bind(String name, String namespaceUri, Int32 numArgs, Type objectType, BindingFlags flags)
at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args)
at (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)
at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, XmlWriter results, XmlResolver documentResolver)
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)
Ahh, sorry, change it to:
Matt
Im sorry to bother you whit this but no it says:
Error occured
false
ups, forget what I wrote 2 min ago.
I get this error:
Error occured
System.OverflowException: Value was either too large or too small for an Int32.
at System.Convert.ToInt32(Double value)
at System.Double.System.IConvertible.ToInt32(IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType xmlType, Object value, Type destinationType)
at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args)
at (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)
at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, XmlWriter results, XmlResolver documentResolver)
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)
my xslt look like this :
use
to avoid the error
Hey Kate.
Can you try changing true() to 1 and false() to 0 in the 2 GetMedia calls?
Matt
Hi Dirk
Thanks it works, but I cant see the difference form what Matt did.
Can you explain, please?
No difference in logic, but as './@id' doesn't get an actual value until runtime, the statement is considered invalid (that's just because when saving the xslt, it's also parsed). Best practise to always add an extra <xls:if> statement (Alternatively, check the 'Skip error' box)
Cheers,
/Dirk
Thanks to both of you.
It works just like I want it :-)
is working on a reply...