List of usage examples for javax.xml.stream XMLInputFactory IS_COALESCING
String IS_COALESCING
To view the source code for javax.xml.stream XMLInputFactory IS_COALESCING.
Click Source Link
From source file:EntityReferenceTest.java
public static void main(String[] args) throws Exception { XMLInputFactory inputFactory = XMLInputFactory.newInstance(); inputFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE); inputFactory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.TRUE); XMLStreamReader reader = inputFactory.createXMLStreamReader(new FileInputStream("e.xml")); while (reader.hasNext()) { int event = reader.next(); if (event == XMLStreamConstants.CHARACTERS) System.out.println(reader.getText()); else if (event == XMLStreamConstants.ENTITY_REFERENCE) { System.out.println("en: " + reader.getLocalName()); System.out.println("er: " + reader.getText()); }/*from w ww .jav a 2 s. com*/ } inputFactory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.FALSE); reader = inputFactory.createXMLStreamReader(new FileInputStream("e.xml")); while (reader.hasNext()) { int event = reader.next(); if (event == XMLStreamConstants.CHARACTERS) System.out.println(reader.getText()); else if (event == XMLStreamConstants.ENTITY_REFERENCE) { System.out.println("en: " + reader.getLocalName()); System.out.println("er: " + reader.getText()); } } }
From source file:StaxCursorTest.java
public static void main(String[] args) throws Exception { String filename = "yourXML.xml"; XMLInputFactory xmlif = null; xmlif = XMLInputFactory.newInstance(); xmlif.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.TRUE); xmlif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE); xmlif.setProperty(XMLInputFactory.IS_COALESCING, Boolean.FALSE); try {/*w ww. ja va 2s . co m*/ XMLStreamReader xmlr = xmlif.createXMLStreamReader(filename, new FileInputStream(filename)); int eventType = xmlr.getEventType(); printStartDocument(xmlr); while (xmlr.hasNext()) { eventType = xmlr.next(); printStartElement(xmlr); printEndElement(xmlr); printText(xmlr); printPIData(xmlr); printComment(xmlr); } } catch (XMLStreamException ex) { System.out.println(ex.getMessage()); if (ex.getNestedException() != null) { ex.getNestedException().printStackTrace(); } } }
From source file:Main.java
public static void main(String[] args) throws Exception { String filename = "yourXML.xml"; XMLInputFactory xmlif = null; xmlif = XMLInputFactory.newInstance(); xmlif.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.TRUE); xmlif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE); xmlif.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.TRUE); xmlif.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE); System.out.println("FACTORY: " + xmlif); System.out.println("filename = " + filename); FileInputStream fis = new FileInputStream(filename); XMLStreamReader xmlr = xmlif.createFilteredReader(xmlif.createXMLStreamReader(fis), new MyFilter()); int eventType = xmlr.getEventType(); printEventType(eventType);/* w w w . j a v a 2s .co m*/ while (xmlr.hasNext()) { eventType = xmlr.next(); printEventType(eventType); printName(xmlr, eventType); printText(xmlr); if (xmlr.isStartElement()) { printAttributes(xmlr); } printPIData(xmlr); } }
From source file:Main.java
public static void main(String[] args) throws Exception { String filename = "yourXML.xml"; XMLInputFactory xmlif = null; xmlif = XMLInputFactory.newInstance(); xmlif.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.TRUE); xmlif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE); xmlif.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.TRUE); xmlif.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE); System.out.println("FACTORY: " + xmlif); System.out.println("filename = " + filename); FileInputStream fis = new FileInputStream(filename); XMLStreamReader xmlr = xmlif.createFilteredReader(xmlif.createXMLStreamReader(fis), new Main()); int eventType = xmlr.getEventType(); printEventType(eventType);//w w w.j av a2 s .com while (xmlr.hasNext()) { eventType = xmlr.next(); printEventType(eventType); printName(xmlr, eventType); printText(xmlr); if (xmlr.isStartElement()) { printAttributes(xmlr); } printPIData(xmlr); } }
From source file:MyStreamFilter.java
public static void main(String[] args) throws Exception { String filename = "yourXML.xml"; XMLInputFactory xmlif = null; xmlif = XMLInputFactory.newInstance(); xmlif.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.TRUE); xmlif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE); xmlif.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.TRUE); xmlif.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE); System.out.println("FACTORY: " + xmlif); System.out.println("filename = " + filename); FileInputStream fis = new FileInputStream(filename); XMLStreamReader xmlr = xmlif.createFilteredReader(xmlif.createXMLStreamReader(fis), new MyStreamFilter()); int eventType = xmlr.getEventType(); printEventType(eventType);// w ww. ja va2 s .c o m while (xmlr.hasNext()) { eventType = xmlr.next(); printEventType(eventType); printName(xmlr, eventType); printText(xmlr); if (xmlr.isStartElement()) { printAttributes(xmlr); } printPIData(xmlr); } }
From source file:Main.java
/** * Build a new XMLInputFactory./*from w w w . ja v a 2s.c o m*/ * * @return XML input factory */ public static XMLInputFactory getXmlInputFactory() { XMLInputFactory inputFactory = XMLInputFactory.newInstance(); inputFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE); inputFactory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.TRUE); return inputFactory; }
From source file:Main.java
protected static synchronized void initializeXMLInputFactory() { if (xmlInputFactory == null) { xmlInputFactory = XMLInputFactory.newInstance(); xmlInputFactory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.FALSE); xmlInputFactory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE); xmlInputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE); // This disables DTDs entirely for that factory xmlInputFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.FALSE); }/* www .j ava 2 s . com*/ }
From source file:eu.arthepsy.sonar.plugins.scapegoat.util.XmlUtils.java
public static SMInputFactory createFactory() { XMLInputFactory xmlFactory = XMLInputFactory.newInstance(); xmlFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE); xmlFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE); xmlFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE); xmlFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE); xmlFactory.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.FALSE); SMInputFactory inputFactory = new SMInputFactory(xmlFactory); return inputFactory; }
From source file:Main.java
private static XMLEventReader getXMLEventReader(String filename) throws Exception { XMLInputFactory xmlif = null; XMLEventReader xmlr = null;//from ww w .ja v a2 s. c o m xmlif = XMLInputFactory.newInstance(); xmlif.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.TRUE); xmlif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE); xmlif.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.TRUE); xmlif.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE); FileInputStream fis = new FileInputStream(filename); xmlr = xmlif.createXMLEventReader(filename, fis); return xmlr; }
From source file:com.autonomy.aci.client.services.impl.AbstractStAXProcessorTest.java
@After public void tearDown() { System.clearProperty(XMLInputFactory.IS_NAMESPACE_AWARE); System.clearProperty(XMLInputFactory.IS_VALIDATING); System.clearProperty(XMLInputFactory.IS_COALESCING); System.clearProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES); System.clearProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES); System.clearProperty(XMLInputFactory.SUPPORT_DTD); }