Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jacques S. 5 posts 25 karma points
    May 31, 2010 @ 15:34
    Jacques S.
    0

    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:

    1. 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']"/>
    2. 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'])"/>
    3. 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)

     

    How should I correct?

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    May 31, 2010 @ 23:01
    Chriztian Steinmeier
    0

    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 

Please Sign in or register to post replies

Write your reply to:

Draft