From 9b9d24f8a658f7c3a82049b568ef74c9743d230a Mon Sep 17 00:00:00 2001 From: Atsushi Eno Date: Sat, 24 Dec 2005 16:22:09 +0000 Subject: 2005-12-24 Atsushi Enomoto * 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 svn path=/trunk/mcs/; revision=54833 --- mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog | 8 ++++ mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs | 13 ++++--- .../System.XML/Mono.Xml.Xsl/GenericOutputter.cs | 2 +- mcs/class/System.XML/Mono.Xml.Xsl/HtmlEmitter.cs | 2 +- mcs/class/System.XML/Mono.Xml.Xsl/XslOutput.cs | 43 +++++++++------------- 5 files changed, 36 insertions(+), 32 deletions(-) (limited to 'mcs/class/System.XML') diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog b/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog index 1718b338f42..6641c25340c 100644 --- a/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog +++ b/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog @@ -1,3 +1,11 @@ +2005-12-24 Atsushi Enomoto + + * 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 * XslOutput.cs: Reduced indentation of cases in switch statement. diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs b/mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs index d60e652f0c5..8f90d24c00e 100644 --- a/mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs +++ b/mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs @@ -127,7 +127,8 @@ namespace Mono.Xml.Xsl 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 @@ namespace Mono.Xml.Xsl // 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 @@ namespace Mono.Xml.Xsl 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); diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/GenericOutputter.cs b/mcs/class/System.XML/Mono.Xml.Xsl/GenericOutputter.cs index 36bb6729a32..2a302cf15f0 100644 --- a/mcs/class/System.XML/Mono.Xml.Xsl/GenericOutputter.cs +++ b/mcs/class/System.XML/Mono.Xml.Xsl/GenericOutputter.cs @@ -145,7 +145,7 @@ namespace Mono.Xml.Xsl break; case OutputMethod.XML: XmlTextWriter w = new XmlTextWriter (pendingTextWriter); - if (xslOutput.Indent) + if (xslOutput.Indent == "yes") w.Formatting = Formatting.Indented; _emitter = new XmlWriterEmitter (w); diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/HtmlEmitter.cs b/mcs/class/System.XML/Mono.Xml.Xsl/HtmlEmitter.cs index fe9aaff392b..a34f9c7acf2 100644 --- a/mcs/class/System.XML/Mono.Xml.Xsl/HtmlEmitter.cs +++ b/mcs/class/System.XML/Mono.Xml.Xsl/HtmlEmitter.cs @@ -55,7 +55,7 @@ namespace Mono.Xml.Xsl 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; diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/XslOutput.cs b/mcs/class/System.XML/Mono.Xml.Xsl/XslOutput.cs index 744cf22716d..842dc1d4002 100644 --- a/mcs/class/System.XML/Mono.Xml.Xsl/XslOutput.cs +++ b/mcs/class/System.XML/Mono.Xml.Xsl/XslOutput.cs @@ -70,22 +70,17 @@ namespace Mono.Xml.Xsl 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 - { - NotSet, - Yes, - No - } - - public XslOutput (string uri) + public XslOutput (string uri, string stylesheetVersion) { this.uri = uri; + this.stylesheetVersion = stylesheetVersion; } public OutputMethod Method { get { return method; }} @@ -127,8 +122,8 @@ namespace Mono.Xml.Xsl } } - public bool Indent { - get { return indent == IndentType.Yes; } + public string Indent { + get { return indent; } } public string MediaType { @@ -174,9 +169,6 @@ namespace Mono.Xml.Xsl break; case "html": omitXmlDeclaration = true; - if (indent == IndentType.NotSet) { - indent = IndentType.Yes; - } method = OutputMethod.HTML; break; case "text": @@ -262,21 +254,22 @@ namespace Mono.Xml.Xsl } break; case "indent": + indent = value; + if (stylesheetVersion != "1.0") + break; switch (value) { - case "yes": - this.indent = IndentType.Yes; - break; - case "no": - this.indent = IndentType.No; + case "yes": + case "no": + break; + default: + switch (method) { + case OutputMethod.Custom: 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: -- cgit v1.2.3