List of usage examples for org.w3c.dom Attr getValue
public String getValue();
From source file:be.fedict.eid.dss.document.zip.ZIPResourceResolver.java
@Override public XMLSignatureInput engineResolve(Attr uri, String baseUri) throws ResourceResolverException { LOG.debug("engineResolve: " + uri.getValue()); InputStream inputStream;/*from w w w .j a v a 2s .c om*/ try { inputStream = findZIPEntry(uri); } catch (IOException e) { throw new ResourceResolverException("IO error: " + e.getMessage(), e, uri, baseUri); } XMLSignatureInput signatureInput = new XMLSignatureInput(inputStream); return signatureInput; }
From source file:com.intuit.karate.Script.java
public static void evalXmlEmbeddedExpressions(Node node, ScriptContext context) { if (node.getNodeType() == Node.DOCUMENT_NODE) { node = node.getFirstChild();/* w ww .ja v a2 s .c om*/ } NamedNodeMap attribs = node.getAttributes(); int attribCount = attribs.getLength(); for (int i = 0; i < attribCount; i++) { Attr attrib = (Attr) attribs.item(i); String value = attrib.getValue(); value = StringUtils.trimToEmpty(value); if (isEmbeddedExpression(value)) { try { ScriptValue sv = evalInNashorn(value.substring(1), context); attrib.setValue(sv.getAsString()); } catch (Exception e) { logger.warn("embedded xml-attribute script eval failed: {}", e.getMessage()); } } } NodeList nodes = node.getChildNodes(); int childCount = nodes.getLength(); for (int i = 0; i < childCount; i++) { Node child = nodes.item(i); String value = child.getNodeValue(); if (value != null) { value = StringUtils.trimToEmpty(value); if (isEmbeddedExpression(value)) { try { ScriptValue sv = evalInNashorn(value.substring(1), context); child.setNodeValue(sv.getAsString()); } catch (Exception e) { logger.warn("embedded xml-text script eval failed: {}", e.getMessage()); } } } else if (child.hasChildNodes()) { evalXmlEmbeddedExpressions(child, context); } } }
From source file:com.sap.research.connectivity.gw.converters.GwRemoteEntityConverter.java
public boolean getAllPossibleValues(final List<Completion> completions, final Class<?> requiredType, final String existingData, final String optionContext, final MethodTarget target) { // Parse, and obtain the namespace value String namespaceValue = " "; if (target.getRemainingBuffer().contains("--namespace")) { String[] splitCommand = target.getRemainingBuffer().split(" "); for (int i = 0; i < splitCommand.length; i++) { if (splitCommand[i].equals("--namespace")) { namespaceValue = splitCommand[i + 1]; break; }// w w w . j a va 2s .co m } } else { log.severe( "Please specify a namespace before choosing the remote entity set (use the option \"--namespace\")."); return true; } // Obtain the available entity sets from the gateway name space String metaDataPath = getSubPackagePath(oDataFolder); String metaDataFile = metaDataPath + SEPARATOR + namespaceValue + "_metadata.xml"; Document doc; try { InputStream metaDataIs = fileManager.getInputStream(metaDataFile); doc = XmlUtils.getDocumentBuilder().parse(metaDataIs); } catch (Exception ex) { //throw new IllegalStateException(ex); log.severe("Namespace \"" + namespaceValue + "\" does not exist or is corrupted. Please specify a valid namespace."); return true; } NodeList nodeList = doc.getElementsByTagName("entity"); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); Attr attr = (Attr) node.getAttributes().getNamedItem("name"); completions.add(new Completion(attr.getValue().toString())); } return false; }
From source file:com.sap.research.connectivity.gw.parsers.MetadataXMLParser.java
private Element getRemoteEntityNode(NodeList nodeList) { for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); Attr attr = (Attr) node.getAttributes().getNamedItem("name"); if (remoteEntity.equals(attr.getValue().toString())) return (Element) node; }/*from w w w.ja v a2s . c om*/ return null; }
From source file:com.krawler.esp.utils.mime.MimeTypesReader.java
/** Read Element named magic. */ private void readMagic(Element element, MimeType mimeType) { // element.getValue(); String offset = null;/*from ww w.ja va2 s. c om*/ String content = null; String type = null; NamedNodeMap attrs = element.getAttributes(); for (int i = 0; i < attrs.getLength(); i++) { Attr attr = (Attr) attrs.item(i); if (attr.getName().equals("offset")) { offset = attr.getValue(); } else if (attr.getName().equals("type")) { type = attr.getValue(); } else if (attr.getName().equals("value")) { content = attr.getValue(); } } if ((offset != null) && (content != null)) { mimeType.addMagic(Integer.parseInt(offset), type, content); } }
From source file:TreeDumper2.java
private void dumpAttributeNode(Attr node, String indent) { System.out.println(indent + "ATTRIBUTE " + node.getName() + "=\"" + node.getValue() + "\""); }
From source file:edu.mayo.cts2.framework.core.xml.PatchedCastorMarshaller.java
protected Object unmarshalDomSource(DOMSource domSource) throws XmlMappingException { Node node = domSource.getNode(); if (node != null && node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) node; Node parent = node.getParentNode(); while (parent != null) { NamedNodeMap atts = parent.getAttributes(); if (atts != null) { for (int i = 0, j = atts.getLength(); i < j; i++) { Attr att = (Attr) atts.item(i); if (XMLNS_NS.equals(att.getNamespaceURI())) { String name = att.getName(); String value = att.getValue(); if (!element.hasAttributeNS(XMLNS_NS, name)) { element.setAttributeNS(XMLNS_NS, name, value); }/*from w w w . jav a 2 s . c om*/ } } } parent = parent.getParentNode(); } } return super.unmarshalDomSource(domSource); }
From source file:com.amalto.core.history.accessor.AttributeAccessor.java
public String get() { Node namedItem = getAttribute(); if (!(namedItem instanceof Attr)) { throw new IllegalStateException( "Expected a " + Attr.class.getName() + " instance but got a " + namedItem.getClass().getName()); //$NON-NLS-1$ //$NON-NLS-2$ }//from w ww . jav a 2s. c o m Attr attribute = (Attr) namedItem; return attribute.getValue(); }
From source file:com.krawler.esp.utils.mime.MimeTypesReader.java
/** Read Element named mime-type. */ private MimeType readMimeType(Element element) { String name = null;/* w w w . j a va 2 s .c o m*/ String description = null; MimeType type = null; NamedNodeMap attrs = element.getAttributes(); for (int i = 0; i < attrs.getLength(); i++) { Attr attr = (Attr) attrs.item(i); if (attr.getName().equals("name")) { name = attr.getValue(); } else if (attr.getName().equals("description")) { description = attr.getValue(); } } if ((name == null) || (name.trim().equals(""))) { return null; } try { type = new MimeType(name); } catch (MimeTypeException mte) { // Mime Type not valid... just ignore it if (logger.isInfoEnabled()) { logger.info(mte.toString() + " ... Ignoring!"); } return null; } type.setDescription(description); NodeList nodes = element.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element nodeElement = (Element) node; if (nodeElement.getTagName().equals("ext")) { readExt(nodeElement, type); } else if (nodeElement.getTagName().equals("magic")) { readMagic(nodeElement, type); } } } return type; }
From source file:com.predic8.membrane.core.config.spring.AbstractParser.java
protected void setProperties(String prop, Element e, BeanDefinitionBuilder builder) { NamedNodeMap attributes = e.getAttributes(); HashMap<String, String> attrs = new HashMap<String, String>(); for (int i = 0; i < attributes.getLength(); i++) { Attr item = (Attr) attributes.item(i); if (item.getLocalName() != null) attrs.put(item.getLocalName(), item.getValue()); }/*from w w w . j av a 2 s. com*/ builder.addPropertyValue(prop, attrs); }