U4-458 - umbraco.library.GetXmlNodeByXPath() fails if called first (Expression must evaluate to a node-set.)

Created by Sebastiaan Janssen 19 Aug 2012, 14:53:00 Updated by Shannon Deminick 21 Jun 2017, 07:52:13

If I call this method: umbraco.library.GetXmlNodeByXPath(xpath); before viewing any front end page, eg via a custom dashboard control. then it throws this exception. if I then refresh a page on the front end it will work, it appears some kind of xml cache is not initialised correctly.

NB: this affects many uComponents / uQuery methods also, but I believe that is because they rely on this method internally

[XPathException: Expression must evaluate to a node-set.] MS.Internal.Xml.XPath.XPathParser.ParseNodeTest(AstNode qyInput, AxisType axisType, XPathNodeType nodeType) +4098410 MS.Internal.Xml.XPath.XPathParser.ParseStep(AstNode qyInput) +85 MS.Internal.Xml.XPath.XPathParser.ParseRelativeLocationPath(AstNode qyInput) +17 MS.Internal.Xml.XPath.XPathParser.ParseLocationPath(AstNode qyInput) +36 MS.Internal.Xml.XPath.XPathParser.ParsePathExpr(AstNode qyInput) +30 MS.Internal.Xml.XPath.XPathParser.ParseUnionExpr(AstNode qyInput) +19 MS.Internal.Xml.XPath.XPathParser.ParseUnaryExpr(AstNode qyInput) +31 MS.Internal.Xml.XPath.XPathParser.ParseMultiplicativeExpr(AstNode qyInput) +23 MS.Internal.Xml.XPath.XPathParser.ParseAdditiveExpr(AstNode qyInput) +23 MS.Internal.Xml.XPath.XPathParser.ParseRelationalExpr(AstNode qyInput) +23 MS.Internal.Xml.XPath.XPathParser.ParseEqualityExpr(AstNode qyInput) +23 MS.Internal.Xml.XPath.XPathParser.ParseAndExpr(AstNode qyInput) +19 MS.Internal.Xml.XPath.XPathParser.ParseOrExpr(AstNode qyInput) +19 MS.Internal.Xml.XPath.XPathParser.ParsePredicate(AstNode qyInput) +58 MS.Internal.Xml.XPath.XPathParser.ParseStep(AstNode qyInput) +349 MS.Internal.Xml.XPath.XPathParser.ParseRelativeLocationPath(AstNode qyInput) +17 MS.Internal.Xml.XPath.XPathParser.ParseRelativeLocationPath(AstNode qyInput) +70 MS.Internal.Xml.XPath.XPathParser.ParseLocationPath(AstNode qyInput) +205 MS.Internal.Xml.XPath.XPathParser.ParsePathExpr(AstNode qyInput) +30 MS.Internal.Xml.XPath.XPathParser.ParseUnionExpr(AstNode qyInput) +19 MS.Internal.Xml.XPath.XPathParser.ParseUnaryExpr(AstNode qyInput) +31 MS.Internal.Xml.XPath.XPathParser.ParseMultiplicativeExpr(AstNode qyInput) +23 MS.Internal.Xml.XPath.XPathParser.ParseAdditiveExpr(AstNode qyInput) +23 MS.Internal.Xml.XPath.XPathParser.ParseRelationalExpr(AstNode qyInput) +23 MS.Internal.Xml.XPath.XPathParser.ParseEqualityExpr(AstNode qyInput) +23 MS.Internal.Xml.XPath.XPathParser.ParseAndExpr(AstNode qyInput) +19 MS.Internal.Xml.XPath.XPathParser.ParseOrExpr(AstNode qyInput) +19 MS.Internal.Xml.XPath.XPathParser.ParseXPathExpresion(String xpathExpresion) +54 System.Xml.XPath.XPathExpression.Compile(String xpath, IXmlNamespaceResolver nsResolver) +52 System.Xml.XPath.XPathNavigator.Select(String xpath) +14 umbraco.library.GetXmlNodeByXPath(String xpathQuery) +41 ... confidential info snipped...

''Originally created on CodePlex by [Myster|http://www.codeplex.com/site/users/view/Myster]'' on 10/13/2011 5:49:38 AM [Codeplex ID: 30536 - Codeplex Votes: 4]

Imported comments

''Comment by [Myster|http://www.codeplex.com/site/users/view/Myster] on 10/13/2011 5:51:16 AM:'' Is there some way to manually check/initialise the xml as an interim measure?

''Comment by [Myster|http://www.codeplex.com/site/users/view/Myster] on 10/13/2011 6:29:33 AM:'' //HACK: to work around this: http://umbraco.codeplex.com/workitem/30536 int sourceNodeId; try catch(XPathException ex) { //HACK: to work around this: http://umbraco.codeplex.com/workitem/30536 umbraco.library.RenderTemplate(uQuery.RootNodeId); sourceNodeId = uComponents.Core.XsltExtensions.Nodes.GetNodeIdByUrl(urlPath); }

Comments

Shannon Deminick 21 Jun 2017, 07:52:14

Closing issue due to inactivity - see blog post for details https://umbraco.com/blog/issue-tracker-cleanup/


Priority: Normal

Type: Bug

State: Closed

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions:

Due in version:

Sprint:

Story Points:

Cycle: