# HG changeset patch # User Nicholas Jillings # Date 1456152916 0 # Node ID 8424449cd11d15dfd1f2534cb5b4b041818e54f7 # Parent 6c05c36a34eaed99aa92f7e471e7b6ca66c51b52 Bug Fix #1611 : Generates valid XML from examples. diff -r 6c05c36a34ea -r 8424449cd11d core.js --- a/core.js Mon Feb 22 14:38:45 2016 +0000 +++ b/core.js Mon Feb 22 14:55:16 2016 +0000 @@ -1935,7 +1935,7 @@ this.exportXML = function(doc) { - var node = doc.createElement('surveyelement'); + var node = doc.createElement('surveyentry'); node.setAttribute('type',this.type); var statement = doc.createElement('statement'); statement.textContent = this.statement; @@ -1945,17 +1945,16 @@ case "statement": break; case "question": - node.id = this.id; - node.setAttribute("mandatory",this.mandatory); - node.setAttribute("boxsize",this.boxsize); - break; - case "number": - node.id = this.id; - node.setAttribute("mandatory",this.mandatory); - node.setAttribute("min", this.min); - node.setAttribute("max", this.max); - node.setAttribute("step", this.step); - break; + node.id = this.id; + if (this.mandatory != undefined) { node.setAttribute("mandatory",this.mandatory);} + if (this.boxsize != undefined) {node.setAttribute("boxsize",this.boxsize);} + break; + case "number": + node.id = this.id; + if (this.mandatory != undefined) { node.setAttribute("mandatory",this.mandatory);} + if (this.min != undefined) {node.setAttribute("min", this.min);} + if (this.max != undefined) {node.setAttribute("max", this.max);} + break; case "checkbox": case "radio": node.id = this.id; diff -r 6c05c36a34ea -r 8424449cd11d test_create/test_create.html --- a/test_create/test_create.html Mon Feb 22 14:38:45 2016 +0000 +++ b/test_create/test_create.html Mon Feb 22 14:55:16 2016 +0000 @@ -230,7 +230,7 @@ this.exportXML = function(doc) { - var node = doc.createElement('surveyelement'); + var node = doc.createElement('surveyentry'); node.setAttribute('type',this.type); var statement = doc.createElement('statement'); statement.textContent = this.statement; @@ -241,15 +241,14 @@ break; case "question": node.id = this.id; - node.setAttribute("mandatory",this.mandatory); - node.setAttribute("boxsize",this.boxsize); + if (this.mandatory != undefined) { node.setAttribute("mandatory",this.mandatory);} + if (this.boxsize != undefined) {node.setAttribute("boxsize",this.boxsize);} break; case "number": node.id = this.id; - node.setAttribute("mandatory",this.mandatory); - node.setAttribute("min", this.min); - node.setAttribute("max", this.max); - node.setAttribute("step", this.step); + if (this.mandatory != undefined) { node.setAttribute("mandatory",this.mandatory);} + if (this.min != undefined) {node.setAttribute("min", this.min);} + if (this.max != undefined) {node.setAttribute("max", this.max);} break; case "checkbox": case "radio":