private List getTagAttributes()

in src/main/java/org/apache/sling/xss/impl/xml/MapBuilder.java [179:218]


    private List<Attribute> getTagAttributes(List<Attribute> attributeList, String tagName)
            throws InvalidConfigException {
        List<Attribute> tagAttributes = new ArrayList<>();

        for (Attribute attribute : attributeList) {
            Attribute newAttribute;
            String attributeName = attribute.getName();
            List<Regexp> regexps = attribute.getRegexpList();
            List<Literal> literals = attribute.getLiteralList();
            String onInvalid = attribute.getOnInvalid();
            String description = attribute.getDescription();

            // attribute has no children
            if (regexps.isEmpty() && literals.isEmpty()) {
                Attribute commonAttribute = policy.commonAttributes.get(attributeName);
                if (commonAttribute != null) {
                    // creates a new Attribute with the fetched Attribute's information if not
                    // available
                    newAttribute = new Attribute(
                            attributeName,
                            !regexps.isEmpty() ? regexps : commonAttribute.getRegexpList(),
                            !literals.isEmpty() ? literals : commonAttribute.getLiteralList(),
                            !onInvalid.isEmpty() ? onInvalid : commonAttribute.getOnInvalid(),
                            !description.isEmpty() ? description : commonAttribute.getDescription());
                } else {
                    throw new InvalidConfigException(
                            "Attribute '" + attributeName + "' was referenced as a common attribute in definition of '"
                                    + tagName + "', but does not exist in <common-attributes>");
                }
            } else {
                List<Regexp> commonAllowedRegexps = getAllowedRegexps(regexps);
                List<Literal> allowedValues = attribute.getLiteralList();
                newAttribute =
                        new Attribute(attributeName, commonAllowedRegexps, allowedValues, onInvalid, description);
            }
            // Add fully built attribute.
            tagAttributes.add(newAttribute);
        }
        return tagAttributes;
    }