But whatever i pass to GetNodeIdByUrl(String) returns this error
System.Xml.XPath.XPathException: Expression must evaluate to a node-set. at MS.Internal.Xml.XPath.XPathParser.ParseNodeTest(AstNode qyInput, AxisType axisType, XPathNodeType nodeType) at MS.Internal.Xml.XPath.XPathParser.ParseStep(AstNode qyInput) at MS.Internal.Xml.XPath.XPathParser.ParseRelativeLocationPath(AstNode qyInput) at MS.Internal.Xml.XPath.XPathParser.ParseLocationPath(AstNode qyInput) at MS.Internal.Xml.XPath.XPathParser.ParsePathExpr(AstNode qyInput) at MS.Internal.Xml.XPath.XPathParser.ParseUnionExpr(AstNode qyInput) at MS.Internal.Xml.XPath.XPathParser.ParseUnaryExpr(AstNode qyInput) at MS.Internal.Xml.XPath.XPathParser.ParseMultiplicativeExpr(AstNode qyInput) at MS.Internal.Xml.XPath.XPathParser.ParseAdditiveExpr(AstNode qyInput) at MS.Internal.Xml.XPath.XPathParser.ParseRelationalExpr(AstNode qyInput) at MS.Internal.Xml.XPath.XPathParser.ParseEqualityExpr(AstNode qyInput) at MS.Internal.Xml.XPath.XPathParser.ParseAndExpr(AstNode qyInput) at MS.Internal.Xml.XPath.XPathParser.ParseOrExpr(AstNode qyInput) at MS.Internal.Xml.XPath.XPathParser.ParsePredicate(AstNode qyInput) at MS.Internal.Xml.XPath.XPathParser.ParseStep(AstNode qyInput) at MS.Internal.Xml.XPath.XPathParser.ParseRelativeLocationPath(AstNode qyInput) at MS.Internal.Xml.XPath.XPathParser.ParseRelativeLocationPath(AstNode qyInput) at MS.Internal.Xml.XPath.XPathParser.ParseLocationPath(AstNode qyInput) at MS.Internal.Xml.XPath.XPathParser.ParsePathExpr(AstNode qyInput) at MS.Internal.Xml.XPath.XPathParser.ParseUnionExpr(AstNode qyInput) at MS.Internal.Xml.XPath.XPathParser.ParseUnaryExpr(AstNode qyInput) at MS.Internal.Xml.XPath.XPathParser.ParseMultiplicativeExpr(AstNode qyInput) at MS.Internal.Xml.XPath.XPathParser.ParseAdditiveExpr(AstNode qyInput) at MS.Internal.Xml.XPath.XPathParser.ParseRelationalExpr(AstNode qyInput) at MS.Internal.Xml.XPath.XPathParser.ParseEqualityExpr(AstNode qyInput) at MS.Internal.Xml.XPath.XPathParser.ParseAndExpr(AstNode qyInput) at MS.Internal.Xml.XPath.XPathParser.ParseOrExpr(AstNode qyInput) at MS.Internal.Xml.XPath.XPathParser.ParseXPathExpresion(String xpathExpresion) at System.Xml.XPath.XPathExpression.Compile(String xpath, IXmlNamespaceResolver nsResolver) at System.Xml.XPath.XPathNavigator.Select(String xpath) at System.Xml.XmlNode.SelectNodes(String xpath) at System.Xml.XmlNode.SelectSingleNode(String xpath) at uComponents.Core.XsltExtensions.Nodes.GetNodeIdByUrl(String url) at uComponents.Core.XsltExtensions.Urls.GetNodeIdByUrl(String url)
The "GetNodeIdByUrl" extension doesn't work with absolute URLs (ones that start with "http://") ... it was intended to work with the URL's path - anything after the TLD (e.g. ".com") from the forward-slash onwards.
I've tested a few variations, but didn't get any errors/exceptions. For the URLs that it couldn't find, it just returned a "-1".
What values are you getting for "http_referer"? I'd like to replicate this error - so we can fix it. :-)
I just tried it and got the error on the first run, but subsequently couldn't reproduce it...
I *think* the error might have something to do with returning just a number where the XSLT processor expects to output an XML document - do you get the error when assigning the value to a variable as well? E.g.:
How to use GetNodeIdByUrl(String)?
Im trying to get a page id from a url on my site. The reason is i need to know the id of the referring page, so combining
umbraco.library:RequestServerVariables('http_referer')
With
<xsl:value-of select="ucomponents.urls:GetNodeIdByUrl('url')"/>
Would enable me to do this...
But whatever i pass to GetNodeIdByUrl(String) returns this error
Hi Claushingebjerg,
The "GetNodeIdByUrl" extension doesn't work with absolute URLs (ones that start with "http://") ... it was intended to work with the URL's path - anything after the TLD (e.g. ".com") from the forward-slash onwards.
I've tested a few variations, but didn't get any errors/exceptions. For the URLs that it couldn't find, it just returned a "-1".
What values are you getting for "http_referer"? I'd like to replicate this error - so we can fix it. :-)
Cheers, Lee
Well actually im not even using the 'http_referer' yet
Heres what i have
<xsl:value-of select="ucomponents.urls:GetNodeIdByUrl('gaver.aspx')"/>
where gaver.aspx is a page with the id of 1061. But i get the above error
Ive tried with
gaver.aspx
'/gaver.aspx'
/gaver.aspx
But the all return the same error.
What throws me, is the error about a node-set?!?! why would it need a node-set
could i have included the extension wrong??? i have:
xmlns:ucomponents.urls="urn:ucomponents.urls"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ucomponents.urls ">
Hi Claus,
I just tried it and got the error on the first run, but subsequently couldn't reproduce it...
I *think* the error might have something to do with returning just a number where the XSLT processor expects to output an XML document - do you get the error when assigning the value to a variable as well? E.g.:
(For working URLs I found that all versions with or without leading/trailing slashes; with or without '.aspx' reliably returned the right Id)
/Chriztian
Hmmmm maybe it needed an app pool recycle.
It Worked this morning without changing at thing?!?!?
Glad that it's working now. Strange that you both got errors with it - I couldn't reproduce the error with my tests.
Best to keep an eye on it and let me know if anything strange happens again - we'll try to get a fix in place.
Cheers, Lee.
is working on a reply...