I'm building a user control which queries content using XPath.I need to make use of Exslt extensions (and umbraco.library), so I added the namespace using XmlNamespaceManager. But I'm still getting an error: XsltContext needed
What am I missing here?
XPathNavigator nav = content.Instance.XmlContent.CreateNavigator();
XmlNamespaceManager nsMgr = new XmlNamespaceManager(nav.NameTable); nsMgr.AddNamespace("Exslt.ExsltStrings", "Exslt.ExsltStrings");
XPathExpression expr = nav.Compile("./descendant::node[@nodeTypeAlias='Person' and contains(Exslt.ExsltStrings:uppercase(data[@alias='fornavn']), 'JENS')]");
Hi Christian, just a quick suggestion here - could it be something with the expression contect of your data element (missing appropriate context) ? I wonder if you reference the right content node by default here. If you want to use something like $currentpage you probably have to find it using something like
//node[@id=”currentNodeId“]
where currentNodeId is the nodeid for the current node, available from ((umbraco.cms.businesslogic.datatype.DefaultData)_data).NodeId.
Thank you for your answer. I don't think it has to do with the XPath it self.
This works fine (all nodes of type person where 'fornavn' contains 'Jens''):
./descendant::node[@nodeTypeAlias='Person' and contains(data[@alias='fornavn'], 'Jens')]
This doesn't work - because of the xslt-extension:
./descendant::node[@nodeTypeAlias='Person' and contains(Exslt.ExsltStrings:uppercase(data[@alias='fornavn']), 'JENS')]
I've made my own xslt-extension and tried to reference it in the same way, but I still get the same error. Everything works fine in a plain xsl-file, but for different reasons I need to work with the nodes ind the usercontrol.
I have not tried it myself, but you may need to do some extra work on the context. I found this link: http://msdn.microsoft.com/en-us/library/ms950806.aspx - maybe it's usefull (last section, putting it all together)
XsltContext needed
Hi,
I'm building a user control which queries content using XPath.I need to make use of Exslt extensions (and umbraco.library), so I added the namespace using XmlNamespaceManager. But I'm still getting an error: XsltContext needed
What am I missing here?
This works fine without
Best regards
Christian
Hi Christian, just a quick suggestion here - could it be something with the expression contect of your data element (missing appropriate context) ? I wonder if you reference the right content node by default here. If you want to use something like $currentpage you probably have to find it using something like
where currentNodeId is the nodeid for the current node, available from ((umbraco.cms.businesslogic.datatype.DefaultData)_data).NodeId.
>Tommy
Hi Tommy.
Thank you for your answer. I don't think it has to do with the XPath it self.
This works fine (all nodes of type person where 'fornavn' contains 'Jens''):
./descendant::node[@nodeTypeAlias='Person' and contains(data[@alias='fornavn'], 'Jens')]
This doesn't work - because of the xslt-extension:
./descendant::node[@nodeTypeAlias='Person' and contains(Exslt.ExsltStrings:uppercase(data[@alias='fornavn']), 'JENS')]
I've made my own xslt-extension and tried to reference it in the same way, but I still get the same error. Everything works fine in a plain xsl-file, but for different reasons I need to work with the nodes ind the usercontrol.
ahh, I see.
I have not tried it myself, but you may need to do some extra work on the context. I found this link: http://msdn.microsoft.com/en-us/library/ms950806.aspx - maybe it's usefull (last section, putting it all together)
Assuming you are just after converting any case to upper case, you could actually use the xsl translate function if you wanted, e.g.
<xsl:variable name="lcletters">abcdefghijklmnopqrstuvwxyz</xsl:variable>
<xsl:variable name="ucletters">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
<xsl:value-of select="translate('CaTeRpiLLar', $lcletters, $ucletters)"/>
in my case, I store the two variables in a common xslt include. so I can call the translate on any template that includes it.
is working on a reply...