http://bugzilla.novell.com/show_bug.cgi?id=559994
http://bugzilla.novell.com/show_bug.cgi?id=559994#c0 Summary: XSLT 1.0 Incompatibility: result tree fragments treatable as node-sets, but shouldn't be Classification: Mono Product: Mono: Class Libraries Version: SVN Platform: x86-64 OS/Version: openSUSE 11.2 Status: NEW Severity: Normal Priority: P5 - None Component: Sys.XML AssignedTo: [email protected] ReportedBy: [email protected] QAContact: [email protected] Found By: --- Blocker: --- Mono's XSLT allows treating result tree fragments as if they were node sets, but this is forbidden by the XSLT 1.0 standard (ยง11.1) and incompatible with NET. Quoth the standard http://www.w3.org/TR/xslt#section-Result-Tree-Fragments: In particular, it is not permitted to use the /, //, and [] operators on result tree fragments. Thus, consider the following program: using System; using System.IO; using System.Xml; using System.Xml.XPath; using System.Xml.Xsl; class Test { public static void Main () { string xsl = @"<xsl:stylesheet version='1.0' exclude-result-prefixes='msxsl' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:msxsl='urn:schemas-microsoft-com:xslt' > <xsl:template match='/'> <root> <xsl:variable name='t'> <xsl:call-template name='get-type' /> </xsl:variable> <xsl:value-of select='$t/@Name' /> </root> </xsl:template> <xsl:template name='get-type'> <Type Name='Foo' Namespace='Bar' /> </xsl:template> </xsl:stylesheet>"; var t = new XslCompiledTransform (); t.Load (new XPathDocument (new StringReader (xsl))); t.Transform ( new XPathDocument ( new XmlTextReader ( new StringReader ( "<root><foo attr='A'/><foo attr='B'/><foo attr='C'/></root>"))), null, Console.Out); Console.WriteLine(); } } Under Mono, it generates: <?xml version="1.0" encoding="utf-8"?><root>Foo</root> Under .NET, it generates: Unhandled Exception: System.Xml.Xsl.XslTransformException: To use a result tree fragment in a path expression, first convert it to a node-set using the msxsl:no de-set() function. at System.Xml.Xsl.Runtime.XsltConvert.EnsureNodeSet(IList`1 listItems) at <xsl:template match="/">(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-d ebug}runtime) at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver da taSources, XsltArgumentList argumentList, XmlWriter writer, Boolean closeWriter) at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlRe solver dataSources, XsltArgumentList argumentList, XmlWriter results) at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltA rgumentList arguments, TextWriter results) at Test.Main() <?xml version="1.0" encoding="IBM437"?><root> For user code, they should change line 21 from: <xsl:value-of select='$t/@Name' /> to: <xsl:value-of select='msxsl:node-set($t)/Type/@Name' /> This generates proper output under both .NET and Mono: <?xml version="1.0" encoding="utf-8"?><root>Foo</root> -- Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the QA contact for the bug. _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
