Beispiel #1
0
        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);
        }
 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());
        }
        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);
        }
Beispiel #5
0
 /// <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);
     }
 }
Beispiel #6
0
        // 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);
            }
        }