1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Mozilla Public License Version
6
* 1.1 (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/MPL/
10
* Software distributed under the License is distributed on an "AS IS" basis,
11
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
* for the specific language governing rights and limitations under the
15
* The Original Code is the TransforMiiX XSLT processor.
17
* The Initial Developer of the Original Code is
18
* Netscape Communications Corporation.
19
* Portions created by the Initial Developer are Copyright (C) 2001
20
* the Initial Developer. All Rights Reserved.
23
* Peter Van der Beken <peterv@netscape.com>
25
* Alternatively, the contents of this file may be used under the terms of
26
* either the GNU General Public License Version 2 or later (the "GPL"), or
27
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28
* in which case the provisions of the GPL or the LGPL are applicable instead
29
* of those above. If you wish to allow use of your version of this file only
30
* under the terms of either the GPL or the LGPL, and not to allow others to
31
* use your version of this file under the terms of the MPL, indicate your
32
* decision by deleting the provisions above and replace them with the notice
33
* and other provisions required by the GPL or the LGPL. If you do not delete
34
* the provisions above, a recipient may use your version of this file under
35
* the terms of any one of the MPL, the GPL or the LGPL.
37
* ***** END LICENSE BLOCK ***** */
39
#include "txOutputFormat.h"
42
txOutputFormat::txOutputFormat() : mMethod(eMethodNotSet),
43
mOmitXMLDeclaration(eNotSet),
49
txOutputFormat::~txOutputFormat()
51
txListIterator iter(&mCDATASectionElements);
52
while (iter.hasNext())
53
delete (txExpandedName*)iter.next();
56
void txOutputFormat::reset()
58
mMethod = eMethodNotSet;
60
if (mEncoding.IsEmpty())
61
mOmitXMLDeclaration = eNotSet;
62
mStandalone = eNotSet;
65
txListIterator iter(&mCDATASectionElements);
66
while (iter.hasNext())
67
delete (txExpandedName*)iter.next();
69
mMediaType.Truncate();
72
void txOutputFormat::merge(txOutputFormat& aOutputFormat)
74
if (mMethod == eMethodNotSet)
75
mMethod = aOutputFormat.mMethod;
77
if (mVersion.IsEmpty())
78
mVersion = aOutputFormat.mVersion;
80
if (mEncoding.IsEmpty())
81
mEncoding = aOutputFormat.mEncoding;
83
if (mOmitXMLDeclaration == eNotSet)
84
mOmitXMLDeclaration = aOutputFormat.mOmitXMLDeclaration;
86
if (mStandalone == eNotSet)
87
mStandalone = aOutputFormat.mStandalone;
89
if (mPublicId.IsEmpty())
90
mPublicId = aOutputFormat.mPublicId;
92
if (mSystemId.IsEmpty())
93
mSystemId = aOutputFormat.mSystemId;
95
txListIterator iter(&aOutputFormat.mCDATASectionElements);
96
txExpandedName* qName;
97
while ((qName = (txExpandedName*)iter.next())) {
98
mCDATASectionElements.add(qName);
99
// XXX We need txList.clear()
103
if (mIndent == eNotSet)
104
mIndent = aOutputFormat.mIndent;
106
if (mMediaType.IsEmpty())
107
mMediaType = aOutputFormat.mMediaType;
110
void txOutputFormat::setFromDefaults()
115
mMethod = eXMLOutput;
120
if (mVersion.IsEmpty())
121
mVersion.Append(NS_LITERAL_STRING("1.0"));
123
if (mEncoding.IsEmpty())
124
mEncoding.Append(NS_LITERAL_STRING("UTF-8"));
126
if (mOmitXMLDeclaration == eNotSet)
127
mOmitXMLDeclaration = eFalse;
129
if (mIndent == eNotSet)
132
if (mMediaType.IsEmpty())
133
mMediaType.Append(NS_LITERAL_STRING("text/xml"));
139
if (mVersion.IsEmpty())
140
mVersion.Append(NS_LITERAL_STRING("4.0"));
142
if (mEncoding.IsEmpty())
143
mEncoding.Append(NS_LITERAL_STRING("UTF-8"));
145
if (mIndent == eNotSet)
148
if (mMediaType.IsEmpty())
149
mMediaType.Append(NS_LITERAL_STRING("text/html"));
155
if (mEncoding.IsEmpty())
156
mEncoding.Append(NS_LITERAL_STRING("UTF-8"));
158
if (mMediaType.IsEmpty())
159
mMediaType.Append(NS_LITERAL_STRING("text/plain"));