/** * 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()); } }
private List <string> ParsedPathList(string rawXml) { List <string> pathList = null; _vectorStringData = rawXml; var br = new BufferedReader(new StringReader(_vectorStringData)); var is1 = new InputSource(br); try { var parser = new XmlParser(); var factory = SAXParserFactory.NewInstance(); var sp = factory.NewSAXParser(); var reader = sp.XMLReader; reader.ContentHandler = parser; reader.Parse(is1); pathList = parser.List; } catch (Exception ex) { Log.Debug("XML Parser Exception", ex.ToString()); } return(pathList); }
protected internal virtual void loadXML() { try { try { try { SAXParserFactory saxparserFactory = SAXParserFactory.newInstance(); XMLReader xmlreader = saxparserFactory.newSAXParser().getXMLReader(); this.rules = new HashMap(); GrXMLHandler grXMLHandler = new GrXMLHandler(this.baseURL, this.rules, this.logger); xmlreader.setContentHandler(grXMLHandler); xmlreader.setErrorHandler(grXMLHandler); InputStream inputStream = this.baseURL.openStream(); xmlreader.parse(new InputSource(inputStream)); inputStream.close(); } catch (SAXParseException ex) { throw new IOException(new StringBuilder().append("Error while parsing line ").append(ex.getLineNumber()).append(" of ").append(this.baseURL).append(": ").append(ex.getMessage()).toString()); } } catch (SAXException ex3) { throw new IOException(new StringBuilder().append("Problem with XML: ").append(ex3).toString()); } } catch (ParserConfigurationException ex5) { throw new IOException(Throwable.instancehelper_getMessage(ex5)); } }
public virtual Map load() { try { try { try { SAXParserFactory saxparserFactory = SAXParserFactory.newInstance(); XMLReader xmlreader = saxparserFactory.newSAXParser().getXMLReader(); ConfigHandler contentHandler = new ConfigHandler(this.rpdMap, this.globalProperties, this.replaceDuplicates, this.url); xmlreader.setContentHandler(contentHandler); xmlreader.parse(this.url.toString()); } catch (SAXParseException ex) { throw new IOException(new StringBuilder().append("Error while parsing line ").append(ex.getLineNumber()).append(" of ").append(this.url).append(": ").append(ex.getMessage()).toString()); } } catch (SAXException ex3) { throw new IOException(new StringBuilder().append("Problem with XML: ").append(ex3).toString()); } } catch (ParserConfigurationException ex5) { throw new IOException(Throwable.instancehelper_getMessage(ex5)); } return(this.rpdMap); }
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()); }
/// <summary> /// Creates a SAX parser using JAXP /// </summary> /// <returns> the created SAX parser </returns> internal static XMLReader createParser() { try { SAXParserFactory factory = SAXParserFactory.newInstance(); factory.NamespaceAware = true; return(factory.newSAXParser().XMLReader); } catch (Exception e) { throw new Exception("Couldn't create XMLReader: " + e.Message); } }
static Dictionary <string, QuestionGroup> GetQuestionGroups(Context context) { var qStream = context.Assets.Open("Questions.xml"); var spf = SAXParserFactory.NewInstance(); var sp = spf.NewSAXParser(); var xr = sp.XMLReader; var questionsXmlHandler = new QuestionsXmlHandler(); xr.ContentHandler = questionsXmlHandler; var inStream = new InputSource(qStream); xr.Parse(inStream); return(questionsXmlHandler.QuestionGroups); }
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); } }