List of usage examples for javax.xml.stream XMLInputFactory SUPPORT_DTD
String SUPPORT_DTD
To view the source code for javax.xml.stream XMLInputFactory SUPPORT_DTD.
Click Source Link
From source file:uk.ac.ebi.metabolomes.webservices.eutils.ESummaryXMLResponseParser.java
/** * Parses the whole ESummaryResult XML object, delivering a List of ESummaryResults. * // w w w. j a va 2 s .c o m * @param in the input stream through which the response the response can be read. * @return multimap with the mappings from the XML. * @throws javax.xml.stream.XMLStreamException */ public List<T> parseESummaryResult(InputStream in) throws XMLStreamException { XMLInputFactory2 xmlif = (XMLInputFactory2) XMLInputFactory2.newInstance(); xmlif.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.FALSE); xmlif.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE); xmlif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.TRUE); xmlif.setProperty(XMLInputFactory.IS_COALESCING, Boolean.FALSE); xmlif.configureForSpeed(); XMLStreamReader2 xmlr = (XMLStreamReader2) xmlif.createXMLStreamReader(in); int event; List<T> results = new ArrayList<T>(); T currentResult = getNewESummaryResult(); while (xmlr.hasNext()) { event = xmlr.next(); switch1: switch (event) { case XMLEvent.START_DOCUMENT: break; case XMLEvent.START_ELEMENT: //LOGGER.info("Start Element: "+xmlr.getLocalName()); //LOGGER.info("Attributes: "+getAttributes(xmlr)); if (xmlr.getLocalName().equalsIgnoreCase("Item")) { boolean done = false; for (Enum keyword : currentResult.getScalarKeywords()) { if (hasAttributeNameWithValue(xmlr, keyword.toString())) { //LOGGER.info("Entering addScalarForKeyword: "+keyword.toString()+" for "+xmlr.getLocalName()); currentResult.addScalarForKeyword(keyword, getFollowingCharacters(xmlr)); break switch1; } } for (Enum keyword : currentResult.getListKeywords()) { if (hasAttributeNameWithValue(xmlr, keyword.toString())) { //LOGGER.info("Entering addListForKeyword: "+keyword.toString()+" for "+xmlr.getLocalName()); currentResult.addListForKeyword(keyword, parseList(xmlr)); break switch1; } } } if (xmlr.getLocalName().equalsIgnoreCase("Id")) { for (Enum keyword : currentResult.getScalarKeywords()) { if (keyword.toString().equalsIgnoreCase("Id")) { currentResult.addScalarForKeyword(keyword, getFollowingCharacters(xmlr)); break switch1; } } } /* if (xmlr.getLocalName().equalsIgnoreCase("Item") && hasAttributeNameWithValue(xmlr, "SID")) { currentResult.setId(getFollowingCharacters(xmlr)); } else if (xmlr.getLocalName().equalsIgnoreCase("Item") && hasAttributeNameWithValue(xmlr, "SourceNameList")) { currentResult.setSourceNames(parseList(xmlr)); } else if (xmlr.getLocalName().equalsIgnoreCase("Item") && hasAttributeNameWithValue(xmlr, "SourceID")) { currentResult.addSourceID(getFollowingCharacters(xmlr)); } else if (xmlr.getLocalName().equalsIgnoreCase("Item") && hasAttributeNameWithValue(xmlr, "DBUrl")) { currentResult.setDBUrl(getFollowingCharacters(xmlr)); } else if (xmlr.getLocalName().equalsIgnoreCase("Item") && hasAttributeNameWithValue(xmlr, "SynonymList")) { currentResult.setSynonyms(parseList(xmlr)); }*/ break; case XMLEvent.END_ELEMENT: //LOGGER.info("End Element: "+xmlr.getLocalName()); if (xmlr.getLocalName().equalsIgnoreCase("DocSum")) { currentResult.wrap(); results.add(currentResult); currentResult = getNewESummaryResult(); } break; } } xmlr.closeCompletely(); return results; }