Isis 3 Programmer Reference
IsisXMLHelper.cpp
Go to the documentation of this file.
1 
25 #include <string>
26 
27 #include <xercesc/util/PlatformUtils.hpp>
28 #include <xercesc/sax2/SAX2XMLReader.hpp>
29 #include <xercesc/sax2/Attributes.hpp>
30 
31 #include "IsisXMLHelper.h"
32 #include "IsisXMLChTrans.h"
33 
34 #include "IString.h"
35 
36 using namespace std;
37 
38 namespace XERCES = XERCES_CPP_NAMESPACE;
39 
40 // Constructors
41 IsisXMLHelper::IsisXMLHelper(char *PencodingName,
42  bool &PexpandNamespaces,
43  XERCES::SAX2XMLReader* &Pparser,
44  IsisHelperData *Phelper) {
45 
46  encodingName = PencodingName;
47  expandNamespaces = PexpandNamespaces;
48  parser = Pparser;
49  helper = Phelper;
50 
51  prevDocHandler = parser->getContentHandler();
52  prevErrorHandler = parser->getErrorHandler();
53 
54  parser->setContentHandler(this);
55  parser->setErrorHandler(this);
56 
57  ignoreHandler = NULL;
58  generalHandler = NULL;
59 }
60 
61 IsisXMLHelper::~IsisXMLHelper() {
62  if(ignoreHandler != NULL) delete ignoreHandler;
63  if(generalHandler != NULL) delete generalHandler;
64 }
65 
66 
67 // IsisXMLHelper: Overrides of the SAX DocumentHandler interface
68 void IsisXMLHelper::characters(const XMLCh *const chars,
69  const XMLSize_t length) {
70 }
71 
72 
73 void IsisXMLHelper::endElement(const XMLCh *const uri,
74  const XMLCh *const localname,
75  const XMLCh *const qname) {
76  parser->setContentHandler(prevDocHandler);
77  parser->setErrorHandler(prevErrorHandler);
78 }
79 
80 void IsisXMLHelper::startElement(const XMLCh *const uri,
81  const XMLCh *const localname,
82  const XMLCh *const qname,
83  const XERCES::Attributes &attributes) {
84 
85  if((string)XERCES::XMLString::transcode(localname) == (string)"brief") {
86  if(generalHandler != NULL) {
87  delete generalHandler;
88  generalHandler = NULL;
89  }
90  generalHandler = new IsisXMLHandler(encodingName, expandNamespaces,
91  parser, &helper->brief);
92  }
93  else if((string)XERCES::XMLString::transcode(localname) == (string)"description") {
94  if(generalHandler != NULL) {
95  delete generalHandler;
96  generalHandler = NULL;
97  }
98  generalHandler = new IsisXMLHandler(encodingName, expandNamespaces,
99  parser, &helper->description);
100  }
101  else if((string)XERCES::XMLString::transcode(localname) == (string)"function") {
102  if(generalHandler != NULL) {
103  delete generalHandler;
104  generalHandler = NULL;
105  }
106  generalHandler = new IsisXMLHandler(encodingName, expandNamespaces,
107  parser, &helper->function);
108  }
109  else if((string)XERCES::XMLString::transcode(localname) == (string)"icon") {
110  if(generalHandler != NULL) {
111  delete generalHandler;
112  generalHandler = NULL;
113  }
114  generalHandler = new IsisXMLHandler(encodingName, expandNamespaces,
115  parser, &helper->icon);
116  }
117  else {
118  if(ignoreHandler != NULL) {
119  delete ignoreHandler;
120  ignoreHandler = NULL;
121  }
122  ignoreHandler = new IsisXMLIgnore(encodingName, expandNamespaces, parser,
123  (string)XERCES::XMLString::transcode(localname));
124  }
125 }
Namespace for the standard library.