10 #include <xercesc/util/PlatformUtils.hpp>
11 #include <xercesc/sax2/SAX2XMLReader.hpp>
12 #include <xercesc/sax2/Attributes.hpp>
16 #include "IsisXMLParameter.h"
17 #include "IsisXMLChTrans.h"
23 IsisXMLParameter::IsisXMLParameter(
char *PencodingName,
24 bool &PexpandNamespaces,
25 XERCES::SAX2XMLReader* &Pparser,
28 encodingName = PencodingName;
29 expandNamespaces = PexpandNamespaces;
31 parameter = Pparameter;
33 prevDocHandler = parser->getContentHandler();
34 prevErrorHandler = parser->getErrorHandler();
36 parser->setContentHandler(
this);
37 parser->setErrorHandler(
this);
39 generalHandler = NULL;
40 multipleValuesHandler = NULL;
43 helpersHandler = NULL;
46 IsisXMLParameter::~IsisXMLParameter() {
47 if(generalHandler != NULL) {
48 delete generalHandler;
49 generalHandler = NULL;
51 if(multipleValuesHandler != NULL) {
52 delete multipleValuesHandler;
53 multipleValuesHandler = NULL;
55 if(ignoreHandler != NULL) {
59 if(listHandler != NULL) {
63 if(helpersHandler != NULL) {
64 delete helpersHandler;
65 helpersHandler = NULL;
71 void IsisXMLParameter::characters(
const XMLCh *
const chars,
72 const XMLSize_t length) {}
75 void IsisXMLParameter::endElement(
const XMLCh *
const uri,
76 const XMLCh *
const localname,
77 const XMLCh *
const qname) {
78 if((
string)XERCES::XMLString::transcode(localname) !=
"list") {
79 parser->setContentHandler(prevDocHandler);
80 parser->setErrorHandler(prevErrorHandler);
84 void IsisXMLParameter::startElement(
const XMLCh *
const uri,
85 const XMLCh *
const localname,
86 const XMLCh *
const qname,
87 const XERCES::Attributes &attributes) {
88 if((
string)XERCES::XMLString::transcode(localname) == (
string)
"type") {
89 if(generalHandler != NULL) {
90 delete generalHandler;
91 generalHandler = NULL;
93 generalHandler =
new IsisXMLHandler(encodingName, expandNamespaces,
94 parser, ¶meter->type);
96 else if((
string)XERCES::XMLString::transcode(localname) == (
string)
"brief") {
97 if(generalHandler != NULL) {
98 delete generalHandler;
99 generalHandler = NULL;
101 generalHandler =
new IsisXMLHandler(encodingName, expandNamespaces,
102 parser, ¶meter->brief);
104 else if((
string)XERCES::XMLString::transcode(localname) == (
string)
"description") {
105 if(generalHandler != NULL) {
106 delete generalHandler;
107 generalHandler = NULL;
109 generalHandler =
new IsisXMLHandler(encodingName, expandNamespaces,
110 parser, ¶meter->description);
112 else if((
string)XERCES::XMLString::transcode(localname) == (
string)
"default") {
113 if(multipleValuesHandler != NULL) {
114 delete multipleValuesHandler;
115 multipleValuesHandler = NULL;
118 parser, ¶meter->defaultValues);
120 else if((
string)XERCES::XMLString::transcode(localname) == (
string)
"internalDefault") {
121 if(generalHandler != NULL) {
122 delete generalHandler;
123 generalHandler = NULL;
125 generalHandler =
new IsisXMLHandler(encodingName, expandNamespaces, parser,
126 ¶meter->internalDefault);
128 else if((
string)XERCES::XMLString::transcode(localname) == (
string)
"count") {
129 if(generalHandler != NULL) {
130 delete generalHandler;
131 generalHandler = NULL;
133 generalHandler =
new IsisXMLHandler(encodingName, expandNamespaces, parser,
136 else if((
string)XERCES::XMLString::transcode(localname) == (
string)
"list") {
138 else if((
string)XERCES::XMLString::transcode(localname) == (
string)
"option") {
139 if(listHandler != NULL) {
143 unsigned int index = parameter->listOptions.size();
144 parameter->listOptions.resize(index + 1);
145 QString lo = XERCES::XMLString::transcode(attributes.getValue((XMLSize_t)0));
147 parameter->listOptions[index].value = lo;
148 listHandler =
new IsisXMLList(encodingName, expandNamespaces, parser,
149 ¶meter->listOptions[index]);
151 else if((
string)XERCES::XMLString::transcode(localname) == (
string)
"minimum") {
152 if(generalHandler != NULL) {
153 delete generalHandler;
154 generalHandler = NULL;
156 QString mi = XERCES::XMLString::transcode(attributes.getValue((XMLSize_t)0));
157 parameter->minimum_inclusive = mi.toLower();
158 generalHandler =
new IsisXMLHandler(encodingName, expandNamespaces,
159 parser, ¶meter->minimum);
161 else if((
string)XERCES::XMLString::transcode(localname) == (
string)
"maximum") {
162 if(generalHandler != NULL) {
163 delete generalHandler;
164 generalHandler = NULL;
166 QString mi = XERCES::XMLString::transcode(attributes.getValue((XMLSize_t)0));
167 parameter->maximum_inclusive = mi.toLower();
168 generalHandler =
new IsisXMLHandler(encodingName, expandNamespaces, parser,
169 ¶meter->maximum);
171 else if((
string)XERCES::XMLString::transcode(localname) == (
string)
"greaterThan") {
172 if(multipleValuesHandler != NULL) {
173 delete multipleValuesHandler;
174 multipleValuesHandler = NULL;
177 parser, ¶meter->greaterThan);
179 else if((
string)XERCES::XMLString::transcode(localname) == (
string)
"greaterThanOrEqual") {
180 if(multipleValuesHandler != NULL) {
181 delete multipleValuesHandler;
182 multipleValuesHandler = NULL;
185 parser, ¶meter->greaterThanOrEqual);
187 else if((
string)XERCES::XMLString::transcode(localname) == (
string)
"lessThan") {
188 if(multipleValuesHandler != NULL) {
189 delete multipleValuesHandler;
190 multipleValuesHandler = NULL;
193 parser, ¶meter->lessThan);
195 else if((
string)XERCES::XMLString::transcode(localname) == (
string)
"lessThanOrEqual") {
196 if(multipleValuesHandler != NULL) {
197 delete multipleValuesHandler;
198 multipleValuesHandler = NULL;
201 parser, ¶meter->lessThanOrEqual);
203 else if((
string)XERCES::XMLString::transcode(localname) == (
string)
"notEqual") {
204 if(multipleValuesHandler != NULL) {
205 delete multipleValuesHandler;
206 multipleValuesHandler = NULL;
209 parser, ¶meter->notEqual);
211 else if((
string)XERCES::XMLString::transcode(localname) == (
string)
"odd") {
212 if(generalHandler != NULL) {
213 delete generalHandler;
214 generalHandler = NULL;
216 parameter->odd =
"TRUE";
217 generalHandler =
new IsisXMLHandler(encodingName, expandNamespaces, parser);
220 else if((
string)XERCES::XMLString::transcode(localname) == (
string)
"exclusions") {
221 if(multipleValuesHandler != NULL) {
222 delete multipleValuesHandler;
223 multipleValuesHandler = NULL;
226 parser, ¶meter->exclude);
228 else if((
string)XERCES::XMLString::transcode(localname) == (
string)
"inclusions") {
229 if(multipleValuesHandler != NULL) {
230 delete multipleValuesHandler;
231 multipleValuesHandler = NULL;
234 parser, ¶meter->include);
236 else if((
string)XERCES::XMLString::transcode(localname) == (
string)
"filter") {
237 if(generalHandler != NULL) {
238 delete generalHandler;
239 generalHandler = NULL;
241 generalHandler =
new IsisXMLHandler(encodingName, expandNamespaces, parser, ¶meter->filter);
243 else if((
string)XERCES::XMLString::transcode(localname) == (
string)
"defaultPath") {
244 if(generalHandler != NULL) {
245 delete generalHandler;
246 generalHandler = NULL;
248 generalHandler =
new IsisXMLHandler(encodingName, expandNamespaces, parser,
251 else if((
string)XERCES::XMLString::transcode(localname) == (
string)
"fileMode") {
252 if(generalHandler != NULL) {
253 delete generalHandler;
254 generalHandler = NULL;
256 generalHandler =
new IsisXMLHandler(encodingName, expandNamespaces, parser, ¶meter->fileMode);
258 else if((
string)XERCES::XMLString::transcode(localname) == (
string)
"pixelType") {
259 if(generalHandler != NULL) {
260 delete generalHandler;
261 generalHandler = NULL;
263 generalHandler =
new IsisXMLHandler(encodingName, expandNamespaces, parser, ¶meter->pixelType);
265 else if((
string)XERCES::XMLString::transcode(localname) == (
string)
"helpers") {
266 if(helpersHandler != NULL) {
267 delete helpersHandler;
268 helpersHandler = NULL;
270 helpersHandler =
new IsisXMLHelpers(encodingName, expandNamespaces, parser,
271 ¶meter->helpers);
274 if(ignoreHandler != NULL) {
275 delete ignoreHandler;
276 ignoreHandler = NULL;
278 ignoreHandler =
new IsisXMLIgnore(encodingName, expandNamespaces, parser,
279 (
string)XERCES::XMLString::transcode(localname));