~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/extensions/transformiix/source/xslt/txXMLOutput.h

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
4
 *
 
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/
 
9
 *
 
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
 
13
 * License.
 
14
 *
 
15
 * The Original Code is the TransforMiiX XSLT processor.
 
16
 *
 
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.
 
21
 *
 
22
 * Contributor(s):
 
23
 *   Peter Van der Beken <peterv@netscape.com>
 
24
 *
 
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.
 
36
 *
 
37
 * ***** END LICENSE BLOCK ***** */
 
38
 
 
39
#ifndef TRANSFRMX_XML_OUTPUT_H
 
40
#define TRANSFRMX_XML_OUTPUT_H
 
41
 
 
42
#include "txXMLEventHandler.h"
 
43
#include "List.h"
 
44
#include "txStack.h"
 
45
#include "txOutputFormat.h"
 
46
#include "XMLUtils.h"
 
47
 
 
48
#define DASH            '-'
 
49
#define TX_CR           '\r'
 
50
#define TX_LF           '\n'
 
51
 
 
52
#define AMPERSAND       '&'
 
53
#define APOSTROPHE      '\''
 
54
#define GT              '>'
 
55
#define LT              '<'
 
56
#define QUOTE           '"'
 
57
 
 
58
#define AMP_ENTITY      "&amp;"
 
59
#define APOS_ENTITY     "&apos;"
 
60
#define GT_ENTITY       "&gt;"
 
61
#define LT_ENTITY       "&lt;"
 
62
#define QUOT_ENTITY     "&quot;"
 
63
#define HEX_ENTITY      "&#"
 
64
 
 
65
#define CDATA_END       "]]>"
 
66
#define CDATA_START     "<![CDATA["
 
67
#define COMMENT_START   "<!--"
 
68
#define COMMENT_END     "-->"
 
69
#define DOCTYPE_START   "<!DOCTYPE "
 
70
#define DOCTYPE_END     ">"
 
71
#define DOUBLE_QUOTE    "\""
 
72
#define EQUALS          "="
 
73
#define FORWARD_SLASH   "/"
 
74
#define L_ANGLE_BRACKET "<"
 
75
#define PI_START        "<?"
 
76
#define PI_END          "?>"
 
77
#define PUBLIC          "PUBLIC"
 
78
#define R_ANGLE_BRACKET ">"
 
79
#define SEMICOLON       ";"
 
80
#define SPACE           " "
 
81
#define SYSTEM          "SYSTEM"
 
82
#define XML_DECL        "xml version="
 
83
#define XML_VERSION     "1.0"
 
84
 
 
85
class txOutAttr {
 
86
public:
 
87
    txOutAttr(PRInt32 aNsID, nsIAtom* aLocalName, const nsAString& aValue);
 
88
    txExpandedName mName;
 
89
    nsString mValue;
 
90
    MBool mShorthand;
 
91
};
 
92
 
 
93
class txXMLOutput : public txAOutputXMLEventHandler
 
94
{
 
95
public:
 
96
    txXMLOutput(txOutputFormat* aFormat, ostream* aOut);
 
97
    virtual ~txXMLOutput();
 
98
 
 
99
    static const int DEFAULT_INDENT;
 
100
 
 
101
    TX_DECL_TXAXMLEVENTHANDLER
 
102
    TX_DECL_TXAOUTPUTXMLEVENTHANDLER
 
103
 
 
104
protected:
 
105
    virtual void closeStartTag(MBool aUseEmptyElementShorthand);
 
106
    void printUTF8Char(PRUnichar& ch);
 
107
    void printUTF8Chars(const nsAString& aData);
 
108
    void printWithXMLEntities(const nsAString& aData,
 
109
                              MBool aAttribute = MB_FALSE);
 
110
 
 
111
    ostream* mOut;
 
112
    txOutputFormat mOutputFormat;
 
113
    MBool mUseEmptyElementShorthand;
 
114
    MBool mHaveDocumentElement;
 
115
    MBool mStartTagOpen;
 
116
    MBool mAfterEndTag;
 
117
    MBool mInCDATASection;
 
118
    PRUint32 mIndentLevel;
 
119
    txList mAttributes;
 
120
    txStack mCDATASections;
 
121
 
 
122
private:
 
123
    PRUnichar mBuffer[4];
 
124
};
 
125
 
 
126
#endif