Our Forum has Moved

This site is our old forum and is only here for achive until we get proper 301 redirects setup to make Google happy.

Please use our new community site - Our Umbraco - which contains an improved forum, documentation wiki, package repository and a member locator.

Go to Our Umbraco now

Learn everything about Umbraco
Error: [Expression must evaluate to a node-set] with data from xslt extension. Options
widescreen
Posted: Friday, December 12, 2008 8:25:54 AM

Rank: Newbie

Joined: 3/29/2008
Posts: 24
Location: NC
I have a little bit of sample code:

Code:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:Stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
<xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library"
        xmlns:mine="urn:mine"
    exclude-result-prefixes="msxml umbraco.library mine">

<xsl:output method="xml" omit-xml-declaration="yes"/>

<xsl:param name="currentPage"/>
<xsl:variable name="messages" select="mine:UnreadMessages()" />

<xsl:template match="/">
<xsl:for-each select="$messages/node">
HERE
</xsl:for-each>

</xsl:template>

</xsl:stylesheet>


mine:UnreadMessages() returns a string of XML data, but when I try to iterate through the xml data, I am receiving and error on save:

Code:

Hide ErrorsError occured
System.Xml.XPath.XPathException: Expression must evaluate to a node-set.
at MS.Internal.Xml.XPath.ExtensionQuery.Advance()
at MS.Internal.Xml.XPath.ChildrenQuery.Advance()
at MS.Internal.Xml.XPath.XPathSelectionIterator.MoveNext()
at System.Xml.Xsl.XsltOld.ActionFrame.NewNextNode(Processor proc)
at System.Xml.Xsl.XsltOld.ForEachAction.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 umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String fileContents, Boolean ignoreDebugging)


I have dug through the forums and have found others with this problem, but haven't been able to find a workable solution. Can anyone explain how to iterate through XML returned from an xslt extension?

BTW - the copy of an <xsl:copy-of> is this:
Code:

&lt;NewDataSet&gt;
  &lt;Messages&gt;
    &lt;CreatedOn&gt;2008-12-12T02:23:13.9830731-05:00&lt;/CreatedOn&gt;
    &lt;Message&gt;This is a test.&lt;/Message&gt;
  &lt;/Messages&gt;
&lt;/NewDataSet&gt;


Thanks for the help as always.

Hal
widescreen
Posted: Friday, December 12, 2008 8:35:32 AM

Rank: Newbie

Joined: 3/29/2008
Posts: 24
Location: NC
One additional note: I have tried doing the following as well:

Code:

<xsl:variable name="messages" select="msxml:node-set(meta:UnreadMessages())" />


But receive an error like the following:

Code:

System.Xml.XPath.XPathException: Function 'msxml:node-set()' has failed. ---> System.Xml.Xsl.XsltException: Cannot convert the operand to 'Result tree fragment'.
at System.Xml.Xsl.XsltOld.XsltCompileContext.XsltFunctionImpl.ToNavigator(Object argument)
at System.Xml.Xsl.XsltOld.XsltCompileContext.FuncNodeSet.Invoke(XsltContext xsltContext, Object[] args, XPathNavigator docContext)
at MS.Internal.Xml.XPath.FunctionQuery.Evaluate(XPathNodeIterator nodeIterator)
--- End of inner exception stack trace ---
at MS.Internal.Xml.XPath.FunctionQuery.Evaluate(XPathNodeIterator nodeIterator)
at System.Xml.Xsl.XsltOld.Processor.RunQuery(ActionFrame context, Int32 key)
at System.Xml.Xsl.XsltOld.VariableAction.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 umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String fileContents, Boolean ignoreDebugging)
PeterD
Posted: Friday, December 12, 2008 9:14:59 AM

Rank: Addict

Joined: 7/20/2006
Posts: 842
Location: NL
Hal,

the result-set, does it have brackets or does it contain lt's and gt's? (From what I see in your copy-of)
If the latter, than that is the problem. Make your dll to spit out brackets.

HTH,
PeterD


Add compression to your site in 10 minutes
Looking for a calendar with recurring events?

widescreen
Posted: Friday, December 12, 2008 9:21:36 AM

Rank: Newbie

Joined: 3/29/2008
Posts: 24
Location: NC
PeterD wrote:
does it have brackets or does it contain lt's and gt's? (From what I see in your copy-of) If the latter, than that is the problem. Make your dll to spit out brackets.


My copy-of does send the content to the browser with gt, lt, but in my extensions method I am simply doing a DataSet.GetXml().

I've tried, in turn, wrapping the DataSet.GetXml with an HttpUtility.HtmlDecode(input), but seem to get the same results on output.

I'll dig a little deeper here - that maybe my problem.

Thanks for the help.

Hal
PeterD
Posted: Friday, December 12, 2008 9:26:41 AM

Rank: Addict

Joined: 7/20/2006
Posts: 842
Location: NL
Try sending it to screen with value-of with disible output-escaping and see if it sends the correct format.
Might shed some more light


Add compression to your site in 10 minutes
Looking for a calendar with recurring events?

widescreen
Posted: Friday, December 12, 2008 9:44:44 AM

Rank: Newbie

Joined: 3/29/2008
Posts: 24
Location: NC
Thank you, thank you, thank you. Looks like I need to return a result set as an System.Xml.XPath.XPathNodeIterator instead of a string. After updating:

Code:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:Stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
<xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library"
        xmlns:meta="urn:meta"
    exclude-result-prefixes="msxml umbraco.library meta">

<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:variable name="messages" select="meta:UnreadMessages()" />

<xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:for-each select="$messages/NewDataSet/Messages">
<xsl:copy-of select="$messages" />
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>


... works completely as expected.

Best regards,

Hal
widescreen
Posted: Friday, December 12, 2008 9:47:19 AM

Rank: Newbie

Joined: 3/29/2008
Posts: 24
Location: NC
Just a quick note on the above. I found the solution to returning a result set as an XPathNodeIterator here:

http://blockquote.be/examples/umbraco-xslt-lib-astuanax.txt

The forum has moved

This forum is no longer in use, so you can't reply to this message - please go to Our Umbraco

Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.