5 // Oleg Tkachenko (oleg@tkachenko.com)
7 // (C) 2003 Oleg Tkachenko
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 using System.Collections;
36 namespace Mono.Xml.Xsl {
38 /// Outputter implementation for XML output method
40 internal class XmlOutputter : Outputter {
41 private XmlWriter _writer;
42 private Hashtable _outputs;
43 private XslOutput _currentOutput;
45 public XmlOutputter(XmlWriter w, Hashtable o) {
48 _currentOutput = (XslOutput)o[String.Empty];
51 public XmlOutputter(TextWriter w, Hashtable o)
52 : this(new XmlTextWriter(w), o) {}
54 public override void WriteStartDocument() {
55 if (_currentOutput != null && _currentOutput.OmitXmlDeclaration)
57 if (_currentOutput == null || _currentOutput.Standalone == null)
58 _writer.WriteStartDocument();
60 _writer.WriteStartDocument(_currentOutput.Standalone == "yes");
63 public override void WriteEndDocument() {
64 _writer.WriteEndDocument();
67 public override void WriteStartElement(string prefix, string localName, string nsURI) {
68 _writer.WriteStartElement(prefix, localName, nsURI);
71 public override void WriteEndElement() {
72 _writer.WriteEndElement();
75 public override void WriteAttributeString(string prefix, string localName, string nsURI, string value) {
76 _writer.WriteAttributeString(prefix, localName, nsURI, value);
79 public override void WriteStartAttribute(string prefix, string localName, string nsURI) {
80 _writer.WriteStartAttribute(prefix, localName, nsURI);
83 public override void WriteEndAttribute() {
84 _writer.WriteEndAttribute();
87 public override void WriteComment(string text) {
88 _writer.WriteComment(text);
91 public override void WriteProcessingInstruction(string name, string text) {
92 _writer.WriteProcessingInstruction(name, text);
95 public override void WriteString(string text) {
96 _writer.WriteString(text);
99 public override void WriteRaw(string data) {
100 _writer.WriteRaw(data);
103 public override void Done () {