# HG changeset patch # User Nicholas Jillings # Date 1458312750 0 # Node ID 3600fff74af9ff75f2c021ea7848381901890362 # Parent 4fb8222b96ae1117fc857ab446947d0570d61f9f Fixed errors caused by specifcation nesting, specifically if interface nodes have nodes. diff -r 4fb8222b96ae -r 3600fff74af9 core.js --- a/core.js Wed Mar 16 16:52:30 2016 +0000 +++ b/core.js Fri Mar 18 14:52:30 2016 +0000 @@ -1812,13 +1812,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 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) { @@ -1864,9 +1864,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": @@ -1966,6 +1966,7 @@ this.surveyNode = function() { this.location = null; this.options = []; + this.parent = null; this.schema = specification.schema.getAllElementsByName('survey')[0]; this.OptionNode = function() { @@ -1988,7 +1989,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": @@ -2058,6 +2059,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';} @@ -2107,7 +2109,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": @@ -2201,15 +2207,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 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