List of usage examples for org.w3c.dom Element getElementsByTagNameNS
public NodeList getElementsByTagNameNS(String namespaceURI, String localName) throws DOMException;
NodeList
of all the descendant Elements
with a given local name and namespace URI in document order. From source file:org.jdal.beans.CustomBeanDefinitionParser.java
/** * Parse a list element//from w w w .ja v a 2s .c om * @param element parent element * @param parserContext parse context * @param builder bean definition builder. * @param name the child list name. */ protected void parseList(Element element, ParserContext parserContext, BeanDefinitionBuilder builder, String name) { NodeList nl = element.getElementsByTagNameNS(element.getNamespaceURI(), name); if (nl.getLength() > 0) { Element e = (Element) nl.item(0); List<Object> actionList = parserContext.getDelegate().parseListElement(e, builder.getRawBeanDefinition()); builder.addPropertyValue(name, actionList); } }
From source file:be.e_contract.mycarenet.sts.EHealthSTSClient.java
/** * Returns the value of the NotOnOrAfter element within the given SAML * assertion.//from w w w .ja v a 2 s . c o m * * @param assertionElement * @return */ public DateTime getNotAfter(Element assertionElement) { NodeList conditionsNodeList = assertionElement .getElementsByTagNameNS("urn:oasis:names:tc:SAML:1.0:assertion", "Conditions"); Element conditionsElement = (Element) conditionsNodeList.item(0); String notOnOrAfterAttributeValue = conditionsElement.getAttribute("NotOnOrAfter"); Calendar calendar = DatatypeConverter.parseDateTime(notOnOrAfterAttributeValue); return new DateTime(calendar.getTime()); }
From source file:com.mtgi.analytics.aop.config.v11.BtJdbcPersisterBeanDefinitionParser.java
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { //configure ID generator settings NodeList children = element.getElementsByTagNameNS("*", ELT_ID_SQL); if (children.getLength() == 1) { BeanDefinition def = builder.getRawBeanDefinition(); MutablePropertyValues props = def.getPropertyValues(); Element child = (Element) children.item(0); String sql = child.getTextContent(); if (StringUtils.hasText(sql)) props.addPropertyValue("idSql", sql); if (child.hasAttribute(ATT_INCREMENT)) props.addPropertyValue("idIncrement", child.getAttribute(ATT_INCREMENT)); }//from w w w .ja v a 2 s .c om //configure nested dataSource NodeList nodes = element.getElementsByTagNameNS("*", "data-source"); if (nodes.getLength() == 1) { Element ds = (Element) nodes.item(0); ds.setAttribute("name", "dataSource"); parserContext.getDelegate().parsePropertyElement(ds, builder.getRawBeanDefinition()); } //push persister into parent manager bean, if applicable if (parserContext.isNested()) { AbstractBeanDefinition def = builder.getBeanDefinition(); String id = element.hasAttribute("id") ? element.getAttribute("id") : BeanDefinitionReaderUtils.generateBeanName(def, parserContext.getReaderContext().getRegistry(), true); BeanDefinitionHolder holder = new BeanDefinitionHolder(def, id); BtManagerBeanDefinitionParser.registerNestedBean(holder, "persister", parserContext); } }
From source file:org.carewebframework.shell.BaseXmlParser.java
/** * Returns the children under the specified tag. Compensates for namespace usage. * //from w w w . j av a2s . c o m * @param tagName Name of tag whose children are sought. * @param element Element to search for tag. * @return Node list containing children of tag. */ protected NodeList getTagChildren(String tagName, Element element) { return element.getNamespaceURI() == null ? element.getElementsByTagName(tagName) : element.getElementsByTagNameNS(element.getNamespaceURI(), tagName); }
From source file:net.scriptability.core.integration.spring.ScriptAbilityBeanDefinitionParser.java
private Map<String, RuntimeBeanReference> createBeanBindings(final Element bindingsElement) { Map<String, RuntimeBeanReference> beanBindings = new ManagedMap<>(); NodeList bindingNodeList = bindingsElement.getElementsByTagNameNS(XML_NAMESPACE__SCRIPTABILITY, XML_ELEMENT__BINDING);//from ww w.ja va 2 s .co m for (int i = 0; i < bindingNodeList.getLength(); i++) { Element binding = (Element) bindingNodeList.item(i); beanBindings.put(binding.getAttribute(XML_ATTRIBUTE__NAME), new RuntimeBeanReference(binding.getAttribute(XML_ATTRIBUTE__BEAN_REF))); } return beanBindings; }
From source file:be.e_contract.mycarenet.sts.EHealthSTSClient.java
/** * Requests an eHealth SAML assertion from the eHealth STS. * // ww w . j av a 2s. c o m * @param authnCertificate * the eID authentication certificate. * @param authnPrivateKey * the eID authentication private key. * @param hokCertificate * the eHealth holder-of-key authentication certificate. * @param hokPrivateKey * the eHealth holder-of-key authentication private key. * @param attributes * the identity attributes. * @param attributeDesignators * the required attributes. * @return the SAML assertion as DOM element. * @throws Exception * in case something goes wrong. */ public Element requestAssertion(X509Certificate authnCertificate, PrivateKey authnPrivateKey, X509Certificate hokCertificate, PrivateKey hokPrivateKey, List<Attribute> attributes, List<AttributeDesignator> attributeDesignators) throws Exception { this.wsSecuritySOAPHandler.setCertificate(authnCertificate); this.wsSecuritySOAPHandler.setPrivateKey(authnPrivateKey); RequestFactory requestFactory = new RequestFactory(); Element requestElement = requestFactory.createRequest(authnCertificate, hokPrivateKey, hokCertificate, attributes, attributeDesignators); Source responseSource = this.dispatch.invoke(new DOMSource(requestElement)); Element responseElement = toElement(responseSource); NodeList assertionNodeList = responseElement.getElementsByTagNameNS("urn:oasis:names:tc:SAML:1.0:assertion", "Assertion"); if (assertionNodeList.getLength() == 0) { LOG.error("no assertion in response"); return null; } return (Element) assertionNodeList.item(0); }
From source file:com.nominanuda.springmvc.MvcFrontControllerBeanDefinitionParser.java
protected @Nullable List<BeanMetadataElement> generateFilterList(Element element, ParserContext parserContext, String uriSpec) {//from w w w . j a v a 2s.c o m NodeList nl = element.getElementsByTagNameNS(ns, "filter"); if (nl == null || nl.getLength() == 0) { return null; } List<BeanMetadataElement> l = new ManagedList<BeanMetadataElement>(); for (int i = 0; i < nl.getLength(); i++) { Element filter = (Element) nl.item(i); String ref = getAttribute(filter, "ref"); BeanDefinition bd; if (ref != null) { bd = parserContext.getRegistry().getBeanDefinition(ref); } else { Element innerBean = (Element) filter.getElementsByTagNameNS(beansNs, "bean").item(0); String innerBeanId = getAttribute(innerBean, "id"); if (innerBeanId == null) { innerBeanId = uuid(); } bd = parserContext.getDelegate().parseBeanDefinitionElement(innerBean).getBeanDefinition(); parserContext.getRegistry().registerBeanDefinition(innerBeanId, bd); } l.add(Check.notNull(bd)); } return l; }
From source file:com.ubikod.capptain.android.sdk.reach.CapptainPoll.java
/** * Parse an announcement./* ww w . j a v a 2 s .c om*/ * @param jid service that sent the announcement. * @param xml raw XML of announcement to store in SQLite. * @param root parsed XML root DOM element. * @throws JSONException if a parsing error occurs. */ CapptainPoll(String jid, String xml, Element root) throws JSONException { super(jid, xml, root); mAnswers = new Bundle(); mQuestions = new JSONArray(); NodeList questions = root.getElementsByTagNameNS(REACH_NAMESPACE, "question"); for (int i = 0; i < questions.getLength(); i++) { Element questionE = (Element) questions.item(i); NodeList choicesN = questionE.getElementsByTagNameNS(REACH_NAMESPACE, "choice"); JSONArray choicesJ = new JSONArray(); for (int j = 0; j < choicesN.getLength(); j++) { Element choiceE = (Element) choicesN.item(j); JSONObject choiceJ = new JSONObject(); choiceJ.put("id", choiceE.getAttribute("id")); choiceJ.put("title", XmlUtil.getText(choiceE)); choiceJ.put("default", Boolean.parseBoolean(choiceE.getAttribute("default"))); choicesJ.put(choiceJ); } JSONObject questionJ = new JSONObject(); questionJ.put("id", questionE.getAttribute("id")); questionJ.put("title", XmlUtil.getTagText(questionE, "title", null)); questionJ.put("choices", choicesJ); mQuestions.put(questionJ); } }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRFedNonFedSubAwardBudget_1_3_V1_3Generator.java
private RRFedNonFedBudget12Document getRRFedNonFedBudget(BudgetSubAwardsContract budgetSubAwards) { String subAwdXML = budgetSubAwards.getSubAwardXmlFileData(); Document subAwdFormsDoc = stringToDom(subAwdXML); Element subAwdFormsElement = subAwdFormsDoc.getDocumentElement(); NodeList subAwdNodeList = subAwdFormsElement.getElementsByTagNameNS(RR_FED_NON_FED_BUDGET_12_NAMESPACE_URI, LOCAL_FED_NON_FED_NAME);//from ww w. ja v a2s . c o m Node subAwdNode = null; if (subAwdNodeList != null) { if (subAwdNodeList.getLength() == 0) { return null; } subAwdNode = subAwdNodeList.item(0); } try { byte[] subAwdNodeBytes = docToBytes(nodeToDom(subAwdNode)); return (RRFedNonFedBudget12Document) XmlObject.Factory.parse(new ByteArrayInputStream(subAwdNodeBytes)); } catch (XmlException | IOException e) { throw new RuntimeException(e); } }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRSubAwardBudget10_10V1_4Generator.java
private RRBudget1014Document getRRBudget(BudgetSubAwardsContract budgetSubAwards) { String subAwdXML = budgetSubAwards.getSubAwardXmlFileData(); Document subAwdFormsDoc = stringToDom(subAwdXML); Element subAwdFormsElement = subAwdFormsDoc.getDocumentElement(); NodeList subAwdNodeList = subAwdFormsElement.getElementsByTagNameNS(RR_BUDGET_10_1_4_NAMESPACE_URI, RR_BUDGET_10_1_4_LOCAL_NAME); Node subAwdNode = null;//from w w w . jav a 2 s . c om if (subAwdNodeList != null) { if (subAwdNodeList.getLength() == 0) { return null; } subAwdNode = subAwdNodeList.item(0); } byte[] subAwdNodeBytes = docToBytes(nodeToDom(subAwdNode)); try { return (RRBudget1014Document) XmlObject.Factory.parse(new ByteArrayInputStream(subAwdNodeBytes)); } catch (XmlException | IOException e) { throw new RuntimeException(e); } }