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.kuali.coeus.s2sgen.impl.generate.support.RRSubAwardBudgetV1_2Generator.java
private RRBudgetDocument getRRBudget(BudgetSubAwardsContract budgetSubAwards) { String subAwdXML = budgetSubAwards.getSubAwardXmlFileData(); Document subAwdFormsDoc = stringToDom(subAwdXML); Element subAwdFormsElement = subAwdFormsDoc.getDocumentElement(); NodeList subAwdNodeList = subAwdFormsElement.getElementsByTagNameNS(RR_BUDGET_11_NAMESPACE_URI, LOCAL_NAME); Node subAwdNode = null;// w ww .j ava2 s.c om if (subAwdNodeList != null) { if (subAwdNodeList.getLength() == 0) { return null; } subAwdNode = subAwdNodeList.item(0); } byte[] subAwdNodeBytes; try { subAwdNodeBytes = docToBytes(nodeToDom(subAwdNode)); InputStream bgtIS = new ByteArrayInputStream(subAwdNodeBytes); return (RRBudgetDocument) XmlObject.Factory.parse(bgtIS); } catch (XmlException | IOException e) { throw new RuntimeException(e); } }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRSubAwardBudgetV1_0Generator.java
private RRBudgetDocument getRRBudget(BudgetSubAwardsContract budgetSubAwards) { String subAwdXML = budgetSubAwards.getSubAwardXmlFileData(); Document subAwdFormsDoc = stringToDom(subAwdXML); Element subAwdFormsElement = subAwdFormsDoc.getDocumentElement(); NodeList subAwdNodeList = subAwdFormsElement.getElementsByTagNameNS(RR_BUDGET_10_NAMESPACE_URI, LOCAL_NAME); Node subAwdNode = null;//from www .j av a 2s . c om if (subAwdNodeList != null) { if (subAwdNodeList.getLength() == 0) { return null; } subAwdNode = subAwdNodeList.item(0); } byte[] subAwdNodeBytes; try { subAwdNodeBytes = docToBytes(nodeToDom(subAwdNode)); InputStream bgtIS = new ByteArrayInputStream(subAwdNodeBytes); return (RRBudgetDocument) XmlObject.Factory.parse(bgtIS); } catch (XmlException | IOException e) { throw new RuntimeException(e); } }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRSubAwardBudget1_3V1_3Generator.java
private RRBudget13Document getRRBudget10(BudgetSubAwardsContract budgetSubAwards) { String subAwdXML = budgetSubAwards.getSubAwardXmlFileData(); Document subAwdFormsDoc = stringToDom(subAwdXML); Element subAwdFormsElement = subAwdFormsDoc.getDocumentElement(); NodeList subAwdNodeList = subAwdFormsElement.getElementsByTagNameNS(RR_BUDGET1_3_NAMESPACE_URI, RR_BUDGET1_3_LOCAL_NAME);/*from ww w . java2 s . c o m*/ Node subAwdNode = null; if (subAwdNodeList != null) { if (subAwdNodeList.getLength() == 0) { return null; } subAwdNode = subAwdNodeList.item(0); } byte[] subAwdNodeBytes; try { subAwdNodeBytes = docToBytes(nodeToDom(subAwdNode)); InputStream bgtIS = new ByteArrayInputStream(subAwdNodeBytes); return (RRBudget13Document) XmlObject.Factory.parse(bgtIS); } catch (XmlException | IOException e) { throw new RuntimeException(e); } }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRSubAwardBudget1_4V1_4Generator.java
private RRBudget14Document getRRBudget10(BudgetSubAwardsContract budgetSubAwards) { final RRBudget14Document rrBudget; String subAwdXML = budgetSubAwards.getSubAwardXmlFileData(); Document subAwdFormsDoc = stringToDom(subAwdXML); Element subAwdFormsElement = subAwdFormsDoc.getDocumentElement(); NodeList subAwdNodeList = subAwdFormsElement.getElementsByTagNameNS(RR_BUDGET1_4_NAMESPACE_URI, RR_BUDGET1_4_LOCAL_NAME);/* ww w .j a v a 2 s. co m*/ Node subAwdNode = null; if (subAwdNodeList != null) { if (subAwdNodeList.getLength() == 0) { return null; } subAwdNode = subAwdNodeList.item(0); } byte[] subAwdNodeBytes = docToBytes(nodeToDom(subAwdNode)); try { rrBudget = (RRBudget14Document) XmlObject.Factory.parse(new ByteArrayInputStream(subAwdNodeBytes)); } catch (XmlException | IOException e) { throw new RuntimeException(e); } return rrBudget; }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRSubAwardBudgetV1_1Generator.java
private RRBudgetDocument getRRBudget(BudgetSubAwardsContract budgetSubAwards) throws S2SException { String subAwdXML = budgetSubAwards.getSubAwardXmlFileData(); Document subAwdFormsDoc = stringToDom(subAwdXML); Element subAwdFormsElement = subAwdFormsDoc.getDocumentElement(); NodeList subAwdNodeList = subAwdFormsElement.getElementsByTagNameNS(RR_BUDGET_11_NAMESPACE_URI, LOCAL_NAME); Node subAwdNode = null;//from w ww. ja v a2 s.co m if (subAwdNodeList != null) { if (subAwdNodeList.getLength() == 0) { return null; } subAwdNode = subAwdNodeList.item(0); } byte[] subAwdNodeBytes; InputStream bgtIS = null; try { subAwdNodeBytes = docToBytes(nodeToDom(subAwdNode)); bgtIS = new ByteArrayInputStream(subAwdNodeBytes); return (RRBudgetDocument) XmlObject.Factory.parse(bgtIS); } catch (XmlException | IOException e) { throw new RuntimeException(e); } finally { if (bgtIS != null) { try { bgtIS.close(); } catch (IOException e) { } } } }
From source file:de.undercouch.citeproc.zotero.ZoteroConnector.java
@Override protected Map<String, Object> parseResponse(Response response) throws IOException { String contentType = response.getHeader("Content-Type"); InputStream is = response.getInputStream(); Reader r = new BufferedReader(new InputStreamReader(is)); if (contentType != null && contentType.equals("application/atom+xml")) { //response is an Atom. parse it... DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); Document doc;/*from w ww. j a v a 2 s. c om*/ try { DocumentBuilder builder = factory.newDocumentBuilder(); InputSource source = new InputSource(r); doc = builder.parse(source); } catch (SAXException e) { throw new IOException("Could not parse server response", e); } catch (ParserConfigurationException e) { throw new IOException("Could not create XML parser", e); } Map<String, Object> result = new HashMap<String, Object>(); //extract content in 'csljson' format Element feed = doc.getDocumentElement(); NodeList entries = feed.getElementsByTagName("entry"); for (int i = 0; i < entries.getLength(); ++i) { String key = null; String csljson = null; Node entry = entries.item(i); if (entry instanceof Element) { Element entryElem = (Element) entry; NodeList keys = entryElem.getElementsByTagNameNS("http://zotero.org/ns/api", "key"); if (keys.getLength() > 0) { key = keys.item(0).getTextContent().trim(); NodeList contents = entryElem.getElementsByTagName("content"); if (contents.getLength() > 0) { Node content = contents.item(0); Node type = content.getAttributes().getNamedItemNS("http://zotero.org/ns/api", "type"); if (type != null && type.getTextContent().equals(CSLJSON)) { csljson = content.getTextContent().trim(); } } } } if (csljson == null || csljson.isEmpty()) { throw new IOException("Could not extract CSL json content from entry"); } Map<String, Object> item = new JsonParser(new JsonLexer(new StringReader(csljson))).parseObject(); result.put(key, item); } return result; } else { return super.parseResponse(response); } }
From source file:com.googlecode.ehcache.annotations.config.EhCacheConfigBeanDefinitionParser.java
public BeanDefinition parse(final Element element, final ParserContext parserContext) { final Object elementSource = parserContext.extractSource(element); final NodeList evictExpiredElements = element.getElementsByTagNameNS(element.getNamespaceURI(), XSD_ELEMENT__EVICT_EXPIRED_ELEMENTS); if (evictExpiredElements.getLength() > 1) { throw new BeanCreationException("Only one '" + XSD_ELEMENT__EVICT_EXPIRED_ELEMENTS + "' is allowed"); }/*from www. ja va 2 s.co m*/ final int evictExpiredElementsLength = evictExpiredElements.getLength(); if (evictExpiredElementsLength == 1) { final Element evictExpiredElement = (Element) evictExpiredElements.item(0); final String interval = evictExpiredElement.getAttribute(XSD_ATTRIBUTE__INTERVAL); List<CacheNameMatcher> cacheNameMatchers = parseEvictExpiredElement(evictExpiredElement); // get RuntimeBeanReference for cacheManager final RuntimeBeanReference cacheManagerReference = new RuntimeBeanReference( element.getAttribute(AnnotationDrivenEhCacheBeanDefinitionParser.XSD_ATTR__CACHE_MANAGER)); // make RootBeanDefinition, RuntimeBeanReference for ExpiredElementEvictor instance, wire cacheNameMatchers reference and final RootBeanDefinition expiredElementEvictor = new RootBeanDefinition(ExpiredElementEvictor.class); expiredElementEvictor.setSource(elementSource); expiredElementEvictor.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); final MutablePropertyValues propertyValues = expiredElementEvictor.getPropertyValues(); propertyValues.addPropertyValue("cacheManager", cacheManagerReference); propertyValues.addPropertyValue("cacheNameMatchers", cacheNameMatchers); propertyValues.addPropertyValue("interval", interval); // register expiredElementEvictor final BeanDefinitionRegistry registry = parserContext.getRegistry(); registry.registerBeanDefinition(EHCACHE_CONFIG_EVICTION_TASK_BEAN_NAME, expiredElementEvictor); } return null; }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRSubAwardBudget10_10V1_2Generator.java
/** * /*from w ww. j a va2 s.c o m*/ * This method is used to get RRBudget from BudgetSubAwards * * @param budgetSubAwards(BudgetSubAwards) budget sub awards entry. * @return RRBudget corresponding to the BudgetSubAwards object. */ private RRBudget10Document getRRBudget10(BudgetSubAwardsContract budgetSubAwards) { RRBudget10Document rrBudget = RRBudget10Document.Factory.newInstance(); String subAwdXML = budgetSubAwards.getSubAwardXmlFileData(); Document subAwdFormsDoc; try { subAwdFormsDoc = stringToDom(subAwdXML); } catch (S2SException e1) { return rrBudget; } Element subAwdFormsElement = subAwdFormsDoc.getDocumentElement(); NodeList subAwdNodeList = subAwdFormsElement.getElementsByTagNameNS(RR_BUDGET10_11_NAMESPACE_URI, RR_BUDGET10_11_LOCAL_NAME); Node subAwdNode = null; if (subAwdNodeList != null) { if (subAwdNodeList.getLength() == 0) { return null; } subAwdNode = subAwdNodeList.item(0); } byte[] subAwdNodeBytes = null; try { subAwdNodeBytes = docToBytes(nodeToDom(subAwdNode)); InputStream bgtIS = new ByteArrayInputStream(subAwdNodeBytes); rrBudget = (RRBudget10Document) XmlObject.Factory.parse(bgtIS); } catch (S2SException e) { return rrBudget; } catch (XmlException e) { return rrBudget; } catch (IOException e) { return rrBudget; } return rrBudget; }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRFedNonFedSubAwardBudgetV1_2Generator.java
/** * /*www .j a va 2 s . c o m*/ * This method is used to get RRFedNonFedBudget from BudgetSubAwards * * @param budgetSubAwards(BudgetSubAwards) budget sub awards entry. * @return RRFedNonFedBudget corresponding to the BudgetSubAwards object. */ private RRFedNonFedBudgetDocument getRRFedNonFedBudget(BudgetSubAwardsContract budgetSubAwards) { RRFedNonFedBudgetDocument rrBudget = RRFedNonFedBudgetDocument.Factory.newInstance(); String subAwdXML = budgetSubAwards.getSubAwardXmlFileData(); Document subAwdFormsDoc; try { subAwdFormsDoc = stringToDom(subAwdXML); } catch (S2SException e1) { return rrBudget; } Element subAwdFormsElement = subAwdFormsDoc.getDocumentElement(); NodeList subAwdNodeList = subAwdFormsElement.getElementsByTagNameNS(RR_FED_NON_FED_BUDGET_11_NAMESPACE_URI, LOCAL_FED_NON_FED_NAME); Node subAwdNode = null; if (subAwdNodeList != null) { if (subAwdNodeList.getLength() == 0) { return null; } subAwdNode = subAwdNodeList.item(0); } byte[] subAwdNodeBytes = null; try { subAwdNodeBytes = docToBytes(nodeToDom(subAwdNode)); InputStream bgtIS = new ByteArrayInputStream(subAwdNodeBytes); rrBudget = (RRFedNonFedBudgetDocument) XmlObject.Factory.parse(bgtIS); } catch (S2SException e) { return rrBudget; } catch (XmlException e) { return rrBudget; } catch (IOException e) { return rrBudget; } return rrBudget; }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRFedNonFedSubAwardBudget10_10V1_2Generator.java
/** * //from w ww . ja v a2 s .c o m * This method is used to get RRFedNonFedBudget from BudgetSubAwards * * @param budgetSubAwards(BudgetSubAwards) budget sub awards entry. * @return RRFedNonFedBudget corresponding to the BudgetSubAwards object. */ private RRFedNonFedBudget10Document getRRFedNonFedBudget(BudgetSubAwardsContract budgetSubAwards) { RRFedNonFedBudget10Document rrBudget = RRFedNonFedBudget10Document.Factory.newInstance(); String subAwdXML = budgetSubAwards.getSubAwardXmlFileData(); Document subAwdFormsDoc; try { subAwdFormsDoc = stringToDom(subAwdXML); } catch (S2SException e1) { return rrBudget; } Element subAwdFormsElement = subAwdFormsDoc.getDocumentElement(); NodeList subAwdNodeList = subAwdFormsElement .getElementsByTagNameNS(RR_FED_NON_FED_BUDGET10_11_NAMESPACE_URI, LOCAL_FED_NON_FED_NAME); Node subAwdNode = null; if (subAwdNodeList != null) { if (subAwdNodeList.getLength() == 0) { return null; } subAwdNode = subAwdNodeList.item(0); } byte[] subAwdNodeBytes = null; try { subAwdNodeBytes = docToBytes(nodeToDom(subAwdNode)); InputStream bgtIS = new ByteArrayInputStream(subAwdNodeBytes); rrBudget = (RRFedNonFedBudget10Document) XmlObject.Factory.parse(bgtIS); } catch (S2SException e) { return rrBudget; } catch (XmlException e) { return rrBudget; } catch (IOException e) { return rrBudget; } return rrBudget; }