/*
Convert evaluated attribute value into a String.
426971
String convertToString(Object value) {
        if (value == null) {
            return null;
        } else if (value instanceof String) {
            return (String) value;
        } else if (value instanceof List) {
            List<?> list = ((List<?>) value);
            if (list.size() == 0) {
                return EvaluationContext.EMPTY_STRING;
            } else if (list.size() == 1) {
                String strValue = String.valueOf(list.get(0));
                return escapeValue(strValue);
            } else {
                StringBuilder builder = new StringBuilder();
                Iterator<?> iterator = list.iterator();
                while (iterator.hasNext()) {
                    String strValue = String.valueOf(iterator.next());
                    strValue = escapeValue(strValue);
                    builder.append(strValue);
                    if (iterator.hasNext()) {
                        builder.append(", ");
                    }
                }
                return builder.toString();
            }
        } else if (value instanceof String[]) {
            String[] array = (String[]) value;
            if (array.length == 0) {
                return EvaluationContext.EMPTY_STRING;
            } else if (array.length == 1) {
                return escapeValue(array[0]);
            } else {
                StringBuilder builder = new StringBuilder();
                for (int i = 0; i < array.length; i++) {
                    String strValue = escapeValue(array[i]);
                    builder.append(strValue);
                    if (i + 1 < array.length) {
                        builder.append(", ");
                    }
                }
                return builder.toString();
            }
        } else if (value.getClass().isArray()) {
            int size = Array.getLength(value);
            if (size == 0) {
                return EvaluationContext.EMPTY_STRING;
            } else if (size == 1) {
                String strValue = String.valueOf(Array.get(value, 0));
                return escapeValue(strValue);
            } else {
                StringBuilder builder = new StringBuilder();
                for (int i = 0; i < size; i++) {
                    String strValue = String.valueOf(Array.get(value, i));
                    strValue = escapeValue(strValue);
                    builder.append(strValue);
                    if (i + 1 < size) {
                        builder.append(", ");
                    }
                }
                return builder.toString();
            }
        } else {
            return value.toString();
        }
    }
684632
function normalizeAttrName(attrName) {
      if (!attrName) { return null }
      attrName = attrName.replace(ATTRS_PREFIX, '');
      if (CASE_SENSITIVE_ATTRIBUTES[attrName]) { attrName = CASE_SENSITIVE_ATTRIBUTES[attrName]; }
      return attrName
    }
397236
function attributesToString(obj, prevObj, level) {
            var attrs = '',
                prefix,
                tab;
            level = level || 1;
            tab = getTabs(level, true);
            _.forEach(obj, function (v, k) {
                if(excludeAttrs.indexOf(k) === -1){
                    var prev = prevObj && prevObj[k] !== undefined ? prevObj[k] : undefined;
                    prefix = attrs.length ? ',\n' : '';
                    if(_.isPlainObject(v)){
                        var subAttr = attributesToString(v, prev, level +1);
                        if(subAttr && subAttr.length)
                            attrs += (prefix + tab + k + ': {\n' + subAttr + '\n' + tab + '}');
                    } else {
                        if(prev !== v){
                            var val = k === 'type' ? 'types.' + v : v;
                            if(_.isArray(val))
                                val = arrayToString(val);
                            if(_.isFunction(val)){
                                val = funcToString(val.toString(), 2);
                            }
                            attrs += (prefix + tab + k + ': ' + val);
                        }
                    }
                }
            });

            return attrs;
        }
144202
function renderAttrs (attrs = {}) {
  const keys = Object.keys(attrs)
  if (keys.length) {
    return ' ' + keys.map(name => `${name}="${escape(attrs[name])}"`).join(' ')
  } else {
    return ''
  }
}
778345
@Nullable
  private static RawTextNode getAttributeValue(
      HtmlAttributeNode htmlAttributeNode, String name, ErrorReporter errorReporter) {
    StandaloneNode valueNode = htmlAttributeNode.getChild(1);
    if (valueNode instanceof HtmlAttributeValueNode) {
      HtmlAttributeValueNode attributeValueNode = (HtmlAttributeValueNode) valueNode;
      if (attributeValueNode.numChildren() == 1
          && attributeValueNode.getChild(0) instanceof RawTextNode) {
        return (RawTextNode) attributeValueNode.getChild(0);
      }
    }
    errorReporter.report(valueNode.getSourceLocation(), INVALID_ATTRIBUTE, name);
    return null;
  }
298377
def attribute_value(string)

      attribute_value = ''
      position = 0
      length = string.length

      while position < length
      
        # x09 (ASCII TAB), 0x0A (ASCII LF), 0x0C (ASCII FF), 0x0D (ASCII CR), or 0x20 (ASCII space) then advance position to the next byte, then, repeat this step.
        if string[position] =~ /[\u{09}\u{0A}\u{0C}\u{0D}\u{20}]/
            
          position += 1

        elsif string[position] =~ /['"]/

          attribute_value, position = quoted_value(string[position, length])
          break

        elsif string[position] == '>'
          position += 1
          break

        else
          attribute_value, position = unquoted_value(string[position, length])
          break
        end
      end

      [attribute_value, position]
    end
1116294
function parseAttributes(attrStr) {
    var reAttributes = /([^=<>\"\'\s]+)\s*(?:=\s*["']?([^"']*)["']?)?/g;
    var result = {};
    var match;

    if (attrStr) {
        while (match = reAttributes.exec(attrStr)) {
            result[match[1]] = match[2] || true;
        }
    }

    return result;
}
1353193
function (attr, expr, context, data) {
                var val = this.exprEvaluator(expr, context, data);
                if (val || typeof val === 'string' || typeof val === 'number') {
                    return " " + attr + '=' + this.generateAttribute(val + '');
                } else {
                    //else if undefined, null, false then don't render attribute.
                    return '';
                }
            }
703186
private BigInteger printExtendedAttributeDurationFormat(Object value)
   {
      BigInteger result = null;
      if (value instanceof Duration)
      {
         result = DatatypeConverter.printDurationTimeUnits(((Duration) value).getUnits(), false);
      }
      return (result);
   }
326570
function renderAttributeString(values, context) {
  if (typeof values === 'string' || typeof values === 'boolean') {
    return values;
  }

  var buffer = '';
  var toString = new ToString();
  for (var i = 0; i < values.length; i++) {
    toString.clear();
    render(toString, values[i], context);
    buffer += toString.getOutput();
  }

  return buffer;
}
652381
private void processAttributes(final String qName, final Attributes atts, final AttributesImpl res) {
        final int attsLen = atts.getLength();
        for (int i = 0; i < attsLen; i++) {
            final QName attQName = new QName(atts.getURI(i), atts.getLocalName(i));
            final String origValue = atts.getValue(i);
            String attValue = origValue;
            if (ATTRIBUTE_NAME_CONREF.equals(attQName.getLocalPart())) {
                attValue = replaceHREF(QName.valueOf(ATTRIBUTE_NAME_CONREF), atts).toString();
            } else if (ATTRIBUTE_NAME_HREF.equals(attQName.getLocalPart()) || ATTRIBUTE_NAME_COPY_TO.equals(attQName.getLocalPart())) {
                if (atts.getValue(ATTRIBUTE_NAME_SCOPE) == null ||
                        atts.getValue(ATTRIBUTE_NAME_SCOPE).equals(ATTR_SCOPE_VALUE_LOCAL)) {
                    attValue = replaceHREF(attQName, atts).toString();
                }
            } else if (ATTRIBUTE_NAME_FORMAT.equals(attQName.getLocalPart())) {
                final String format = atts.getValue(ATTRIBUTE_NAME_FORMAT);
                final String scope = atts.getValue(ATTRIBUTE_NAME_SCOPE);
                // verify format is correct
                if (isFormatDita(format) && (scope == null || scope.equals(ATTR_SCOPE_VALUE_LOCAL))) {
                    attValue = ATTR_FORMAT_VALUE_DITA;
                    if (!format.equals(ATTR_FORMAT_VALUE_DITA)) {
                        XMLUtils.addOrSetAttribute(res, DITA_OT_NS, ATTRIBUTE_NAME_ORIG_FORMAT, DITA_OT_NS_PREFIX + ":" + ATTRIBUTE_NAME_ORIG_FORMAT, "CDATA", format);
                    }
                }
            } else {
                attValue = getAttributeValue(qName, attQName, attValue);
            }
            XMLUtils.addOrSetAttribute(res, atts.getURI(i), atts.getLocalName(i), atts.getQName(i), atts.getType(i), attValue);
        }
    }
1236368
private void renderAttribute(InternalStringBuilder buf, String name, String value)
    {
        assert (name != null);
        if (value == null)
            return;

        buf.append(" ");
        buf.append(name);
        buf.append("=\"");
        buf.append(value);
        buf.append("\"");
    }
522430
def GetAttributeValuesString(self):
    
    attributes = []
    for attribute_name, attribute_value in sorted(self.__dict__.items()):
      # Not using startswith to improve performance.
      if attribute_name[0] == '_' or attribute_value is None:
        continue

      if isinstance(attribute_value, dict):
        attribute_value = sorted(attribute_value.items())

      elif isinstance(attribute_value, py2to3.BYTES_TYPE):
        attribute_value = repr(attribute_value)

      attribute_string = '{0:s}: {1!s}'.format(attribute_name, attribute_value)
      attributes.append(attribute_string)

    return ', '.join(attributes)
1147684
private Object evaluateString(String strVal, ExtendedAttributeDefinition attrDef, EvaluationContext context) throws ConfigEvaluatorException {
        if (attrDef == null) {
            return strVal;
        }

        int type = attrDef.getType();
        if (type == AttributeDefinition.BOOLEAN) {
            return Boolean.valueOf(strVal);
        } else if (type == AttributeDefinition.BYTE) {
            return Byte.valueOf(strVal);
        } else if (type == AttributeDefinition.CHARACTER) {
            return Character.valueOf(strVal.charAt(0));
        } else if (type == AttributeDefinition.DOUBLE) {
            return Double.valueOf(strVal);
        } else if (type == AttributeDefinition.FLOAT) {
            return Float.valueOf(strVal);
        } else if (type == AttributeDefinition.INTEGER) {
            return Integer.valueOf(strVal);
        } else if (type == AttributeDefinition.LONG) {
            return Long.valueOf(strVal);
        } else if (type == AttributeDefinition.SHORT) {
            return Short.valueOf(strVal);
        } else if (type == MetaTypeFactory.DURATION_TYPE) {
            return MetatypeUtils.evaluateDuration(strVal, TimeUnit.MILLISECONDS);
        } else if (type == MetaTypeFactory.DURATION_S_TYPE) {
            return MetatypeUtils.evaluateDuration(strVal, TimeUnit.SECONDS);
        } else if (type == MetaTypeFactory.DURATION_M_TYPE) {
            return MetatypeUtils.evaluateDuration(strVal, TimeUnit.MINUTES);
        } else if (type == MetaTypeFactory.DURATION_H_TYPE) {
            return MetatypeUtils.evaluateDuration(strVal, TimeUnit.HOURS);
        } else if (type == MetaTypeFactory.PASSWORD_TYPE || type == MetaTypeFactory.HASHED_PASSWORD_TYPE) {
            return new SerializableProtectedString(strVal.toCharArray());
        } else if (type == MetaTypeFactory.ON_ERROR_TYPE) {
            return Enum.valueOf(OnError.class, strVal.trim().toUpperCase());
        } else if (type == MetaTypeFactory.TOKEN_TYPE) {
            return MetatypeUtils.evaluateToken(strVal);
        } else if (type == MetaTypeFactory.PID_TYPE) {
            return evaluateReference(strVal, attrDef, context);
        } else {
            // STRING and all other unknown/invalid types.
            return strVal;
        }
    }
1305683
public static String attributeValue(
        String valueIn,
        boolean encode,
        Class expectedType,
        JspConfiguration jspConfig,
        boolean isTagFile,
        String pageContextVar) {
        String value = valueIn;
        value = value.replaceAll("&gt;", ">");
        value = value.replaceAll("&lt;", "<");
        value = value.replaceAll("&amp;", "&");
        value = value.replaceAll("<\\%", "<%");
        value = value.replaceAll("%\\>", "%>");
		if(com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable(Level.FINEST)){
			logger.logp(Level.FINEST, CLASS_NAME, "attributeValue","valueIn = ["+valueIn+"]");
			logger.logp(Level.FINEST, CLASS_NAME, "attributeValue","encode = ["+encode+"]");
			logger.logp(Level.FINEST, CLASS_NAME, "attributeValue","expectedType = ["+expectedType+"]");
			logger.logp(Level.FINEST, CLASS_NAME, "attributeValue","isTagFile = ["+isTagFile+"]");
		}
        if (JspTranslatorUtil.isExpression(value)) {
            value = value.substring(2, value.length() - 1);
            if (encode) {
                value = "org.apache.jasper.runtime.JspRuntimeLibrary.URLEncode(String.valueOf(" + 
                value + 
                "), request.getCharacterEncoding())";//PK03712
            }
    		if(com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable(Level.FINEST)){
    			logger.logp(Level.FINEST, CLASS_NAME, "attributeValue","isExpression. value = ["+value+"]");
    		}
        }
        else if (JspTranslatorUtil.isELInterpreterInput(value, jspConfig)) {
        	if(encode){
                //PK65013 - add pageContextVar parameter
        	    value = "org.apache.jasper.runtime.JspRuntimeLibrary.URLEncode(" + 
        	            interpreterCall(isTagFile, value, expectedType, "_jspx_fnmap", false, pageContextVar) + 
						", request.getCharacterEncoding())";
        	}
        	else{
                //PK65013 - add pageContextVar parameter
                value = interpreterCall(isTagFile, value, expectedType, "_jspx_fnmap", false, pageContextVar);
        	}
    		if(com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable(Level.FINEST)){
    			logger.logp(Level.FINEST, CLASS_NAME, "attributeValue","isELInterpreterInput. value = ["+value+"]");
    		}
        }
        else {
            if (encode) {
                value = "org.apache.jasper.runtime.JspRuntimeLibrary.URLEncode("
                        + quote(value)
                        + ", request.getCharacterEncoding())";
            }
            else {
                value = quote(value);
            }
    		if(com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable(Level.FINEST)){
    			logger.logp(Level.FINEST, CLASS_NAME, "attributeValue","default. value = ["+value+"]");
    		}
        }

        return (value);
    }
976009
public String getStr(String attr) {
		// return (String)attrs.get(attr);
		Object s = attrs.get(attr);
		return s != null ? s.toString() : null;
	}
702251
private String getFinalValueAsString(String attributeName, String str) {
        int value = Integer.parseInt(str);
        switch (attributeName) {
            case "screenOrientation":
                return AttributeValues.getScreenOrientation(value);
            case "configChanges":
                return AttributeValues.getConfigChanges(value);
            case "windowSoftInputMode":
                return AttributeValues.getWindowSoftInputMode(value);
            case "launchMode":
                return AttributeValues.getLaunchMode(value);
            case "installLocation":
                return AttributeValues.getInstallLocation(value);
            case "protectionLevel":
                return AttributeValues.getProtectionLevel(value);
            default:
                return str;
        }
    }