I'm pretty new to xslt and I'm trying to get the "NiceUrl" from a node, defined on a parent page. Here's how I thought doing it:
To get a reference to the link on the parent page, one would use: <xsl:variable name="homelink" select="$currentPage/ancestor-or-self::node [string(data[@alias='homelink'])!=''] [position()=1] /data[@alias='homelink']"/>
To convert a link from a "content picker" datatype to a real link, one would use: <xsl:variable name="whatlink" select="umbraco.library:NiceUrl($currentPage/data[@alias='whatlink'])"/>
Now I want to combine both: get the real URL pointing to a "content-picker" datatype from a parent page. Hence I thought combining both items above into the following: <xsl:variable name="testlink" select="umbraco.library:NiceUrl($currentPage/ancestor-or-self::node [string(data[@alias='homelink'])!=''] [position()=1] /data[@alias='homelink'])"/>
When trying to save this last "testlink" I only get the following error messages:
(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)
When you save an XSLT file it is tested with the $currentPage parameter set to the Content node, which could result in an error here, since the XPath won't return any meaningful node, thus NiceUrl() will fail. Usually, though, it fails with something about "unable to convert to an Int32" (or similar).
Have you tried to check the "Ignore errors" checkbox when saving, and see if it actually works? Then you'd be able to add a test before performing the evaluation...
recursive nice URL
I'm pretty new to xslt and I'm trying to get the "NiceUrl" from a node, defined on a parent page. Here's how I thought doing it:
<xsl:variable name="homelink" select="$currentPage/ancestor-or-self::node [string(data[@alias='homelink'])!=''] [position()=1] /data[@alias='homelink']"/>
<xsl:variable name="whatlink" select="umbraco.library:NiceUrl($currentPage/data[@alias='whatlink'])"/>
<xsl:variable name="testlink" select="umbraco.library:NiceUrl($currentPage/ancestor-or-self::node [string(data[@alias='homelink'])!=''] [position()=1] /data[@alias='homelink'])"/>
When trying to save this last "testlink" I only get the following error messages:
How should I correct?
Hi Jaques,
When you save an XSLT file it is tested with the $currentPage parameter set to the Content node, which could result in an error here, since the XPath won't return any meaningful node, thus NiceUrl() will fail. Usually, though, it fails with something about "unable to convert to an Int32" (or similar).
Have you tried to check the "Ignore errors" checkbox when saving, and see if it actually works? Then you'd be able to add a test before performing the evaluation...
/Chriztian
is working on a reply...