I've got an old Umbraco website running on 4.0.3 and I'm trying to extend the \umbraco\xslt\searchResult.xslt file to show more info in the backoffice search results. Because I don't want to change the source I'm trying to add my own XSLT extension which displays the template of the found node. When I try to add my own XSLT extension I'm getting this error:
System.Xml.Xsl.XsltException: Cannot find the script or external object that implements prefix 'Project.Tools'.
at System.Xml.Xsl.XsltOld.XsltCompileContext.ResolveFunction(String prefix, String name, XPathResultType[] argTypes)
at MS.Internal.Xml.XPath.FunctionQuery.SetXsltContext(XsltContext context)
at System.Xml.Xsl.XsltOld.Processor.GetValueQuery(Int32 key, XsltCompileContext context)
at System.Xml.Xsl.XsltOld.Processor.ValueOf(ActionFrame context, Int32 key)
at System.Xml.Xsl.XsltOld.ValueOfAction.Execute(Processor processor, ActionFrame frame)
at System.Xml.Xsl.XsltOld.ActionFrame.Execute(Processor processor)
at System.Xml.Xsl.XsltOld.Processor.Execute()
at System.Xml.Xsl.XsltOld.Processor.Execute(TextWriter writer)
at System.Xml.Xsl.XslTransform.Transform(XPathNavigator input, XsltArgumentList args, TextWriter output, XmlResolver resolver)
at System.Xml.Xsl.XslTransform.Transform(IXPathNavigable input, XsltArgumentList args, TextWriter output, XmlResolver resolver)
at System.Web.UI.WebControls.Xml.Render(HtmlTextWriter output)
at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
at umbraco.uicontrols.Pane.Render(HtmlTextWriter writer) in d:\TeamCity\buildAgent\work\7380c184e9fcd3ea\components\umbraco.controls\pane.cs:line 99
I already added the extension there. It works in normal XSLT files, but not in this XSLT file which is in the Umbraco backoffice. Also tried Umbraco XSLT extensions and those also don't work.
Ahhh... sorry, missed that. Those are different and not handled the same way. You might need to put the code in your xslt file directly, but someone who is better with the source of the back office might know better.
I'm now trying in-line C# like you mentioned in your blog, but it gives me this error:
Error creating control System.Xml.Xsl.XsltCompileException: XSLT compile error at C:\SVN\PrismaIntranet\trunk\site\umbraco\xslt\searchResult.xslt(30,58). See InnerException for details. ---> System.Xml.Xsl.XsltException: The 'msxsl:script' element cannot be empty. at System.Xml.Xsl.XsltOld.ContainerAction.AddScript(Compiler compiler) at System.Xml.Xsl.XsltOld.ContainerAction.CompileTopLevelElements(Compiler compiler) at System.Xml.Xsl.XsltOld.ContainerAction.CompileDocument(Compiler compiler, Boolean inInclude) at System.Xml.Xsl.XsltOld.RootAction.Compile(Compiler compiler) at System.Xml.Xsl.XsltOld.Compiler.CreateRootAction() at System.Xml.Xsl.XsltOld.Compiler.Compile(NavigatorInput input, XmlResolver xmlResolver, Evidence evidence) --- End of inner exception stack trace --- at System.Xml.Xsl.XsltOld.Compiler.Compile(NavigatorInput input, XmlResolver xmlResolver, Evidence evidence) at System.Xml.Xsl.XslTransform.Compile(XPathNavigator stylesheet, XmlResolver resolver, Evidence evidence) at System.Xml.Xsl.XslTransform.Load(XPathNavigator stylesheet, XmlResolver resolver) at System.Xml.Xsl.XslTransform.Load(IXPathNavigable stylesheet, XmlResolver resolver) at System.Xml.Xsl.XslTransform.Load(XmlReader stylesheet) at System.Web.UI.WebControls.Xml.LoadTransformFromSource() at System.Web.UI.WebControls.Xml.Render(HtmlTextWriter output) at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) at System.Web.UI.Control.RenderControl(HtmlTextWriter writer) at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) at umbraco.uicontrols.Pane.Render(HtmlTextWriter writer) in d:\TeamCity\buildAgent\work\7380c184e9fcd3ea\components\umbraco.controls\pane.cs:line 99
The element is not empty. If I remove the complete msxsl:script part it doesn't give an error.
Correct me if I'm wrong, but asp:xml knows nothing about Umbraco's extensions. When we run an XML script on the front-end we add extensions, etc. to the XSLT engine before running it. I'm afraid the asp:xml control does nothing of that. So you try to use an extension that it's not aware of.
Look at System.Web.UI.WebControls.Xml documentation, there might be a way to register extensions...
Hmm that would cause all these issues :p. Haven't looked at a way to register extensions yet, but if it's possible I'm afraid that I'll need to change something in the Umbraco source and that's what I've been trying to avoid here. If I need to change the Umbraco source anyways there are easier ways to extend the search results page.
Now I'm using Simple Search for Umbraco. It replaces searching in the Umbraco backoffice and I modified it to show the extra info I needed. This way I still didn't need to modify the Umbraco source.
XSLT extensions not working
Hello,
I've got an old Umbraco website running on 4.0.3 and I'm trying to extend the \umbraco\xslt\searchResult.xslt file to show more info in the backoffice search results. Because I don't want to change the source I'm trying to add my own XSLT extension which displays the template of the found node. When I try to add my own XSLT extension I'm getting this error:
System.Xml.Xsl.XsltException: Cannot find the script or external object that implements prefix 'Project.Tools'. at System.Xml.Xsl.XsltOld.XsltCompileContext.ResolveFunction(String prefix, String name, XPathResultType[] argTypes) at MS.Internal.Xml.XPath.FunctionQuery.SetXsltContext(XsltContext context) at System.Xml.Xsl.XsltOld.Processor.GetValueQuery(Int32 key, XsltCompileContext context) at System.Xml.Xsl.XsltOld.Processor.ValueOf(ActionFrame context, Int32 key) at System.Xml.Xsl.XsltOld.ValueOfAction.Execute(Processor processor, ActionFrame frame) at System.Xml.Xsl.XsltOld.ActionFrame.Execute(Processor processor) at System.Xml.Xsl.XsltOld.Processor.Execute() at System.Xml.Xsl.XsltOld.Processor.Execute(TextWriter writer) at System.Xml.Xsl.XslTransform.Transform(XPathNavigator input, XsltArgumentList args, TextWriter output, XmlResolver resolver) at System.Xml.Xsl.XslTransform.Transform(IXPathNavigable input, XsltArgumentList args, TextWriter output, XmlResolver resolver) at System.Web.UI.WebControls.Xml.Render(HtmlTextWriter output) at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) at System.Web.UI.Control.RenderControl(HtmlTextWriter writer) at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) at umbraco.uicontrols.Pane.Render(HtmlTextWriter writer) in d:\TeamCity\buildAgent\work\7380c184e9fcd3ea\components\umbraco.controls\pane.cs:line 99
This is how the XSLT file:
In the 4.0 versions you need to manually add the extensions to the /config/xsltextensions.config file I believe.
cheers,
doug.
I already added the extension there. It works in normal XSLT files, but not in this XSLT file which is in the Umbraco backoffice. Also tried Umbraco XSLT extensions and those also don't work.
Jeroen
Ahhh... sorry, missed that. Those are different and not handled the same way. You might need to put the code in your xslt file directly, but someone who is better with the source of the back office might know better.
Here's how to do it: http://blog.percipientstudios.com/2009/9/21/advanced-xslt-with-net-namespaces.aspx. Read the comments too about debug mode.
cheers,
doug.
I'm now trying in-line C# like you mentioned in your blog, but it gives me this error:
Error creating control
System.Xml.Xsl.XsltCompileException: XSLT compile error at C:\SVN\PrismaIntranet\trunk\site\umbraco\xslt\searchResult.xslt(30,58). See InnerException for details. ---> System.Xml.Xsl.XsltException: The 'msxsl:script' element cannot be empty. at System.Xml.Xsl.XsltOld.ContainerAction.AddScript(Compiler compiler) at System.Xml.Xsl.XsltOld.ContainerAction.CompileTopLevelElements(Compiler compiler) at System.Xml.Xsl.XsltOld.ContainerAction.CompileDocument(Compiler compiler, Boolean inInclude) at System.Xml.Xsl.XsltOld.RootAction.Compile(Compiler compiler) at System.Xml.Xsl.XsltOld.Compiler.CreateRootAction() at System.Xml.Xsl.XsltOld.Compiler.Compile(NavigatorInput input, XmlResolver xmlResolver, Evidence evidence) --- End of inner exception stack trace --- at System.Xml.Xsl.XsltOld.Compiler.Compile(NavigatorInput input, XmlResolver xmlResolver, Evidence evidence) at System.Xml.Xsl.XslTransform.Compile(XPathNavigator stylesheet, XmlResolver resolver, Evidence evidence) at System.Xml.Xsl.XslTransform.Load(XPathNavigator stylesheet, XmlResolver resolver) at System.Xml.Xsl.XslTransform.Load(IXPathNavigable stylesheet, XmlResolver resolver) at System.Xml.Xsl.XslTransform.Load(XmlReader stylesheet) at System.Web.UI.WebControls.Xml.LoadTransformFromSource() at System.Web.UI.WebControls.Xml.Render(HtmlTextWriter output) at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) at System.Web.UI.Control.RenderControl(HtmlTextWriter writer) at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) at umbraco.uicontrols.Pane.Render(HtmlTextWriter writer) in d:\TeamCity\buildAgent\work\7380c184e9fcd3ea\components\umbraco.controls\pane.cs:line 99
The element is not empty. If I remove the complete msxsl:script part it doesn't give an error.
Jeroen
I wonder if it just isn't possible in the back office context? I've never tried it but it sure seems it ought to work.
Can you post a trimmed down version of your searchResult.xslt file? Perhaps a second set of eyes might spot something.
cheers,
doug.
The xslt in my first post is the complete search result file. Here is how the file is loaded in the Umbraco backoffice:
search.aspx
Correct me if I'm wrong, but asp:xml knows nothing about Umbraco's extensions. When we run an XML script on the front-end we add extensions, etc. to the XSLT engine before running it. I'm afraid the asp:xml control does nothing of that. So you try to use an extension that it's not aware of.
Look at System.Web.UI.WebControls.Xml documentation, there might be a way to register extensions...
Hmm that would cause all these issues :p. Haven't looked at a way to register extensions yet, but if it's possible I'm afraid that I'll need to change something in the Umbraco source and that's what I've been trying to avoid here. If I need to change the Umbraco source anyways there are easier ways to extend the search results page.
Jeroen
*cough* You could use XSLTsearch *cough*
Now I'm using Simple Search for Umbraco. It replaces searching in the Umbraco backoffice and I modified it to show the extra info I needed. This way I still didn't need to modify the Umbraco source.
Jeroen
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.