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