/** * Processes the given sheet */ public void ProcessSheet( SheetContentsHandler sheetContentsExtractor, StylesTable styles, ReadOnlySharedStringsTable strings, InputStream sheetInputStream) { DataFormatter formatter; if (locale == null) { formatter = new DataFormatter(); } else { formatter = new DataFormatter(locale); } InputSource sheetSource = new InputSource(sheetInputStream); SAXParserFactory saxFactory = SAXParserFactory.newInstance(); try { SAXParser saxParser = saxFactory.newSAXParser(); XMLReader sheetParser = saxParser.GetXMLReader(); ContentHandler handler = new XSSFSheetXMLHandler( styles, strings, sheetContentsExtractor, formatter, formulasNotResults); sheetParser.SetContentHandler(handler); sheetParser.Parse(sheetSource); } catch (ParserConfigurationException e) { throw new RuntimeException("SAX Parser appears to be broken - " + e.GetMessage()); } }
public virtual Parse execute() { try { Stream inputStream = streamSource.InputStream; parser.SaxParserFactory.setFeature(XXE_PROCESSING, enableXxeProcessing); if (string.ReferenceEquals(schemaResource, null)) { // must be done before parser is created parser.SaxParserFactory.NamespaceAware = false; parser.SaxParserFactory.Validating = false; } SAXParser saxParser = parser.SaxParser; if (!string.ReferenceEquals(schemaResource, null)) { saxParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA); saxParser.setProperty(JAXP_SCHEMA_SOURCE, schemaResource); } saxParser.parse(inputStream, new ParseHandler(this)); } catch (Exception e) { throw LOG.parsingFailureException(name_Renamed, e); } return(this); }
public TransformXML() { try { saxParser = SAXParserFactory.NewInstance().NewSAXParser(); } catch (Exception e) { log.Info("Error configuring XML parser: " + e); throw new Exception(e); } }
public virtual void TestPBImageXmlWriter() { ByteArrayOutputStream output = new ByteArrayOutputStream(); TextWriter o = new TextWriter(output); PBImageXmlWriter v = new PBImageXmlWriter(new Configuration(), o); v.Visit(new RandomAccessFile(originalFsimage, "r")); SAXParserFactory spf = SAXParserFactory.NewInstance(); SAXParser parser = spf.NewSAXParser(); string xml = output.ToString(); parser.Parse(new InputSource(new StringReader(xml)), new DefaultHandler()); }
protected internal ConstitParseSampleStream(ObjectStream <sbyte[]> samples) : base(samples) { SAXParserFactory factory = SAXParserFactory.newInstance(); try { saxParser = factory.newSAXParser(); } catch (ParserConfigurationException e) { throw new IllegalStateException(e); } catch (SAXException e) { throw new IllegalStateException(e); } }
/// <summary>Creates a new instance of XmlRecordInput</summary> public XmlRecordInput(InputStream @in) { try { valList = new AList <XmlRecordInput.Value>(); DefaultHandler handler = new XmlRecordInput.XMLParser(valList); SAXParserFactory factory = SAXParserFactory.NewInstance(); SAXParser parser = factory.NewSAXParser(); parser.Parse(@in, handler); vLen = valList.Count; vIdx = 0; } catch (Exception ex) { throw new RuntimeException(ex); } }
// In this mode, it runs the command and compares the actual output // with the expected output // Run the tests // If it is set to nocompare, run the command and do not compare. // This can be useful populate the testConfig.xml file the first time // a new command is added //By default, run the tests. The other mode is to run the commands and not // compare the output // Storage for tests read in from the config file /// <summary>Read the test config file - testConfig.xml</summary> protected internal virtual void ReadTestConfigFile() { string testConfigFile = GetTestFile(); if (testsFromConfigFile == null) { bool success = false; testConfigFile = TestCacheDataDir + FilePath.separator + testConfigFile; try { SAXParser p = (SAXParserFactory.NewInstance()).NewSAXParser(); p.Parse(testConfigFile, GetConfigParser()); success = true; } catch (Exception) { Log.Info("File: " + testConfigFile + " not found"); success = false; } Assert.True("Error reading test config file", success); } }