/** * Gets the child elements of the given element in a single iteration. * * @param root element to get the child elements of * * @return child elements indexed by namespace qualifed tag name, never null */ public static Map<QName, List<Element>> getChildElements(Element root) { Map<QName, List<Element>> children = new HashMap<QName, List<Element>>(); Element e = getFirstChildElement(root); while (e != null) { QName qname = getNodeQName(e); List<Element> elements = children.get(qname); if (elements == null) { elements = new ArrayList<Element>(); children.put(qname, elements); } elements.add(e); e = getNextSiblingElement(e); } return children; }
/** * Gets the child elements of the given element in a single iteration. * * @param root element to get the child elements of * * @return child elements indexed by namespace qualifed tag name, never null */ public static Map<QName, List<Element>> getChildElements(Element root) { Map<QName, List<Element>> children = new HashMap<QName, List<Element>>(); Element e = getFirstChildElement(root); while (e != null) { QName qname = getNodeQName(e); List<Element> elements = children.get(qname); if (elements == null) { elements = new ArrayList<Element>(); children.put(qname, elements); } elements.add(e); e = getNextSiblingElement(e); } return children; }
/** * Gets the child nodes with the given local tag name. If you need to retrieve multiple, named, children consider * using {@link #getChildElements(Element)}. * * @param root element to retrieve the children from * @param localName local, tag, name of the child element * * @return list of child elements, never null */ public static List<Element> getChildElementsByTagName(Element root, String localName) { ArrayList<Element> children = new ArrayList<Element>(); Element e = getFirstChildElement(root); while (e != null) { if (DatatypeHelper.safeEquals(e.getLocalName(), localName)) { children.add(e); } e = getNextSiblingElement(e); } return children; }
/** * Gets the child nodes with the given local tag name. If you need to retrieve multiple, named, children consider * using {@link #getChildElements(Element)}. * * @param root element to retrieve the children from * @param localName local, tag, name of the child element * * @return list of child elements, never null */ public static List<Element> getChildElementsByTagName(Element root, String localName) { ArrayList<Element> children = new ArrayList<Element>(); Element e = getFirstChildElement(root); while (e != null) { if (DatatypeHelper.safeEquals(e.getLocalName(), localName)) { children.add(e); } e = getNextSiblingElement(e); } return children; }
/** * Gets the child nodes with the given namespace qualified tag name. If you need to retrieve multiple, named, * children consider using {@link #getChildElements(Element)}. * * @param root element to retrieve the children from * @param namespaceURI namespace URI of the child element * @param localName local, tag, name of the child element * * @return list of child elements, never null */ public static List<Element> getChildElementsByTagNameNS(Element root, String namespaceURI, String localName) { ArrayList<Element> children = new ArrayList<Element>(); Element e = getFirstChildElement(root); while (e != null) { if (DatatypeHelper.safeEquals(e.getNamespaceURI(), namespaceURI) && DatatypeHelper.safeEquals(e.getLocalName(), localName)) { children.add(e); } e = getNextSiblingElement(e); } return children; }
/** * Gets the child nodes with the given namespace qualified tag name. If you need to retrieve multiple, named, * children consider using {@link #getChildElements(Element)}. * * @param root element to retrieve the children from * @param namespaceURI namespace URI of the child element * @param localName local, tag, name of the child element * * @return list of child elements, never null */ public static List<Element> getChildElementsByTagNameNS(Element root, String namespaceURI, String localName) { ArrayList<Element> children = new ArrayList<Element>(); Element e = getFirstChildElement(root); while (e != null) { if (DatatypeHelper.safeEquals(e.getNamespaceURI(), namespaceURI) && DatatypeHelper.safeEquals(e.getLocalName(), localName)) { children.add(e); } e = getNextSiblingElement(e); } return children; }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { log.info("Parsing configuration for {} trust engine with id: {}", XMLHelper.getXSIType(element) .getLocalPart(), element.getAttributeNS(null, "id")); ManagedList managedChain = new ManagedList(); Element child = XMLHelper.getFirstChildElement(element); while (child != null) { QName childName = XMLHelper.getNodeQName(child); if (TRUST_ENGINE_NAME.equals(childName)) { log.debug("Parsing chain trust engine member {}", element.getAttributeNS(null, "id")); managedChain.add(SpringConfigurationUtils.parseCustomElement(child, parserContext)); } else if (TRUST_ENGINE_REF_NAME.equals(childName)) { log.debug("Parsing chain trust engine member reference {}", element.getAttributeNS(null, "ref") ); managedChain.add(SpringConfigurationUtils.parseCustomElementReference(child, "ref", parserContext)); } else { log.error("Unsupported child element of chaining trust engine '{}' encountered with name: {}", element.getAttributeNS(null, "id"), childName); throw new FatalBeanException("Unsupported child element of chaining trust engine encountered"); } child = XMLHelper.getNextSiblingElement(child); } builder.addPropertyValue("chain", managedChain); }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { log.info("Parsing configuration for {} trust engine with id: {}", XMLHelper.getXSIType(element).getLocalPart(), element.getAttributeNS(null, "id")); ManagedList managedChain = new ManagedList(); Element child = XMLHelper.getFirstChildElement(element); while (child != null) { QName childName = XMLHelper.getNodeQName(child); if (TRUST_ENGINE_NAME.equals(childName)) { log.debug("Parsing chain trust engine member {}", element.getAttributeNS(null, "id")); managedChain.add(SpringConfigurationUtils.parseCustomElement(child, parserContext)); } else if (TRUST_ENGINE_REF_NAME.equals(childName)) { log.debug("Parsing chain trust engine member reference {}", element.getAttributeNS(null, "ref")); managedChain.add(SpringConfigurationUtils.parseCustomElementReference(child, "ref", parserContext)); } else { log.error("Unsupported child element of chaining trust engine '{}' encountered with name: {}", element .getAttributeNS(null, "id"), childName); throw new FatalBeanException("Unsupported child element of chaining trust engine encountered"); } child = XMLHelper.getNextSiblingElement(child); } builder.addPropertyValue("chain", managedChain); }
/** {@inheritDoc} */ public boolean isSigned() { Element domElement = getDOM(); if (domElement == null) { return false; } Element childElement = XMLHelper.getFirstChildElement(domElement); while (childElement != null) { if (XMLHelper.isElementNamed(childElement, XMLConstants.XMLSIG_NS, Signature.DEFAULT_ELEMENT_LOCAL_NAME)) { return true; } childElement = XMLHelper.getNextSiblingElement(childElement); } return false; }
/** {@inheritDoc} */ public boolean isSigned() { Element domElement = getDOM(); if (domElement == null) { return false; } Element childElement = XMLHelper.getFirstChildElement(domElement); while (childElement != null) { if (XMLHelper.isElementNamed(childElement, XMLConstants.XMLSIG_NS, Signature.DEFAULT_ELEMENT_LOCAL_NAME)) { return true; } childElement = XMLHelper.getNextSiblingElement(childElement); } return false; }
Element childNode = getFirstChildElement(domElement); while (childNode != null) { rootNamespaces(childNode, upperNamespaceSearchBound);
Element childNode = getFirstChildElement(domElement); while (childNode != null) { rootNamespaces(childNode, upperNamespaceSearchBound);