use of org.w3c.dom.Attr in project kotlin by JetBrains.
the class ResourceVisitor method visitElement.
private void visitElement(@NonNull XmlContext context, @NonNull Element element) {
List<Detector.XmlScanner> elementChecks = mElementToCheck.get(element.getTagName());
if (elementChecks != null) {
assert elementChecks instanceof RandomAccess;
for (XmlScanner check : elementChecks) {
check.visitElement(context, element);
}
}
if (!mAllElementDetectors.isEmpty()) {
for (XmlScanner check : mAllElementDetectors) {
check.visitElement(context, element);
}
}
if (!mAttributeToCheck.isEmpty() || !mAllAttributeDetectors.isEmpty()) {
NamedNodeMap attributes = element.getAttributes();
for (int i = 0, n = attributes.getLength(); i < n; i++) {
Attr attribute = (Attr) attributes.item(i);
String name = attribute.getLocalName();
if (name == null) {
name = attribute.getName();
}
List<Detector.XmlScanner> list = mAttributeToCheck.get(name);
if (list != null) {
for (XmlScanner check : list) {
check.visitAttribute(context, attribute);
}
}
if (!mAllAttributeDetectors.isEmpty()) {
for (XmlScanner check : mAllAttributeDetectors) {
check.visitAttribute(context, attribute);
}
}
}
}
// Visit children
NodeList childNodes = element.getChildNodes();
for (int i = 0, n = childNodes.getLength(); i < n; i++) {
Node child = childNodes.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
visitElement(context, (Element) child);
}
}
// Post hooks
if (elementChecks != null) {
for (XmlScanner check : elementChecks) {
check.visitElementAfter(context, element);
}
}
if (!mAllElementDetectors.isEmpty()) {
for (XmlScanner check : mAllElementDetectors) {
check.visitElementAfter(context, element);
}
}
}
use of org.w3c.dom.Attr in project kotlin by JetBrains.
the class ApiDetector method checkElement.
/** Checks whether the given element is the given tag, and if so, whether it satisfied
* the minimum version that the given tag is supported in */
private void checkElement(@NonNull XmlContext context, @NonNull Element element, @NonNull String tag, int api, @Nullable String gradleVersion, @NonNull Issue issue) {
if (tag.equals(element.getTagName())) {
int minSdk = getMinSdk(context);
if (api > minSdk && api > context.getFolderVersion() && api > getLocalMinSdk(element) && !featureProvidedByGradle(context, gradleVersion)) {
Location location = context.getLocation(element);
// For the <drawable> tag we report it against the class= attribute
if ("drawable".equals(tag)) {
Attr attribute = element.getAttributeNode(ATTR_CLASS);
if (attribute == null) {
return;
}
location = context.getLocation(attribute);
tag = ATTR_CLASS;
}
String message;
if (issue == UNSUPPORTED) {
message = String.format("`<%1$s>` requires API level %2$d (current min is %3$d)", tag, api, minSdk);
if (gradleVersion != null) {
message += String.format(" or building with Android Gradle plugin %1$s or higher", gradleVersion);
} else if (tag.contains(".")) {
message = String.format("Custom drawables requires API level %1$d (current min is %2$d)", api, minSdk);
}
} else {
assert issue == UNUSED : issue;
message = String.format("`<%1$s>` is only used in API level %2$d and higher " + "(current min is %3$d)", tag, api, minSdk);
}
context.report(issue, element, location, message);
}
}
}
use of org.w3c.dom.Attr in project jangaroo-tools by CoreMedia.
the class ExmlToModelParser method fillModelAttributes.
private void fillModelAttributes(ExmlModel model, JsonObject jsonObject, Element componentNode, ConfigClass configClass) {
NamedNodeMap attributes = componentNode.getAttributes();
for (int i = 0; i < attributes.getLength(); i++) {
Attr attribute = (Attr) attributes.item(i);
String attributeName = attribute.getLocalName();
String attributeValue = attribute.getValue();
ConfigAttribute configAttribute = getCfgByName(configClass, attributeName);
jsonObject.set(attributeName, getAttributeValue(attributeValue, configAttribute == null ? null : configAttribute.getType()));
}
fillModelAttributesFromSubElements(model, jsonObject, componentNode, configClass);
}
use of org.w3c.dom.Attr in project OpenAM by OpenRock.
the class AMModuleProperties method getAttribute.
//end of walk
private String getAttribute(Node node, String name) {
NamedNodeMap nnm = node.getAttributes();
if (nnm != null) {
int len = nnm.getLength();
Attr attr;
for (int i = 0; i < len; i++) {
attr = (Attr) nnm.item(i);
if (attr.getNodeName().equals(name)) {
return attr.getNodeValue();
}
}
}
return null;
}
use of org.w3c.dom.Attr in project OpenClinica by OpenClinica.
the class OpenRosaServices method applyXformAttributes.
public String applyXformAttributes(String xform, NamedNodeMap attribs) throws Exception {
String defaultNamespace = null;
for (int i = 0; i < attribs.getLength(); i++) {
Attr attrib = (Attr) attribs.item(i);
if (attrib.getName().equals("xmlns"))
defaultNamespace = attrib.getValue();
}
String[] xformArray = xform.split("html", 2);
String modifiedXform = xformArray[0] + "html xmlns=\"" + defaultNamespace + "\" " + xformArray[1];
return modifiedXform;
}
Aggregations