Search in sources :

Example 1 with Attribute

use of com.smartandroid.sa.tag.nodes.Attribute in project SmartAndroidSource by jaychou2012.

the class Cleaner method createSafeElement.

private ElementMeta createSafeElement(Element sourceEl) {
    String sourceTag = sourceEl.tagName();
    Attributes destAttrs = new Attributes();
    Element dest = new Element(Tag.valueOf(sourceTag), sourceEl.baseUri(), destAttrs);
    int numDiscarded = 0;
    Attributes sourceAttrs = sourceEl.attributes();
    for (Attribute sourceAttr : sourceAttrs) {
        if (whitelist.isSafeAttribute(sourceTag, sourceEl, sourceAttr))
            destAttrs.put(sourceAttr);
        else
            numDiscarded++;
    }
    Attributes enforcedAttrs = whitelist.getEnforcedAttributes(sourceTag);
    destAttrs.addAll(enforcedAttrs);
    return new ElementMeta(dest, numDiscarded);
}
Also used : Attribute(com.smartandroid.sa.tag.nodes.Attribute) Element(com.smartandroid.sa.tag.nodes.Element) Attributes(com.smartandroid.sa.tag.nodes.Attributes)

Aggregations

Attribute (com.smartandroid.sa.tag.nodes.Attribute)1 Attributes (com.smartandroid.sa.tag.nodes.Attributes)1 Element (com.smartandroid.sa.tag.nodes.Element)1