Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAtsushi Eno <atsushieno@gmail.com>2005-12-24 19:22:09 +0300
committerAtsushi Eno <atsushieno@gmail.com>2005-12-24 19:22:09 +0300
commit9b9d24f8a658f7c3a82049b568ef74c9743d230a (patch)
treee0fab7c772ea9078b6f2ea7b51268e306cdfde67 /mcs/class/System.XML
parent844cf8e425d55dd8d9faafca34d68b2d132ccebd (diff)
2005-12-24 Atsushi Enomoto <atsushi@ximian.com>
* 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
Diffstat (limited to 'mcs/class/System.XML')
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog8
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs13
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl/GenericOutputter.cs2
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl/HtmlEmitter.cs2
-rw-r--r--mcs/class/System.XML/Mono.Xml.Xsl/XslOutput.cs43
5 files changed, 36 insertions, 32 deletions
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 <atsushi@ximian.com>
+
+ * 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 <drieseng@users.sourceforge.net>
* 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: