From 332df172745f5010be4a1bcc01706ce4afbc9555 Mon Sep 17 00:00:00 2001 From: andreuccio Date: Tue, 6 Oct 2015 16:59:14 -0400 Subject: [PATCH] Disallow attribute deletes if use=required --- src/xml_attribute.js | 9 +++++---- xsd/src/schema_processor.js | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/xml_attribute.js b/src/xml_attribute.js index 02f60a8..ab151e7 100644 --- a/src/xml_attribute.js +++ b/src/xml_attribute.js @@ -35,10 +35,11 @@ XMLAttribute.prototype.render = function (){ 'class' : attributeContainerClass }).data('xmlAttribute', this).appendTo(this.xmlElement.getAttributeContainer()); - var self = this; - var removeButton = document.createElement('a'); - removeButton.appendChild(document.createTextNode('(x) ')); - this.domNode[0].appendChild(removeButton); + if(this.objectType.use != 'required') { + var removeButton = document.createElement('a'); + removeButton.appendChild(document.createTextNode('(x) ')); + this.domNode[0].appendChild(removeButton); + } var label = document.createElement('label'); var prefix = this.editor.xmlState.namespaces.getNamespacePrefix(this.objectType.namespace); diff --git a/xsd/src/schema_processor.js b/xsd/src/schema_processor.js index 342000a..6a6cb86 100644 --- a/xsd/src/schema_processor.js +++ b/xsd/src/schema_processor.js @@ -245,6 +245,7 @@ SchemaProcessor.prototype.build_attribute = function(node, definition) { } else { // Build or retrieve the type definition var type = node.getAttribute("type"); + definition.use = node.getAttribute("use"); if (type == null) { var child = this.getChildren(node)[0]; if (child)