private static String findOpenGraphNamespacePrefix(Element htmlTag) { String prefix = OpenGraphVocabulary.DEFAULT_PREFIX; if (htmlTag != null) { Attributes attributes = htmlTag.getAttributes(); int attributeCount = attributes.size(); for (int i = 0; i < attributeCount; i++) { Attribute attr = attributes.get(i); String value = attr.getValue(); String key = attr.getKey().toLowerCase().trim(); if (key.startsWith(XMLNS_PREFIX)) { if (value.equals(OpenGraphVocabulary.NAMESPACE)) { prefix = key.substring(XMLNS_PREFIX.length()); } } } } return prefix; }
private TemplateNode parseDomElement(Element elem) { DOMElement templateElem = new DOMElement(elem.getName()); templateElem.setLocation(new Location(elem.getBegin(), elem.getEnd())); for (int i = 0; i < elem.getAttributes().size(); ++i) { Attribute attr = elem.getAttributes().get(i); if (attr.getName().indexOf(':') > 0) { AttributeComponentBinding component = parseAttributeComponent(attr); if (component != null) { templateElem.getAttributeComponents().add(component); } } else { templateElem.setAttribute(attr.getName(), attr.getValue(), new Location(attr.getBegin(), attr.getEnd())); } } Set<String> vars = new HashSet<>(); for (AttributeComponentBinding attrComponent : templateElem.getAttributeComponents()) { for (ComponentVariableBinding var : attrComponent.getVariables()) { vars.add(var.getName()); pushVar(var.getName(), var.getValueType()); } } parseSegment(elem.getEnd(), templateElem.getChildNodes(), child -> true); for (String var : vars) { popVar(var); } return templateElem; }
private TemplateNode parseDomElement(Element elem) { DOMElement templateElem = new DOMElement(elem.getName()); templateElem.setLocation(new Location(elem.getBegin(), elem.getEnd())); for (int i = 0; i < elem.getAttributes().size(); ++i) { Attribute attr = elem.getAttributes().get(i); if (attr.getName().indexOf(':') > 0) { AttributeComponentBinding component = parseAttributeComponent(attr); if (component != null) { templateElem.getAttributeComponents().add(component); } } else { templateElem.setAttribute(attr.getName(), attr.getValue(), new Location(attr.getBegin(), attr.getEnd())); } } Set<String> vars = new HashSet<>(); for (AttributeComponentBinding attrComponent : templateElem.getAttributeComponents()) { for (ComponentVariableBinding var : attrComponent.getVariables()) { vars.add(var.getName()); pushVar(var.getName(), var.getValueType()); } } parseSegment(elem.getEnd(), templateElem.getChildNodes(), child -> true); for (String var : vars) { popVar(var); } return templateElem; }