I think that you actually want the @id attribute of the node /macro/picture/node, however I am getting an error when I try to select /macro/picture/node/@id - not sure why exactly, but the error I get when I switch to umbDebug is something like the following:
An item of type 'Attribute' cannot be constructed within a node of type 'Root'.
The full error is
Error parsing XSLT test.xslt
An item of type 'Attribute' cannot be constructed within a node of type 'Root'.
at System.Xml.Xsl.Runtime.XmlQueryOutput.ThrowInvalidStateError(XPathNodeType constructorType)
at System.Xml.Xsl.Runtime.XmlQueryOutput.ConstructInEnumAttrs(XPathNodeType rootType)
at System.Xml.Xsl.Runtime.XmlQueryOutput.WriteStartAttribute(String prefix, String localName, String ns)
at System.Xml.Xsl.Runtime.XmlQueryOutput.StartCopy(XPathNavigator navigator, Boolean callChk)
at System.Xml.Xsl.Runtime.XmlQueryOutput.CopyNode(XPathNavigator navigator)
at System.Xml.Xsl.Runtime.XmlQueryOutput.WriteItem(XPathItem item)
at
XSLT macro parameter problem
I'm trying to create a macro with a parameter. The macro should allow me to select a picture from the media lib.
I added a parameter to the macro, i would like it to be of the mediaPicker type, but that is not available, so i chose the currentMedia type.
When i run the macro i can select a picture, and it says "updated with ID: 1098, which is the correct media id.
But when i try to acces the parametervalue in my XSLT like this :
I get this string : /media/1420/pic1.jpg80060028521jpg
insted of the mediaId i was hoping for.
How can i get my mediId from the macro instead?
Thanks
Mikael
I think that you actually want the @id attribute of the node /macro/picture/node, however I am getting an error when I try to select /macro/picture/node/@id - not sure why exactly, but the error I get when I switch to umbDebug is something like the following:
An item of type 'Attribute' cannot be constructed within a node of type 'Root'.
The full error is
Error parsing XSLT test.xslt
An item of type 'Attribute' cannot be constructed within a node of type 'Root'.
at System.Xml.Xsl.Runtime.XmlQueryOutput.ThrowInvalidStateError(XPathNodeType constructorType)
at System.Xml.Xsl.Runtime.XmlQueryOutput.ConstructInEnumAttrs(XPathNodeType rootType)
at System.Xml.Xsl.Runtime.XmlQueryOutput.WriteStartAttribute(String prefix, String localName, String ns)
at System.Xml.Xsl.Runtime.XmlQueryOutput.StartCopy(XPathNavigator navigator, Boolean callChk)
at System.Xml.Xsl.Runtime.XmlQueryOutput.CopyNode(XPathNavigator navigator)
at System.Xml.Xsl.Runtime.XmlQueryOutput.WriteItem(XPathItem item)
at
Thanks
I will give it a go when tomorrow.
Mikael
I have now confirmed that your suggested solution also works for me.
Thanks
Hi
Have the syntax changed? I'm doing something similar and just cant get it to work. Im using Umbraco 4.7.
Thanks
Hi Ruald,
Yes, the syntax has changed - the "node" should be replaced with the alias of your Media Type. For example if your media type is an image:
Or if you expect different media types you can use a wildcard:
Also to get the filename or any other property:
Hope this helps,
Tom
Brilliant, that works!
Thanks a lot.
is working on a reply...