/** * Matches the given node's name and local name against the given desired name. */ private static boolean nodeNameMatch(Node node, String desiredName) { return (desiredName.equals(node.getNodeName()) || desiredName.equals(node.getLocalName())); }
private static void parseProperties(NodeList nodeList, RootBeanDefinition beanDefinition) { if (nodeList != null && nodeList.getLength() > 0) { for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node instanceof Element) { if ("property".equals(node.getNodeName()) || "property".equals(node.getLocalName())) { String name = ((Element) node).getAttribute("name"); if (name != null && name.length() > 0) { String value = ((Element) node).getAttribute("value"); String ref = ((Element) node).getAttribute("ref"); if (value != null && value.length() > 0) { beanDefinition.getPropertyValues().addPropertyValue(name, value); } else if (ref != null && ref.length() > 0) { beanDefinition.getPropertyValues().addPropertyValue(name, new RuntimeBeanReference(ref)); } else { throw new UnsupportedOperationException("Unsupported <property name=\"" + name + "\"> sub tag, Only supported <property name=\"" + name + "\" ref=\"...\" /> or <property name=\"" + name + "\" value=\"...\" />"); } } } } } } }
/** * @param sibling * @param nodeName * @param number * @return nodes with the constraint */ public static Element selectDsNode(Node sibling, String nodeName, int number) { while (sibling != null) { if (Constants.SignatureSpecNS.equals(sibling.getNamespaceURI()) && sibling.getLocalName().equals(nodeName)) { if (number == 0){ return (Element)sibling; } number--; } sibling = sibling.getNextSibling(); } return null; }
values.add(node.getNodeType()); values.add(node.getNodeName()); values.add(node.getLocalName()); values.add(node.getNamespaceURI()); values.add(node.getPrefix()); values.add(node.getNodeValue()); for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) { values.add(child); switch (node.getNodeType()) { case DOCUMENT_TYPE_NODE: DocumentTypeImpl doctype = (DocumentTypeImpl) node;
Element result = null; NodeList l = parent.getChildNodes(); int nodeCount = l.getLength(); for (int i = 0; i < nodeCount; i++) { if (l.item(i).getNodeType() == Node.ELEMENT_NODE) { Node node = l.item(i); String localName = node.getLocalName(); localName = localName == null ? node.getNodeName() : localName; && (namespace == null || namespace.equals(node.getNamespaceURI()))) { if (result == null) { result = (Element)node;
private void read(InputStream is) throws Exception { Document domDoc = XmlUtils.getNewDocumentBuilder().parse(is); Element presetShapeDefinitons = domDoc.getDocumentElement(); NodeList nodes = presetShapeDefinitons.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i); if (!(node instanceof Element)) continue; String name = node.getLocalName(); CTCustomGeometry2D geom = (CTCustomGeometry2D)XmlUtils.unmarshal(node, Context.jc, CTCustomGeometry2D.class); if(containsKey(name)) { log.warn("Duplicate definition of " + name) ; // happened for upDownArrow; that dupe now commented out } put(name, geom); log.debug(name); } }
NodeList nodes = (NodeList) result; for (int i = 0; i < nodes.getLength(); i++) { Node currentItem = nodes.item(i); System.out.println("found node -> " + currentItem.getLocalName() + " (namespace: " + currentItem.getNamespaceURI() + ")");
private boolean namedNodeMapsEqual(NamedNodeMap a, NamedNodeMap b) { if (a.getLength() != b.getLength()) { return false; } for (int i = 0; i < a.getLength(); i++) { Node aNode = a.item(i); Node bNode = aNode.getLocalName() == null ? b.getNamedItem(aNode.getNodeName()) : b.getNamedItemNS(aNode.getNamespaceURI(), aNode.getLocalName()); if (bNode == null || !aNode.isEqualNode(bNode)) { return false; } } return true; }
Node p = (root.getNodeType() == Node.ATTRIBUTE_NODE) ? ((org.w3c.dom.Attr)root).getOwnerElement() : root.getParentNode(); for (; p != null; p = p.getParentNode()) handle=dtm.getAttributeNode(handle,node.getNamespaceURI(),node.getLocalName());
for (int i = 0, length = attributes.getLength(); i < length; i++) { Node attr = attributes.item(i); if (!"http://www.w3.org/2000/xmlns/".equals(attr.getNamespaceURI()) || !"xmlns".equals(attr.getPrefix()) || !namespaceURI.equals(attr.getNodeValue())) { continue; if (target.isPrefixMappedToUri(attr.getLocalName(), namespaceURI)) { return attr.getLocalName();
return new SimpleScalar(getText(node)); } else if (key.equals(AtAtKey.NAMESPACE.getKey())) { String nsURI = node.getNamespaceURI(); return nsURI == null ? null : new SimpleScalar(nsURI); } else if (key.equals(AtAtKey.LOCAL_NAME.getKey())) { String localName = node.getLocalName(); if (localName == null) { localName = getNodeName(); StringBuilder buf = new StringBuilder(); NodeOutputter nu = new NodeOutputter(node); nu.outputContent(node.getChildNodes(), buf); return new SimpleScalar(buf.toString()); } else if (key.equals(AtAtKey.QNAME.getKey())) {
private static void parseProperties(NodeList nodeList, RootBeanDefinition beanDefinition) { if (nodeList != null && nodeList.getLength() > 0) { for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node instanceof Element) { if ("property".equals(node.getNodeName()) || "property".equals(node.getLocalName())) { String name = ((Element) node).getAttribute("name"); if (name != null && name.length() > 0) { String value = ((Element) node).getAttribute("value"); String ref = ((Element) node).getAttribute("ref"); if (value != null && value.length() > 0) { beanDefinition.getPropertyValues().addPropertyValue(name, value); } else if (ref != null && ref.length() > 0) { beanDefinition.getPropertyValues().addPropertyValue(name, new RuntimeBeanReference(ref)); } else { throw new UnsupportedOperationException("Unsupported <property name=\"" + name + "\"> sub tag, Only supported <property name=\"" + name + "\" ref=\"...\" /> or <property name=\"" + name + "\" value=\"...\" />"); } } } } } } }
for (int i = 0, length = attributes.getLength(); i < length; i++) { Node attr = attributes.item(i); if (!"http://www.w3.org/2000/xmlns/".equals(attr.getNamespaceURI())) { continue; ? "xmlns".equals(attr.getNodeName()) : "xmlns".equals(attr.getPrefix()) && prefix.equals(attr.getLocalName())) { String value = attr.getNodeValue(); return value.length() > 0 ? value : null;
private BeanDefinition parseJupiterProvider(Element element, ParserContext parserContext) { RootBeanDefinition def = new RootBeanDefinition(); def.setBeanClass(beanClass); addPropertyReference(def, element, "server", true); addPropertyReference(def, element, "providerImpl", true); NodeList childNodes = element.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node item = childNodes.item(i); if (item instanceof Element) { String localName = item.getLocalName(); if ("property".equals(localName)) { addProperty(def, (Element) item, "weight", false); addPropertyReferenceArray( def, (Element) item, ProviderInterceptor.class.getName(), "providerInterceptors", false); addPropertyReference(def, (Element) item, "executor", false); addPropertyReference(def, (Element) item, "flowController", false); addPropertyReference(def, (Element) item, "providerInitializer", false); addPropertyReference(def, (Element) item, "providerInitializerExecutor", false); } } } return registerBean(def, element, parserContext); }
/** * Matches the given node's name and local name against the given desired names. */ private static boolean nodeNameMatch(Node node, Collection<?> desiredNames) { return (desiredNames.contains(node.getNodeName()) || desiredNames.contains(node.getLocalName())); }
private void outputQualifiedName(Node n, StringBuilder buf) { String nsURI = n.getNamespaceURI(); if (nsURI == null || nsURI.length() == 0) { buf.append(n.getNodeName()); } else { String prefix = namespacesToPrefixLookup.get(nsURI); if (prefix == null) { //REVISIT! buf.append(n.getNodeName()); } else { if (prefix.length() > 0) { buf.append(prefix); buf.append(':'); } buf.append(n.getLocalName()); } } }
Node p = (root.getNodeType() == Node.ATTRIBUTE_NODE) ? ((org.w3c.dom.Attr)root).getOwnerElement() : root.getParentNode(); for (; p != null; p = p.getParentNode()) handle=dtm.getAttributeNode(handle,node.getNamespaceURI(),node.getLocalName());
protected void write(OutputStream out) throws IOException { XmlObject rootObject = XmlObject.Factory.newInstance(); XmlCursor rootCursor = rootObject.newCursor(); rootCursor.toNextToken(); rootCursor.beginElement("xml"); for(int i=0; i < _items.size(); i++){ XmlCursor xc = _items.get(i).newCursor(); rootCursor.beginElement(_qnames.get(i)); while(xc.toNextToken() == XmlCursor.TokenType.ATTR) { Node anode = xc.getDomNode(); rootCursor.insertAttributeWithValue(anode.getLocalName(), anode.getNamespaceURI(), anode.getNodeValue()); } xc.toStartDoc(); xc.copyXmlContents(rootCursor); rootCursor.toNextToken(); xc.dispose(); } rootCursor.dispose(); rootObject.save(out, DEFAULT_XML_OPTIONS); }
/** * @param sibling * @param nodeName * @param number * @return nodes with the constraint */ public static Element selectDs11Node(Node sibling, String nodeName, int number) { while (sibling != null) { if (Constants.SignatureSpec11NS.equals(sibling.getNamespaceURI()) && sibling.getLocalName().equals(nodeName)) { if (number == 0){ return (Element)sibling; } number--; } sibling = sibling.getNextSibling(); } return null; }
private static void parseNested(Element element, ParserContext parserContext, Class<?> beanClass, boolean required, String tag, String property, String ref, BeanDefinition beanDefinition) { NodeList nodeList = element.getChildNodes(); if (nodeList != null && nodeList.getLength() > 0) { boolean first = true; for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node instanceof Element) { if (tag.equals(node.getNodeName()) || tag.equals(node.getLocalName())) { if (first) { first = false; String isDefault = element.getAttribute("default"); if (StringUtils.isEmpty(isDefault)) { beanDefinition.getPropertyValues().addPropertyValue("default", "false"); } } BeanDefinition subDefinition = parse((Element) node, parserContext, beanClass, required); if (subDefinition != null && ref != null && ref.length() > 0) { subDefinition.getPropertyValues().addPropertyValue(property, new RuntimeBeanReference(ref)); } } } } } }