comparison test_create/test_create.html @ 1203:1f352095179e

Bug Fix #1611 : Generates valid XML from examples.
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Mon, 22 Feb 2016 14:55:16 +0000
parents 47bfd9594617
children bcd5c032f196
comparison
equal deleted inserted replaced
1202:27be75c51b5c 1203:1f352095179e
228 } 228 }
229 }; 229 };
230 230
231 this.exportXML = function(doc) 231 this.exportXML = function(doc)
232 { 232 {
233 var node = doc.createElement('surveyelement'); 233 var node = doc.createElement('surveyentry');
234 node.setAttribute('type',this.type); 234 node.setAttribute('type',this.type);
235 var statement = doc.createElement('statement'); 235 var statement = doc.createElement('statement');
236 statement.textContent = this.statement; 236 statement.textContent = this.statement;
237 node.appendChild(statement); 237 node.appendChild(statement);
238 switch(this.type) 238 switch(this.type)
239 { 239 {
240 case "statement": 240 case "statement":
241 break; 241 break;
242 case "question": 242 case "question":
243 node.id = this.id; 243 node.id = this.id;
244 node.setAttribute("mandatory",this.mandatory); 244 if (this.mandatory != undefined) { node.setAttribute("mandatory",this.mandatory);}
245 node.setAttribute("boxsize",this.boxsize); 245 if (this.boxsize != undefined) {node.setAttribute("boxsize",this.boxsize);}
246 break; 246 break;
247 case "number": 247 case "number":
248 node.id = this.id; 248 node.id = this.id;
249 node.setAttribute("mandatory",this.mandatory); 249 if (this.mandatory != undefined) { node.setAttribute("mandatory",this.mandatory);}
250 node.setAttribute("min", this.min); 250 if (this.min != undefined) {node.setAttribute("min", this.min);}
251 node.setAttribute("max", this.max); 251 if (this.max != undefined) {node.setAttribute("max", this.max);}
252 node.setAttribute("step", this.step);
253 break; 252 break;
254 case "checkbox": 253 case "checkbox":
255 case "radio": 254 case "radio":
256 node.id = this.id; 255 node.id = this.id;
257 for (var i=0; i<this.options.length; i++) 256 for (var i=0; i<this.options.length; i++)