Refine search
public static String getAttribute(Element element, String name) { Attr attr = element.getAttributeNode(name); return (attr != null)? attr.getValue(): null; }
public String getAttribute(String name) { Attr attribute = currentElement.getAttributeNode(encodeAttribute(name)); return attribute == null ? null : attribute.getValue(); }
private void performVersioCodeAutoIncrement( Element manifestElement ) { Attr versionCode = manifestElement.getAttributeNode( ATTR_VERSION_CODE ); int currentVersionCode = 0; if ( versionCode != null ) { currentVersionCode = NumberUtils.toInt( versionCode.getValue(), 0 ); } currentVersionCode++; manifestElement.setAttribute( ATTR_VERSION_CODE, String.valueOf( currentVersionCode ) ); project.getProperties().setProperty( "android.manifest.versionCode", String.valueOf( currentVersionCode ) ); }
Attr att = elem.getAttributeNode(attName); value = att.getValue();
Attr att = elem.getAttributeNode(attName); value = att.getValue();
private boolean updateApplicationAttribute( Element manifestElement, String attribute, String value, boolean dirty ) { NodeList appElements = manifestElement.getElementsByTagName( ELEM_APPLICATION ); // Update all application nodes. Not sure whether there will ever be // more than one. for ( int i = 0; i < appElements.getLength(); ++i ) { Node node = appElements.item( i ); getLog().info( "Testing if node " + node.getNodeName() + " is application" ); if ( node.getNodeType() == Node.ELEMENT_NODE ) { Element element = (Element) node; Attr labelAttrib = element.getAttributeNode( attribute ); if ( labelAttrib == null || !value.equals( labelAttrib.getValue() ) ) { getLog().info( "Setting " + attribute + " to " + value ); element.setAttribute( attribute, String.valueOf( value ) ); dirty = true; } } } return dirty; }
if (n instanceof Element && n.getNodeName().contains("String")) { strings.add(((Element) n).getAttributeNode("value").getValue());
Attr providerName = providerElem.getAttributeNode( ATTR_NAME ); getLog().debug( "Checking provider " + providerName.getValue() ); if ( shouldPerformProviderUpdate( providerName ) ) String name = providerName.getValue(); String newAuthorities = parsedProviderAuthorities.getProperty( name ); getLog().info( "Updating provider " + name + " authorities attr to " + newAuthorities );
Element sharedPoolElement = (Element)item; String poolName = sharedPoolElement.getAttribute("name"); // required Attr fromAttr = sharedPoolElement.getAttributeNode("from"); // optional String fromResource = (fromAttr == null ? null : fromAttr.getValue()); Attr unitAttr = sharedPoolElement.getAttributeNode("unit"); // optional - default 'B' String unit = (unitAttr == null ? "B" : unitAttr.getValue()); MemoryUnit memoryUnit = MemoryUnit.valueOf(unit.toUpperCase(Locale.ENGLISH));
final Attr fromAttr = fragment.getAttributeNode("from"); final String from = (fromAttr == null ? null : fromAttr.getValue());
final Attr urlAttribute = ((Element)item).getAttributeNode("url"); final String urlValue = urlAttribute.getValue(); try { connectionUri = new URI(urlValue); for (int j = 0; j < serverNodes.getLength(); j++) { final Node serverNode = serverNodes.item(j); final String host = ((Element)serverNode).getAttributeNode("host").getValue(); final Attr port = ((Element)serverNode).getAttributeNode("port"); InetSocketAddress address; if (port == null) { address = InetSocketAddress.createUnresolved(host, 0); } else { String portString = port.getValue(); address = InetSocketAddress.createUnresolved(host, Integer.parseInt(portString));
Attr versionNameAttrib = manifestElement.getAttributeNode( ATTR_VERSION_NAME ); if ( versionNameAttrib == null || ! StringUtils.equals( parsedVersionName, versionNameAttrib.getValue() ) ) Attr versionCodeAttr = manifestElement.getAttributeNode( ATTR_VERSION_CODE ); int currentVersionCode = 0; if ( versionCodeAttr != null ) currentVersionCode = NumberUtils.toInt( versionCodeAttr.getValue(), 0 ); Attr sharedUserIdAttrib = manifestElement.getAttributeNode( ATTR_SHARED_USER_ID ); .equals( parsedSharedUserId, sharedUserIdAttrib.getValue() ) ) Attr debuggableAttrib = element.getAttributeNode( ATTR_DEBUGGABLE ); if ( debuggableAttrib == null || parsedDebuggable != BooleanUtils .toBoolean( debuggableAttrib.getValue() ) )
Node node = (Node) parser.getCurrent(); String attachedTo = element.getAttribute("attachedToRef"); Attr cancelActivityAttr = element.getAttributeNode("cancelActivity"); boolean cancelActivity = Boolean.parseBoolean(cancelActivityAttr.getValue());
Attr targetModeAttr = element.getAttributeNode(PackageRelationship.TARGET_MODE_ATTRIBUTE_NAME); TargetMode targetMode = TargetMode.INTERNAL; if (targetModeAttr != null) { targetMode = targetModeAttr.getValue().toLowerCase(Locale.ROOT) .equals("internal") ? TargetMode.INTERNAL : TargetMode.EXTERNAL;
/** * Ensures the namespace declared by {@link ClusteringCacheManagerServiceConfigurationParser} and its * schema are the same. */ @Test public void testSchema() throws Exception { final ClusteringCacheManagerServiceConfigurationParser parser = new ClusteringCacheManagerServiceConfigurationParser(); final StreamSource schemaSource = (StreamSource) parser.getXmlSchema(); final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); factory.setIgnoringComments(true); factory.setIgnoringElementContentWhitespace(true); final DocumentBuilder domBuilder = factory.newDocumentBuilder(); final Element schema = domBuilder.parse(schemaSource.getInputStream()).getDocumentElement(); final Attr targetNamespaceAttr = schema.getAttributeNode("targetNamespace"); assertThat(targetNamespaceAttr, is(not(nullValue()))); assertThat(targetNamespaceAttr.getValue(), is(parser.getNamespace().toString())); }
/** * This is used to get a Document's namespace attribute value. * */ public static String getNamespaceAttributeValue(Document doc) { Element el = doc.getDocumentElement(); String prefix = el.getPrefix(); Attr attr = (prefix == null) ? el.getAttributeNode(XMLNS) : el.getAttributeNode(XMLNS + ':' + prefix); return (attr == null) ? null : attr.getValue(); }
private static void renameNodeReference(List<Element> elements, String attributeName, String oldNodeName, String newNodeName) { for (Element c : elements) { Attr nodeRef = c.getAttributeNode(attributeName); String nodeName = nodeRef.getValue(); if (oldNodeName.equals(nodeName)) { nodeRef.setValue(newNodeName); } } }
/** * Returns the value of an attribute of an element. Returns null * if the attribute is not found (whereas Element.getAttribute * returns "" if an attrib is not found). This method should be * used for elements that support extension attributes because it * does not track unexpected attributes. * * @param el Element whose attrib is looked for * @param attrName name of attribute to look for * @return the attribute value */ static public String getAttribute (Element el, String attrName) { String sRet = null; Attr attr = el.getAttributeNode(attrName); if (attr != null) { sRet = attr.getValue(); } return sRet; }
private static boolean isNodeWithPrototype(Element e, String nodePrototype) { if (e.getTagName().equals("node")) { Attr prototype = e.getAttributeNode("prototype"); if (prototype != null && prototype.getValue().equals(nodePrototype)) { return true; } } return false; }
private void addSchemaLocationIfNeeded(String namespaceURI, String schemaLocation) { Attr schemaLocationAttribute = doc.getDocumentElement().getAttributeNode("xsi:schemaLocation"); if (schemaLocationAttribute != null && !schemaLocationAttribute.getValue().contains(namespaceURI)) { doc.getDocumentElement().setAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "xsi:schemaLocation", schemaLocationAttribute.getValue() + " " + namespaceURI + " " + schemaLocation); } }