ulxr_xmlparse.cpp

Go to the documentation of this file.
00001 /**************************************************************************
00002                ulxr_xmlparse.cpp  -  parse xml files
00003                              -------------------
00004     begin                : Thu Aug 26 2002
00005     copyright            : (C) 2002-2007 by Ewald Arnold
00006     email                : ulxmlrpcpp@ewald-arnold.de
00007 
00008     $Id: ulxr_xmlparse.cpp 1017 2007-07-22 15:20:24Z ewald-arnold $
00009 
00010  ***************************************************************************/
00011 
00012 /**************************************************************************
00013  *
00014  * This program is free software; you can redistribute it and/or modify
00015  * it under the terms of the GNU Lesser General Public License as
00016  * published by the Free Software Foundation; either version 2 of the License,
00017  * or (at your option) any later version.
00018  *
00019  * This program is distributed in the hope that it will be useful,
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  * GNU General Public License for more details.
00023  *
00024  * You should have received a copy of the GNU Lesser General Public License
00025  * along with this program; if not, write to the Free Software
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00027  *
00028  ***************************************************************************/
00029 
00030 #define ULXR_NEED_EXPORTS
00031 #include <ulxmlrpcpp/ulxmlrpcpp.h>
00032 
00033 #include <ulxmlrpcpp/ulxr_xmlparse.h>
00034 #include <ulxmlrpcpp/ulxr_except.h>
00035 
00036 
00037 namespace ulxr {
00038 
00039 
00040 ULXR_API_IMPL0 XmlParser::XmlParser()
00041   : ExpatWrapper()
00042 {
00043 }
00044 
00045 
00046 ULXR_API_IMPL(void) XmlParser::charData(const XML_Char *s, int len)
00047 {
00048   ULXR_TRACE(ULXR_PCHAR("XmlParser::charData(const XML_Char*, int)")
00049 /*             << ULXR_PCHAR("\n  len: ") << len
00050              << ULXR_PCHAR("\n  s: >>")
00051              << ULXR_GET_STRING(Cpp8BitString(s, len))
00052              << ULXR_PCHAR("<<")
00053 */
00054             );
00055   states.top()->appendCharData(s, len);
00056   ULXR_TRACE(ULXR_PCHAR("XmlParser::charData(const XML_Char*, int) finished"));
00057 }
00058 
00059 
00060 ULXR_API_IMPL(bool) XmlParser::testStartElement(const XML_Char *name, const XML_Char ** /*atts*/)
00061 {
00062   throw XmlException(NotWellformedError,
00063                   ulxr_i18n(ULXR_PCHAR("Problem while parsing xml structure")),
00064                   getCurrentLineNumber(),
00065                   ulxr_i18n(ULXR_PCHAR("unexpected opening tag: "))+ULXR_GET_STRING(name) );
00066 }
00067 
00068 
00069 ULXR_API_IMPL(bool) XmlParser::testEndElement(const XML_Char *name)
00070 {
00071   throw XmlException(NotWellformedError,
00072                   ulxr_i18n(ULXR_PCHAR("Problem while parsing xml structure")),
00073                   getCurrentLineNumber(),
00074                   ulxr_i18n(ULXR_PCHAR("unexpected closing tag: "))+ULXR_GET_STRING(name) );
00075 }
00076 
00077 
00078 ULXR_API_IMPL(void) XmlParser::assertEndElement(const char *current, const char *expected)
00079 {
00080   ULXR_TRACE(ULXR_PCHAR("XmlParser::assertEndElement(const char*, const char*): ")
00081              << ULXR_PCHAR("\n curr: ")
00082              << ULXR_GET_STRING(current)
00083              << ULXR_PCHAR(" exp: ")
00084              << ULXR_GET_STRING(expected)
00085              );
00086   if (0 != strcmp(current, expected))
00087     throw XmlException(NotWellformedError,
00088                        (CppString) ulxr_i18n(ULXR_PCHAR("Unexpected xml tag: ")) + ULXR_GET_STRING(current)
00089                        + ulxr_i18n(ULXR_PCHAR(", wanted: ")) + ULXR_GET_STRING(expected),
00090                        getCurrentLineNumber(),
00091                        ulxr_i18n(ULXR_PCHAR("Document not wellformed")));
00092 }
00093 
00094 
00095 }  // namespace ulxr
00096 
00097 
00098 
00099 
00100 
00101 
00102 
00103 
00104 
00105 
00106 
00107 
00108 

Generated on Sun Aug 19 20:08:58 2007 for ulxmlrpcpp by  doxygen 1.5.1