Author: atsushi
Date: 2007-12-27 09:34:30 -0500 (Thu, 27 Dec 2007)
New Revision: 91939

Modified:
   trunk/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog
   trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs
   trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslTemplate.cs
   trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslTransformProcessor.cs
Log:
2007-12-27  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * XslTemplate.cs, XslTransformProcessor.cs :
          Some disambiguation around whitespace handling (input strip/preserve
          and output control).
        * XslStylesheet.cs : change GetPreserveWhitespace() to match the
          actual behavior; it does not (and should not) really walk through
          ancestors. Default whitespace handling depends on the default ("*")
          handling. (Those changes should not affect anything.)



Modified: trunk/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog   2007-12-27 14:27:55 UTC 
(rev 91938)
+++ trunk/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog   2007-12-27 14:34:30 UTC 
(rev 91939)
@@ -1,3 +1,13 @@
+2007-12-27  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * XslTemplate.cs, XslTransformProcessor.cs :
+         Some disambiguation around whitespace handling (input strip/preserve
+         and output control).
+       * XslStylesheet.cs : change GetPreserveWhitespace() to match the
+         actual behavior; it does not (and should not) really walk through
+         ancestors. Default whitespace handling depends on the default ("*")
+         handling. (Those changes should not affect anything.)
+
 2007-10-30  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * Compiler.cs : added CheckExtraAttributes() to check invalid

Modified: trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs    2007-12-27 
14:27:55 UTC (rev 91938)
+++ trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs    2007-12-27 
14:34:30 UTC (rev 91939)
@@ -233,11 +233,13 @@
                {
                        if (!HasSpaceControls)
                                return true;
-                       return GetPreserveWhitespaceInternal (nav.Clone ());
-               }
+                       nav = nav.Clone ();
 
-               private bool GetPreserveWhitespaceInternal (XPathNavigator nav)
-               {
+                       if (!nav.MoveToParent () || nav.NodeType != 
XPathNodeType.Element) {
+                               object def = GetDefaultXmlSpace ();
+                               return def == null || (XmlSpace) def == 
XmlSpace.Preserve;
+                       }
+
                        string localName = nav.LocalName;
                        string ns = nav.NamespaceURI;
 
@@ -263,16 +265,8 @@
                                }
                        }
 
-                       if (o == null) {
-                               o = spaceControls [allMatchName];
-                               if (o == null) {
-                                       for (int i = 0; i < imports.Count; i++) 
{
-                                               o = ((XslStylesheet) imports 
[i]).SpaceControls [qname];
-                                               if (o != null)
-                                                       break;
-                                       }
-                               }
-                       }
+                       if (o == null)
+                               o = GetDefaultXmlSpace ();
 
                        if (o != null) {
                                switch ((XmlSpace) o) {
@@ -282,12 +276,22 @@
                                        return false;
                                }
                        }
-                       if (nav.MoveToParent () &&
-                               nav.NodeType == XPathNodeType.Element)
-                               return GetPreserveWhitespace (nav);
-                       return true;
+                       throw new SystemException ("Mono BUG: should not reach 
here");
                }
 
+               object GetDefaultXmlSpace ()
+               {
+                       object o = spaceControls [allMatchName];
+                       if (o == null) {
+                               for (int i = 0; i < imports.Count; i++) {
+                                       o = ((XslStylesheet) imports 
[i]).SpaceControls [allMatchName];
+                                       if (o != null)
+                                               break;
+                               }
+                       }
+                       return o;
+               }
+
                bool countedNamespaceAliases;
                bool cachedHasNamespaceAliases;
                public bool HasNamespaceAliases {

Modified: trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslTemplate.cs
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslTemplate.cs      2007-12-27 
14:27:55 UTC (rev 91938)
+++ trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslTemplate.cs      2007-12-27 
14:34:30 UTC (rev 91939)
@@ -467,7 +467,7 @@
                public override void Evaluate (XslTransformProcessor p, 
Hashtable withParams)
                {
                        if (p.CurrentNode.NodeType == XPathNodeType.Whitespace) 
{
-                               if (p.PreserveWhitespace ())
+                               if (p.PreserveOutputWhitespace)
                                        p.Out.WriteWhitespace 
(p.CurrentNode.Value);
                        }
                        else

Modified: trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslTransformProcessor.cs
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslTransformProcessor.cs    
2007-12-27 14:27:55 UTC (rev 91938)
+++ trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslTransformProcessor.cs    
2007-12-27 14:34:30 UTC (rev 91939)
@@ -457,6 +457,15 @@
                {
                        if (!iter.MoveNext ())
                                return false;
+                       // FIXME: this check should not be required.
+                       // Since removal of this check causes some regressions,
+                       // there should be some wrong assumption on our
+                       // BaseIterator usage. Actually BaseIterator should
+                       // not do whitespace check and every PreserveWhitespace
+                       // evaluation in XslTransform should be done at
+                       // different level. One possible solution is to wrap
+                       // the input XmlReader by a new XmlReader that takes
+                       // whitespace stripping into consideration.
                        if (iter.Current.NodeType == XPathNodeType.Whitespace 
&& !XPathContext.PreserveWhitespace (iter.Current))
                                return NodesetMoveNext (iter);
                        return true;
@@ -601,10 +610,8 @@
                        Out.InsideCDataSection = XPathContext.IsCData;
                }
 
-               public bool PreserveWhitespace ()
-               {
-//                     return XPathContext.PreserveWhitespace (CurrentNode);
-                       return XPathContext.Whitespace;
+               public bool PreserveOutputWhitespace {
+                       get { return XPathContext.Whitespace; }
                }
        }
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to