10 #include <xercesc/sax2/SAX2XMLReader.hpp>
11 #include <xercesc/util/XMLException.hpp>
15 #include "IException.h"
19 #include "IsisXMLHandler.h"
20 #include "IsisXMLChTrans.h"
24 namespace XERCES = XERCES_CPP_NAMESPACE;
29 IsisXMLHandler::IsisXMLHandler() {
35 IsisXMLHandler::IsisXMLHandler(
char *PencodingName,
36 bool &PexpandNamespaces,
37 XERCES::SAX2XMLReader* &Pparser,
40 encodingName = PencodingName;
41 expandNamespaces = PexpandNamespaces;
47 prevDocHandler = parser->getContentHandler();
48 prevErrorHandler = parser->getErrorHandler();
50 parser->setContentHandler(
this);
51 parser->setErrorHandler(
this);
55 IsisXMLHandler::IsisXMLHandler(
char *PencodingName,
56 bool &PexpandNamespaces,
57 XERCES::SAX2XMLReader* &Pparser) {
62 encodingName = PencodingName;
63 expandNamespaces = PexpandNamespaces;
66 prevDocHandler = parser->getContentHandler();
67 prevErrorHandler = parser->getErrorHandler();
69 parser->setContentHandler(
this);
70 parser->setErrorHandler(
this);
74 IsisXMLHandler::~IsisXMLHandler() {}
78 void IsisXMLHandler::error(
const XERCES::SAXParseException &e) {
80 os <<
"Error in application XML file line: " << e.getLineNumber()
81 <<
" char: " << e.getColumnNumber() <<
". "
82 << XERCES::XMLString::transcode(e.getMessage());
86 void IsisXMLHandler::fatalError(
const XERCES::SAXParseException &e) {
88 os <<
"Error in application XML file line: " << e.getLineNumber()
89 <<
" char: " << e.getColumnNumber() <<
". "
90 << XERCES::XMLString::transcode(e.getMessage());
94 void IsisXMLHandler::warning(
const XERCES::SAXParseException &e) {
96 os <<
"Error in application XML file line: " << e.getLineNumber()
97 <<
" char: " << e.getColumnNumber() <<
". "
98 << XERCES::XMLString::transcode(e.getMessage());
104 void IsisXMLHandler::characters(
const XMLCh *
const chars,
105 const XMLSize_t length) {
109 str = XERCES::XMLString::transcode(chars);
116 void IsisXMLHandler::endDocument() {
120 void IsisXMLHandler::endElement(
const XMLCh *
const uri,
121 const XMLCh *
const localname,
122 const XMLCh *
const qname) {
124 if(outputEndTag > 0) {
126 str = XERCES::XMLString::transcode(localname);
127 *value +=
"</" + str +
">";
131 parser->setContentHandler(prevDocHandler);
132 parser->setErrorHandler(prevErrorHandler);
137 void IsisXMLHandler::ignorableWhitespace(
const XMLCh *
const chars,
138 const unsigned int length) {
142 void IsisXMLHandler::processingInstruction(
const XMLCh *
const target,
143 const XMLCh *
const data) {
147 void IsisXMLHandler::startDocument() {
151 void IsisXMLHandler::startElement(
const XMLCh *
const uri,
152 const XMLCh *
const localname,
153 const XMLCh *
const qname,
154 const XERCES::Attributes &attributes) {
158 str = XERCES::XMLString::transcode(localname);
160 *value +=
"<" + str +
">";