|
|
 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 " "> ]> <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: <NewDataSet> <Messages> <CreatedOn>2008-12-12T02:23:13.9830731-05:00</CreatedOn> <Message>This is a test.</Message> </Messages> </NewDataSet>
Thanks for the help as always. Hal
|
|
 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)
|
|
 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?
|
|
 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
|
|
 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?
|
|
 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 " "> ]> <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
|
|
 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
|
|
Guest |