-rw-r--r-- | noncore/apps/tableviewer/db/xmlsource.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/noncore/apps/tableviewer/db/xmlsource.cpp b/noncore/apps/tableviewer/db/xmlsource.cpp index 7418a85..94fec36 100644 --- a/noncore/apps/tableviewer/db/xmlsource.cpp +++ b/noncore/apps/tableviewer/db/xmlsource.cpp @@ -1,121 +1,123 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "xmlsource.h" #include <qdict.h> #include <stdlib.h> #include <qtextstream.h> +#include "../xmlencodeattr.h" + DBXml::DBXml(DBStore *d) { dstore = d; } QString DBXml::type() { return "xml"; } bool DBXml::openSource(QIODevice *inDev) { bool ok; DBXmlHandler h(dstore); QTextStream tsIn(inDev); QXmlInputSource source(tsIn); QXmlSimpleReader reader; reader.setContentHandler(&h); reader.setErrorHandler(&h); ok = reader.parse(source); return ok; } bool DBXml::saveSource(QIODevice *outDev) { int i; DataElem *elem; KeyList *k; QTextStream outstream(outDev); outstream << "<database name=\"" << dstore->getName() << "\">" << endl; outstream << "<header>" << endl; k = dstore->getKeys(); KeyListIterator it(*k); while(it.current()) { if (!it.current()->delFlag()) { outstream << "<key name=\"KEYID" << it.currentKey() << "\" "; outstream << "type=\"" << TVVariant::typeToName(it.current()->type()) << "\">"; - outstream << it.current()->name() << "</key>" << endl; + outstream << encodeAttr(it.current()->name()) << "</key>" << endl; } ++it; } outstream << "</header>" << endl; dstore->first(); do { elem = dstore->getCurrentData(); if (!elem) break; outstream << "<record>" << endl; it.toFirst(); while (it.current()) { i = it.currentKey(); if (elem->hasValidValue(i)) { outstream << "<KEYID" << i << ">"; if (dstore->getKeyType(i) == TVVariant::Date) { // dates in files are different from displayed dates QDate date = elem->getField(i).toDate(); outstream << date.day() << "/" << date.month() << "/" << date.year(); } else { - outstream << elem->toQString(i); + outstream << encodeAttr(elem->toQString(i)); } outstream << "</KEYID" << i << ">" << endl; } ++it; } outstream << "</record>" << endl; } while(dstore->next()); outstream << "</database>" << endl; return TRUE; } DBXml::~DBXml() {} /*! \class DBXmlHandler \brief An Xml parser for flat tables. An xml parser for parsing the files used by the table viewer application. The format of the xml files can be found at the front of the file dataparser.h */ |