Check if a default attribute element has to be created and create one if necessary
763017
function (defaultTplAtt) {
    if (!this.children) {
      return;
    }

    // TODO memoize result at prototype level to avoid processing this multiple times
    var ct=this.getCptContentType(), loadCpts=true;

    if (ct==="ERROR") {
      loadCpts=false;
      log.error(this.info+" Component content cannot mix attribute elements with content elements");
    } else if (ct!=="ATTELT") {
      if (defaultTplAtt) {
        // ct is CONTENT or INDEFINITE - so we create a default attribute element
        var catt=new $CptAttElement(defaultTplAtt,0,0,0,this.children); // name, exps, attcfg, ehcfg, children

        // add this default cpt att element as unique child
        this.children=[catt];
      } else {
        // there is no defaultTplAtt
        loadCpts=false;
      }
    }

    if (loadCpts) {
      var ni, cn=this.children, sz=cn.length;
      if (!this.attEltNodes) {
        this.attEltNodes=[];
      }
      for (var i=0;sz>i;i++) {
        if (!cn[i].isEmptyTextNode) {
          ni=cn[i].createNodeInstance(this);
          ni.isCptContent=true;
          this.attEltNodes.push(ni);
          // attribute elements will automatically register through registerAttElement()
        }
      }
    }
  }
210117
def _init_optional_attrs(optional_attrs):
        """"""
        if optional_attrs is None:
            return None
        opts = OboOptionalAttrs.get_optional_attrs(optional_attrs)
        if opts:
            return OboOptionalAttrs(opts)
685280
def _required_attr(self, attr, key):
        """"""
        assert isinstance(attr, dict)
        if key not in attr:
            raise AttributeError("Required attribute {} not found.".format(key))
        return attr[key]
1151364
function(attrs, options) {
      if (!options.validate || !this.validate) return true;
      attrs = _.extend({}, this.attributes, attrs);
      var error = this.validationError = this.validate(attrs, options) || null;
      if (!error) return true;
      this.trigger('invalid', this, error, _.extend(options, {validationError: error}));
      return false;
    }
720807
public function doDefaultAttributes()
    {
        foreach ((array)$this->attribute as $name => $value) {
            if (array_key_exists($name, $this->data)) {
                $this->data[$name] = $value;
            }
        }
        return ($this->data) ? $this->data : false;
    }
520234
function(el, attr, ieAttr) {
        ieAttr = (ieAttr !== undefined) ? ieAttr : 2;
        var ret = '';
        if (el && el.getAttribute) {
            attr = Y.DOM.CUSTOM_ATTRIBUTES[attr] || attr;
            ret = el.getAttribute(attr, ieAttr);

            if (ret === null) {
                ret = ''; // per DOM spec
            }
        }
        return ret;
    }
825267
def getAttribute(self, attrName, defaultValue=None):
        '''
            
        '''

        if attrName in TAG_ITEM_BINARY_ATTRIBUTES:
            if attrName in self._attributes:
                attrVal = self._attributes[attrName]
                if not attrVal:
                    return True # Empty valued binary attribute

                return attrVal # optionally-valued binary attribute
            else:
                return False
        else:
            return self._attributes.get(attrName, defaultValue)
845892
def on_change(self, attr, *callbacks):
        ''' 

        '''
        if len(callbacks) == 0:
            raise ValueError("on_change takes an attribute name and one or more callbacks, got only one parameter")

        _callbacks = self._callbacks.setdefault(attr, [])
        for callback in callbacks:

            if callback in _callbacks:
                continue

            _check_callback(callback, ('attr', 'old', 'new'))

            _callbacks.append(callback)
1258115
def is_optional(attr):
    
    return isinstance(attr.validator, _OptionalValidator) or (attr.default is not None and attr.default is not NOTHING)
122652
private static void createAttribute(Map<String, List<XsdAttribute>> createdAttributes, XsdAttribute elementAttribute) {
        if (!createdAttributes.containsKey(elementAttribute.getName())){
            List<XsdAttribute> attributes = new ArrayList<>();

            attributes.add(elementAttribute);

            createdAttributes.put(elementAttribute.getName(), attributes);
        } else {
            List<XsdAttribute> attributes = createdAttributes.get(elementAttribute.getName());

            if (!attributes.contains(elementAttribute)){
                attributes.add(elementAttribute);
            }
        }
    }
28419
function handleSimpleAttribute() {
    SIMPLEATTR.lastIndex = nextchar-1;
    var matched = SIMPLEATTR.exec(chars);
    if (!matched) throw new Error("should never happen");
    var name = matched[1];
    if (!name) return false;
    var value = matched[2];
    var len = value.length;
    switch(value[0]) {
    case '"':
    case "'":
      value = value.substring(1, len-1);
      nextchar += (matched[0].length-1);
      tokenizer = after_attribute_value_quoted_state;
      break;
    default:
      tokenizer = before_attribute_name_state;
      nextchar += (matched[0].length-1);
      value = value.substring(0, len-1);
      break;
    }

    // Make sure there isn't already an attribute with this name
    // If there is, ignore this one.
    for(var i = 0; i < attributes.length; i++) {
      if (attributes[i][0] === name) return true;
    }

    attributes.push([name, value]);
    return true;
  }
950780
def required_attributes(element, *attributes):
    
    if not reduce(lambda still_valid, param: still_valid and param in element.attrib, attributes, True):
        raise NotValidXmlException(msg_err_missing_attributes(element.tag, *attributes))
1348343
function ensureDOMElement (input) {
  let domElement = null
  let tmp = null
  if (input instanceof Element) {
    return input
  } else if ('string' == typeof input) {
    tmp = document.createElement('div')
    tmp.innerHTML = input
    domElement = tmp.innerHTML.length ? tmp.children[0] : new Template(input)
  } else {
    domElement = document.createElement('div')
  }
  return domElement
}
40207
def startElement (self, name, attrs):
                '''
                '''
                func = getattr(self, 'start_' + name, None)
                if func:
                        func(attrs)
387963
def get_attr(item, name, default=None):
    '''  '''
    try:
        val = item[name]
    except (KeyError, TypeError):
        try:
            val = getattr(item, name)
        except AttributeError:
            val = default
    return val
233406
def _create_element(name, element_type, data, server=None):
    '''
    
    '''
    # Define property and id from name and properties + remove SaltStack parameters
    if 'properties' in data:
        data['property'] = ''
        for key, value in data['properties'].items():
            if not data['property']:
                data['property'] += '{0}={1}'.format(key, value.replace(':', '\\:'))
            else:
                data['property'] += ':{0}={1}'.format(key, value.replace(':', '\\:'))
        del data['properties']

    # Send request
    _api_post(element_type, _clean_data(data), server)
    return unquote(name)
1184770
def require_attribute(self, attribute: str, typ: Type = _Any) -> None:
        
        attr_nodes = [
            value_node for key_node, value_node in self.yaml_node.value
            if key_node.value == attribute
        ]
        if len(attr_nodes) == 0:
            raise RecognitionError(
                ('{}{}Missing required attribute {}').format(
                    self.yaml_node.start_mark, os.linesep, attribute))
        attr_node = attr_nodes[0]

        if typ != _Any:
            recognized_types, message = self.__recognizer.recognize(
                attr_node, cast(Type, typ))
            if len(recognized_types) == 0:
                raise RecognitionError(message)