Isis 3 Programmer Reference
IsisXMLGroup.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 "IsisXMLGroup.h"
31 #include "IsisXMLChTrans.h"
32 
33 #include "IString.h"
34 
35 using namespace std;
36 
37 namespace XERCES = XERCES_CPP_NAMESPACE;
38 
39 // Constructors
40 IsisXMLGroup::IsisXMLGroup(char *PencodingName,
41  bool &PexpandNamespaces,
42  XERCES::SAX2XMLReader* &Pparser,
43  IsisGroupData *Pgroup) {
44 
45  encodingName = PencodingName;
46  expandNamespaces = PexpandNamespaces;
47  parser = Pparser;
48  group = Pgroup;
49 
50  prevDocHandler = parser->getContentHandler();
51  prevErrorHandler = parser->getErrorHandler();
52 
53  parser->setContentHandler(this);
54  parser->setErrorHandler(this);
55 
56  parameterHandler = NULL;
57  ignoreHandler = NULL;
58 
59 }
60 
61 IsisXMLGroup::~IsisXMLGroup() {
62 
63  if(parameterHandler != NULL) delete parameterHandler;
64  if(ignoreHandler != NULL) delete ignoreHandler;
65 }
66 
67 
68 // IsisXMLGroup: Overrides of the SAX DocumentHandler interface
69 void IsisXMLGroup::characters(const XMLCh *const chars,
70  const XMLSize_t length) {
71 }
72 
73 
74 void IsisXMLGroup::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 IsisXMLGroup::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)"parameter") {
87  if(parameterHandler != NULL) {
88  delete parameterHandler;
89  parameterHandler = NULL;
90  }
91  unsigned int index = group->parameters.size();
92  group->parameters.resize(index + 1);
93  QString name = XERCES::XMLString::transcode(attributes.getValue((XMLSize_t)0));
94 // Taken out after PVL refactor name.UpCase();
95  group->parameters[index].name = name;
96  parameterHandler = new IsisXMLParameter(encodingName, expandNamespaces,
97  parser, &group->parameters[index]);
98  }
99  else {
100  if(ignoreHandler != NULL) {
101  delete ignoreHandler;
102  ignoreHandler = NULL;
103  }
104  ignoreHandler = new IsisXMLIgnore(encodingName, expandNamespaces, parser,
105  (string)XERCES::XMLString::transcode(localname));
106  }
107 }
Namespace for the standard library.