diff test_create/test_create.html @ 1257:3600fff74af9

Fixed errors caused by specifcation nesting, specifically if <page> interface nodes have <interfaceoption> nodes.
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Fri, 18 Mar 2016 14:52:30 +0000
parents 6dbb9c24d53e
children 2dd5f7071e3f
line wrap: on
line diff
--- a/test_create/test_create.html	Wed Mar 16 16:52:30 2016 +0000
+++ b/test_create/test_create.html	Fri Mar 18 14:52:30 2016 +0000
@@ -20,13 +20,13 @@
             this.errors = [];
             this.schema = null;
 
-            this.processAttribute = function(attribute,schema)
+            this.processAttribute = function(attribute,schema,schemaRoot)
             {
                 // attribute is the string returned from getAttribute on the XML
                 // schema is the <xs:attribute> node
                 if (schema.getAttribute('name') == undefined && schema.getAttribute('ref') != undefined)
                 {
-                    schema = this.schema.getAllElementsByName(schema.getAttribute('ref'))[0];
+                    schema = schemaRoot.getAllElementsByName(schema.getAttribute('ref'))[0];
                 }
                 var defaultOpt = schema.getAttribute('default');
                 if (attribute == null) {
@@ -72,9 +72,9 @@
                 for (var i in attributes)
                 {
                     if (isNaN(Number(i)) == true){break;}
-                    var attributeName = attributes[i].getAttribute('name');
+                    var attributeName = attributes[i].getAttribute('name') || attributes[i].getAttribute('ref');
                     var projectAttr = setupNode.getAttribute(attributeName);
-                    projectAttr = this.processAttribute(projectAttr,attributes[i]);
+                    projectAttr = this.processAttribute(projectAttr,attributes[i],this.schema);
                     switch(typeof projectAttr)
                     {
                     case "number":
@@ -174,6 +174,7 @@
             this.surveyNode = function() {
                 this.location = null;
                 this.options = [];
+                this.parent = null;
                 this.schema = specification.schema.getAllElementsByName('survey')[0];
 
                 this.OptionNode = function() {
@@ -196,7 +197,7 @@
                             if(isNaN(Number(i)) == true){break;}
                             var attributeName = attributeMap[i].getAttribute('name') || attributeMap[i].getAttribute('ref');
                             var projectAttr = child.getAttribute(attributeName);
-                            projectAttr = parent.processAttribute(projectAttr,attributeMap[i]);
+                            projectAttr = parent.processAttribute(projectAttr,attributeMap[i],parent.schema);
                             switch(typeof projectAttr)
                             {
                             case "number":
@@ -266,6 +267,7 @@
                     };
                 };
                 this.decode = function(parent,xml) {
+                    this.parent = parent;
                     this.location = xml.getAttribute('location');
                     if (this.location == 'before'){this.location = 'pre';}
                     else if (this.location == 'after'){this.location = 'post';}
@@ -315,7 +317,11 @@
                         {
                             var attributeName = attributeMap[j].getAttribute('name') || attributeMap[j].getAttribute('ref');
                             var projectAttr = ioNode.getAttribute(attributeName);
-                            projectAttr = parent.processAttribute(projectAttr,attributeMap[j]);
+                            if(parent.processAttribute) {
+                                parent.processAttribute(projectAttr, attributeMap[j], parent.schema)
+                            } else {
+                                parent.parent.processAttribute(projectAttr, attributeMap[j], parent.parent.schema)
+                            }
                             switch(typeof projectAttr)
                             {
                             case "number":
@@ -401,6 +407,7 @@
                 this.showElementComments = undefined;
                 this.outsideReference = null;
                 this.loudness = null;
+                this.label = null;
                 this.preTest = null;
                 this.postTest = null;
                 this.interfaces = [];
@@ -408,15 +415,17 @@
                 this.audioElements = [];
                 this.commentQuestions = [];
                 this.schema = specification.schema.getAllElementsByName("page")[0];
+                this.parent = null;
 
                 this.decode = function(parent,xml)
                 {
+                    this.parent = parent;
                     var attributeMap = this.schema.getAllElementsByTagName('xs:attribute');
                     for (var i=0; i<attributeMap.length; i++)
                     {
                         var attributeName = attributeMap[i].getAttribute('name') || attributeMap[i].getAttribute('ref');
                         var projectAttr = xml.getAttribute(attributeName);
-                        projectAttr = parent.processAttribute(projectAttr,attributeMap[i]);
+                        projectAttr = parent.processAttribute(projectAttr,attributeMap[i],parent.schema);
                         switch(typeof projectAttr)
                         {
                         case "number":
@@ -589,7 +598,7 @@
                         {
                             var attributeName = attributeMap[i].getAttribute('name') || attributeMap[i].getAttribute('ref');
                             var projectAttr = xml.getAttribute(attributeName);
-                            projectAttr = specification.processAttribute(projectAttr,attributeMap[i]);
+                            projectAttr = parent.parent.processAttribute(projectAttr,attributeMap[i],parent.parent.schema);
                             switch(typeof projectAttr)
                             {
                             case "number":