Skip to content

Commit

Permalink
Duplicates check for schema query
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew MacDonald committed Mar 30, 2015
1 parent 8e92c4f commit e78274b
Showing 1 changed file with 53 additions and 42 deletions.
95 changes: 53 additions & 42 deletions src/js/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,56 +650,67 @@ return function(writer) {
return;
}

var childObj = {
name: child['@name'],
level: level+0,
documentation: docs
};
var duplicate = false;
children.every(function(entry, index, array) {
if (entry.name === child['@name']) {
duplicate = true;
return false;
}
return true;
});

if (type == 'attribute') {
if (refParentProps && refParentProps.optional != null) {
childObj.required = !refParentProps.optional;
} else {
childObj.required = true;
_queryUp(child['$parent'], function(item) {
if (item.optional) {
childObj.required = false;
if (!duplicate) {
var childObj = {
name: child['@name'],
level: level+0,
documentation: docs
};

if (type == 'attribute') {
if (refParentProps && refParentProps.optional != null) {
childObj.required = !refParentProps.optional;
} else {
childObj.required = true;
_queryUp(child['$parent'], function(item) {
if (item.optional) {
childObj.required = false;
return false;
}
});
}

var defaultVal = null;
_queryDown(child, function(item) {
if (item['@a:defaultValue']) {
defaultVal = item['@a:defaultValue'];
return false;
}
});
}

var defaultVal = null;
_queryDown(child, function(item) {
if (item['@a:defaultValue']) {
defaultVal = item['@a:defaultValue'];
return false;
}
});
childObj.defaultValue = defaultVal || '';

var choice = null;
_queryDown(child, function(item) {
if (item.choice) {
choice = item.choice;
return false;
}
});
if (choice != null) {
var choices = [];
var values = [];
_queryDown(choice, function(item) {
if (item.value) {
values = item.value;
childObj.defaultValue = defaultVal || '';

var choice = null;
_queryDown(child, function(item) {
if (item.choice) {
choice = item.choice;
return false;
}
});
for (var j = 0; j < values.length; j++) {
choices.push(values[j]);
if (choice != null) {
var choices = [];
var values = [];
_queryDown(choice, function(item) {
if (item.value) {
values = item.value;
}
});
for (var j = 0; j < values.length; j++) {
choices.push(values[j]);
}
childObj.choices = choices;
}
childObj.choices = choices;
}
children.push(childObj);
}
children.push(childObj);
}

// now process the references
Expand Down Expand Up @@ -950,7 +961,7 @@ return function(writer) {
return checkForText(def, defHits, level+1, canContainText);
}
});
};
}

/**
* Checks to see if the tag can contain text, as specified in the schema
Expand Down

0 comments on commit e78274b

Please sign in to comment.