Esempio n. 1
0
        //-------------------------------------------------------------------------
        // creates the XML input factory, recreated each time to avoid JDK-8028111
        // this also provides some protection against hackers attacking XML
        private static XMLInputFactory xmlInputFactory()
        {
            // see https://bugs.openjdk.java.net/browse/JDK-8183519 where JDK deprecated the wrong method
            // to avoid a warning on 9 this code uses newInstance() even though newFactory() is more correct
            // there is no difference in behavior between the two methods
            XMLInputFactory factory = XMLInputFactory.newInstance();

            factory.setProperty(XMLInputFactory.IS_COALESCING, true);
            factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, true);
            factory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
            factory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
            return(factory);
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void open(java.io.InputStreamReader isr) throws org.maltparser.core.exception.MaltChainedException
        private void open(StreamReader isr)
        {
            try
            {
                XMLInputFactory factory = XMLInputFactory.newInstance();
                Reader = factory.createXMLStreamReader(new StreamReader(isr));
            }
            catch (XMLStreamException e)
            {
                throw new DataFormatException("XML input file could be opened. ", e);
            }
            SentenceCount = 0;
        }