private Cleaner.ElementMeta CreateSafeElement(iText.StyledXmlParser.Jsoup.Nodes.Element sourceEl) { String sourceTag = sourceEl.TagName(); Attributes destAttrs = new Attributes(); iText.StyledXmlParser.Jsoup.Nodes.Element dest = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf(sourceTag), sourceEl.BaseUri(), destAttrs); int numDiscarded = 0; Attributes sourceAttrs = sourceEl.Attributes(); foreach (iText.StyledXmlParser.Jsoup.Nodes.Attribute sourceAttr in sourceAttrs) { if (whitelist.IsSafeAttribute(sourceTag, sourceEl, sourceAttr)) { destAttrs.Put(sourceAttr); } else { numDiscarded++; } } Attributes enforcedAttrs = whitelist.GetEnforcedAttributes(sourceTag); destAttrs.AddAll(enforcedAttrs); return(new Cleaner.ElementMeta(dest, numDiscarded)); }