[Mono-bugs] [Bug 560064] New: Variable containing result-tree-fragment should be true()

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Dec 2 14:52:29 EST 2009



           Summary: Variable containing result-tree-fragment should 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: atsushi at ximian.com
        ReportedBy: jpryor at novell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---

This is an incompatibility with .NET.

If an <xsl:variable/> is initialized to contain the result of an
<xsl:call-template/> (which returns nothing), Mono treats the value as having a
false() value within boolean expressions, while .NET treats it as having a
true() value.  Consider:

  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' 
    <xsl:param name='Index' />
    <xsl:template match='/'>
      <xsl:variable name='b'>
        <xsl:call-template name='get-bar'>
          <xsl:with-param name='type' select=""'Mono.DocTest.Color'"" />
      <xsl:if test='$b'>
        <b hasvalue='true' />
    <xsl:template name='get-bar'>
      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

The output under Mono:

  <?xml version="1.0" encoding="utf-8"?><root></root>

The output under .NET:

  <?xml version="1.0" encoding="IBM437"?><root><b hasvalue="true" /></root>

Notice that .NET treats <xsl:if test="$b" /> as being true(), not false(), even
though $b doesn't actually contain anything.

To make .NET behave like Mono, the result tree fragment needs to be converted
into a string, e.g.:  <xsl:if test="string($b)" />

Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the mono-bugs mailing list