protected XMLObject newAttributeValue(final Object value, final String valueType, final QName elementName) {
        LOGGER.trace("Creating new attribute value XMLObject for value: [{}], value type: [{}], QName: [{}]", value, valueType, elementName);

        if (value instanceof final NameIDType instance) {
            LOGGER.trace(LOG_MESSAGE_ATTR_CREATED, value);
            instance.detach();
            return (XMLObject) value;
        }

        if (XSString.class.getSimpleName().equalsIgnoreCase(valueType)) {
            val builder = new XSStringBuilder();
            val attrValueObj = builder.buildObject(elementName, XSString.TYPE_NAME);
            attrValueObj.setValue(value.toString());
            LOGGER.trace(LOG_MESSAGE_ATTR_CREATED, attrValueObj);
            return attrValueObj;
        }

        if (XSURI.class.getSimpleName().equalsIgnoreCase(valueType)) {
            val builder = new XSURIBuilder();
            val attrValueObj = builder.buildObject(elementName, XSURI.TYPE_NAME);
            attrValueObj.setURI(value.toString());
            LOGGER.trace(LOG_MESSAGE_ATTR_CREATED, attrValueObj);
            return attrValueObj;
        }

        if (XSBoolean.class.getSimpleName().equalsIgnoreCase(valueType)) {
            val builder = new XSBooleanBuilder();
            val attrValueObj = builder.buildObject(elementName, XSBoolean.TYPE_NAME);
            attrValueObj.setValue(XSBooleanValue.valueOf(value.toString().toLowerCase(Locale.ENGLISH)));
            LOGGER.trace(LOG_MESSAGE_ATTR_CREATED, attrValueObj);
            return attrValueObj;
        }

        if (XSInteger.class.getSimpleName().equalsIgnoreCase(valueType)) {
            val builder = new XSIntegerBuilder();
            val attrValueObj = builder.buildObject(elementName, XSInteger.TYPE_NAME);
            attrValueObj.setValue(Integer.valueOf(value.toString()));
            LOGGER.trace(LOG_MESSAGE_ATTR_CREATED, attrValueObj);
            return attrValueObj;
        }

        if (XSDateTime.class.getSimpleName().equalsIgnoreCase(valueType)) {
            val builder = new XSDateTimeBuilder();
            val attrValueObj = builder.buildObject(elementName, XSDateTime.TYPE_NAME);
            attrValueObj.setValue(ZonedDateTime.parse(value.toString()).toInstant());
            LOGGER.trace(LOG_MESSAGE_ATTR_CREATED, attrValueObj);
            return attrValueObj;
        }

        if (XSBase64Binary.class.getSimpleName().equalsIgnoreCase(valueType)) {
            val builder = new XSBase64BinaryBuilder();
            val attrValueObj = builder.buildObject(elementName, XSBase64Binary.TYPE_NAME);
            attrValueObj.setValue(value.toString());
            LOGGER.trace(LOG_MESSAGE_ATTR_CREATED, attrValueObj);
            return attrValueObj;
        }

        if (XSObject.class.getSimpleName().equalsIgnoreCase(valueType)) {
            return FunctionUtils.doUnchecked(() -> {
                val builder = new XSAnyBuilder();
                val attrValueObj = builder.buildObject(elementName);
                attrValueObj.setTextContent(XML_OBJECT_MAPPER.writeValueAsString(value));
                LOGGER.trace(LOG_MESSAGE_ATTR_CREATED, attrValueObj);
                return attrValueObj;
            });
        }

        val builder = new XSAnyBuilder();
        val attrValueObj = builder.buildObject(elementName);
        attrValueObj.setTextContent(value.toString());
        LOGGER.trace(LOG_MESSAGE_ATTR_CREATED, attrValueObj);
        return attrValueObj;
    }
New attribute value.

@param value       the value
@param valueType   the value type
@param elementName the element name
@return the xS string
support/cas-server-support-saml-core-api/src/main/java/org/apereo/cas/support/saml/util/AbstractSamlObjectBuilder.java