Author: atsushi
Date: 2005-12-24 11:22:09 -0500 (Sat, 24 Dec 2005)
New Revision: 54833

Modified:
   trunk/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog
   trunk/mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs
   trunk/mcs/class/System.XML/Mono.Xml.Xsl/GenericOutputter.cs
   trunk/mcs/class/System.XML/Mono.Xml.Xsl/HtmlEmitter.cs
   trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslOutput.cs
Log:
2005-12-24  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * Compiler.cs : pass stylesheet version to XslOutput to
        * determine
          "indent" value validity.
        * XslOutput.cs, HtmlEmitter.cs, GenericOutputter.cs : Reverted
          buggy changes on "indent" attribute handling.
          http://www.w3.org/TR/xslt#section-HTML-Output-Method



Modified: trunk/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog   2005-12-24 14:58:10 UTC 
(rev 54832)
+++ trunk/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog   2005-12-24 16:22:09 UTC 
(rev 54833)
@@ -1,3 +1,11 @@
+2005-12-24  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * Compiler.cs : pass stylesheet version to XslOutput to determine
+         "indent" value validity.
+       * XslOutput.cs, HtmlEmitter.cs, GenericOutputter.cs : Reverted
+         buggy changes on "indent" attribute handling.
+         http://www.w3.org/TR/xslt#section-HTML-Output-Method
+
 2005-12-23  Gert Driesen  <[EMAIL PROTECTED]>
 
        * XslOutput.cs: Reduced indentation of cases in switch statement.

Modified: trunk/mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs 2005-12-24 14:58:10 UTC 
(rev 54832)
+++ trunk/mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs 2005-12-24 16:22:09 UTC 
(rev 54833)
@@ -127,7 +127,8 @@
                XslStylesheet rootStyle;
                Hashtable outputs = new Hashtable ();
                bool keyCompilationMode;        
-       
+               string stylesheetVersion;
+
                public CompiledStylesheet Compile (XPathNavigator nav, 
XmlResolver res, Evidence evidence)
                {
                        this.xpathParser = new XPathParser (this);
@@ -140,11 +141,13 @@
                        // reject empty document.
                        if (nav.NodeType == XPathNodeType.Root && 
!nav.MoveToFirstChild ())
                                throw new XsltCompileException ("Stylesheet 
root element must be either \"stylesheet\" or \"transform\" or any literal 
element", null, nav);
-                               
-                       outputs [""] = new XslOutput ("");
-                               
                        while (nav.NodeType != XPathNodeType.Element) 
nav.MoveToNext();
                        
+                       stylesheetVersion = nav.GetAttribute ("version", 
+                               (nav.NamespaceURI != XsltNamespace) ?
+                               XsltNamespace : String.Empty);
+                       outputs [""] = new XslOutput ("", stylesheetVersion);
+                               
                        PushInputDocument (nav);
                        if (nav.MoveToFirstNamespace 
(XPathNamespaceScope.ExcludeXml))
                        {
@@ -600,7 +603,7 @@
                        string uri = n.GetAttribute ("href", "");
                        XslOutput output = outputs [uri] as XslOutput;
                        if (output == null) {
-                               output = new XslOutput (uri);
+                               output = new XslOutput (uri, stylesheetVersion);
                                outputs.Add (uri, output);
                        }
                        output.Fill (n);

Modified: trunk/mcs/class/System.XML/Mono.Xml.Xsl/GenericOutputter.cs
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.Xsl/GenericOutputter.cs 2005-12-24 
14:58:10 UTC (rev 54832)
+++ trunk/mcs/class/System.XML/Mono.Xml.Xsl/GenericOutputter.cs 2005-12-24 
16:22:09 UTC (rev 54833)
@@ -145,7 +145,7 @@
                                        break;
                                case OutputMethod.XML:
                                        XmlTextWriter w = new XmlTextWriter 
(pendingTextWriter);
-                                       if (xslOutput.Indent)
+                                       if (xslOutput.Indent == "yes")
                                                w.Formatting = 
Formatting.Indented;
 
                                        _emitter = new XmlWriterEmitter (w);

Modified: trunk/mcs/class/System.XML/Mono.Xml.Xsl/HtmlEmitter.cs
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.Xsl/HtmlEmitter.cs      2005-12-24 
14:58:10 UTC (rev 54832)
+++ trunk/mcs/class/System.XML/Mono.Xml.Xsl/HtmlEmitter.cs      2005-12-24 
16:22:09 UTC (rev 54833)
@@ -55,7 +55,7 @@
                public HtmlEmitter (TextWriter writer, XslOutput output)
                {
                        this.writer = writer;
-                       indent = output.Indent;
+                       indent = output.Indent == "yes" || output.Indent == 
null;
                        elementNameStack = new Stack ();
                        nonHtmlDepth = -1;
                        outputEncoding = writer.Encoding == null ? 
output.Encoding : writer.Encoding;

Modified: trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslOutput.cs
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslOutput.cs        2005-12-24 
14:58:10 UTC (rev 54832)
+++ trunk/mcs/class/System.XML/Mono.Xml.Xsl/XslOutput.cs        2005-12-24 
16:22:09 UTC (rev 54833)
@@ -70,22 +70,17 @@
                string doctypePublic;
                string doctypeSystem;
                QName [] cdataSectionElements;
-               IndentType indent = IndentType.NotSet;
+               string indent;
                string mediaType;
+               string stylesheetVersion;
 
                // for compilation only.
                ArrayList cdSectsList = new ArrayList ();
 
-               private enum IndentType
+               public XslOutput (string uri, string stylesheetVersion)
                {
-                       NotSet,
-                       Yes,
-                       No
-               }
-
-               public XslOutput (string uri)
-               {
                        this.uri = uri;
+                       this.stylesheetVersion = stylesheetVersion;
                }
 
                public OutputMethod Method { get { return method; }}
@@ -127,8 +122,8 @@
                        }
                }
 
-               public bool Indent {
-                       get { return indent == IndentType.Yes; }
+               public string Indent {
+                       get { return indent; }
                }
 
                public string MediaType {
@@ -174,9 +169,6 @@
                                                break;
                                        case "html":
                                                omitXmlDeclaration = true;
-                                               if (indent == 
IndentType.NotSet) {
-                                                       indent = IndentType.Yes;
-                                               }
                                                method = OutputMethod.HTML;
                                                break;
                                        case "text":
@@ -262,21 +254,22 @@
                                }
                                break;
                        case "indent":
+                               indent = value;
+                               if (stylesheetVersion != "1.0")
+                                       break;
                                switch (value) {
-                                       case "yes":
-                                               this.indent = IndentType.Yes;
+                               case "yes":
+                               case "no":
+                                       break;
+                               default:
+                                       switch (method) {
+                                       case OutputMethod.Custom:
                                                break;
-                                       case "no":
-                                               this.indent = IndentType.No;
-                                               break;
                                        default:
                                                IXmlLineInfo li = nav as 
IXmlLineInfo;
-                                               throw new XsltCompileException 
(new XsltException (
-                                                       "'" + value + "' is an 
invalid value for 'indent'" +
-                                                       " attribute.", 
(Exception) null),
-                                                       nav.BaseURI,
-                                                       li != null ? 
li.LineNumber : 0,
-                                                       li != null ? 
li.LinePosition : 0);
+                                               throw new XsltCompileException 
(String.Format ("Unexpected 'indent' attribute value in 'output' element: 
'{0}'", value), null, nav);
+                                       }
+                                       break;
                                }
                                break;
                        default:

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

Reply via email to