40 *
writer <<
"<?xml version=\"" << version.c_str() <<
"\" ";
46 *
writer <<
"standalone=\"yes\" ";
55 cerr <<
"XMLWriter::ReferToDTD cannot be called twice" << endl;
58 *
writer <<
"<!DOCTYPE " << name.c_str() <<
" PUBLIC \"" << pid.c_str() <<
"\" \"" << ref.c_str() <<
"\">" << endl;
63 cerr <<
"XMLWriter::ReferToDTD cannot be called twice";
66 *
writer <<
"<!DOCTYPE " << name.c_str() <<
" SYSTEM \"" << system.c_str() <<
"\">" << endl;
71 if (!openTags.empty()) {
72 if (!force) cerr <<
"Not all tags were closed before closing XML document:" << endl;
73 while (!openTags.empty()) {
77 cerr <<
" </" << openTags.top().c_str() <<
">" << endl;
87 if (comment.find(
"--") != string::npos) {
88 cerr <<
"XMLWriter::printComment '--' sequence not allowed in comment" << endl;
108 if (openTags.empty() && dtdName.compare(
"") && dtdName.compare(name)) {
109 cerr <<
"XMLWriter::openTag(), First tag: '" << name <<
"' not equal to DTD id: '" << dtdName <<
"'" << endl;
111 *
writer <<
"<" << name.c_str();
119 if (openTags.empty()) {
121 cerr <<
"XMLWriter::closeTag(), No open tags" << endl;
123 string name = openTags.top();
126 *
writer <<
"</" << name.c_str() <<
">" << endl;
131 *
writer <<
"<" << name.c_str();
141 attributes[name] = value;
146 if (name ==
"value")
setAttribute(
"type", (std::string)
"Color");
151 if (name ==
"value")
setAttribute(
"type", (std::string)
"long");
156 if (name ==
"showlabel") {
160 if (name ==
"value")
setAttribute(
"type", (std::string)
"int");
166 if (name ==
"value")
setAttribute(
"type", (std::string)
"boolean");
171 if (name ==
"value")
setAttribute(
"type", (std::string)
"double");
176 int width = tagLength + 1;
177 bool extraIndent =
false;
178 for (map<string,string>::iterator i = attributes.begin(); i != attributes.end(); i++) {
179 string key = i->first;
182 int length = key.length() + value.length() + 3;
194 *
writer << key.c_str() <<
"=\"" << value.c_str() <<
"\"";
204 int len = s.length();
205 for (
int i = 0; i < len; i++) {
221 str.append(
""");
226 sprintf(
buffer,
"&#%ud", ch);
249 int len = s.length();
250 for (
int i = 0; i < len; i++) {
std::string toShowLabel()
std::string getAsString()
std::string getIndentString() const
void setIndentString(const std::string &indentString)
XMLWriter(std::ostream *out, std::string indentString=" ", std::string defaultNameSpace="")
void printComment(std::string comment)
void checkNameValid(std::string s)
void openTag(std::string name)
IndentPrintWriter * writer
void print(std::string text)
std::string normalize(std::string s)
std::string normalizeText(std::string s)
void openDoc(std::string version="1.0", std::string encoding="", bool standalone=false)
void closeDoc(bool force=false)
void referToDTD(std::string name, std::string pid, std::string ref)
void setAttribute(std::string name, char *value)
void printAttributes(int tagLength)
void printTag(std::string name)
void println(std::string text)
void printPlain(std::string text)