Exemplo n.º 1
0
        public void TestSchemaParsing()
        {
            var parser = new SchemaParser(@"TODO FILENAME");

            parser.Parse();
            int i = 0;
        }
Exemplo n.º 2
0
        private static async Task <BebopSchema> ParseAndValidateSchemas(List <string> schemaPaths, string nameSpace)
        {
            var parser = new SchemaParser(schemaPaths, nameSpace);
            var schema = await parser.Parse();

            schema.Validate();
            return(schema);
        }
Exemplo n.º 3
0
        private static async Task <int> CheckSchema(string textualSchema)
        {
            var parser = new SchemaParser(textualSchema, "CheckNameSpace");
            var schema = await parser.Parse();

            schema.Validate();
            return(await ReportSchemaDiagnostics(schema));
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            var dfdl = @"d:\dfdltests\dfdl.xsd";
            var feed = @"d:\dfdltests\sampleinput2.txt";

            var parser = new SchemaParser(dfdl);


            parser.Parse(feed);
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            var dfdl = @"d:\dfdltests\dfdl.xsd";
            var feed = @"d:\dfdltests\sampleinput2.txt";

            var parser = new SchemaParser(dfdl);


            parser.Parse(feed);
        }
Exemplo n.º 6
0
        public TKTClassModel ShowClass(FileInfo fi)
        {
            string        code     = File.ReadAllText(fi.FullName);
            var           tokens   = scanner.Scan(code);
            TKTClassModel tktclass = parser.Parse(tokens);

            if (tktclass.NameModel == null)
            {
                tktclass.NameModel = new TKTContentModel()
                {
                    Content = Path.GetFileName(fi.FullName)
                };
            }
            ShowClass(tktclass);
            return(tktclass);
        }
Exemplo n.º 7
0
        private static async Task <int> CheckSchema(string textualSchema)
        {
            try
            {
                var parser = new SchemaParser(textualSchema, "CheckNameSpace");
                var schema = await parser.Parse();

                schema.Validate();
                if (schema.Errors.Count > 0)
                {
                    await Log.WriteSpanErrors(schema.Errors);

                    return(Err);
                }
                return(Ok);
            }
            catch (Exception e)
            {
                await ReportError(e);

                return(Err);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Method cross references two schema files to search for commonalities and verifies if those
        /// commonolities contains no differences
        /// </summary>
        /// <param name="schemaFileNameSource">filename of source</param>
        /// <param name="schemaFileNameTarget">filename of target</param>
        /// <param name="options">command line options</param>
        /// <returns>List<IReportItem></returns>
        public virtual List <IReportItem> XReference(string schemaFileNameSource, string schemaFileNameTarget)
        {
            var xmlFileReader = new XmlFileReader();
            var items         = new List <IReportItem>();

            var xmlSourceSchema = xmlFileReader.Read(schemaFileNameSource);
            var xmlTargetSchema = xmlFileReader.Read(schemaFileNameTarget);

            if (xmlSourceSchema.HasChildNodes && xmlTargetSchema.HasChildNodes)
            {
                XmlNamespaceManager xsdNsmgr = new XmlNamespaceManager(xmlSourceSchema.NameTable);
                xsdNsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema");

                var xmlSourceSchemas = new List <XmlDocument>()
                {
                    xmlSourceSchema
                };
                var includedSchemaNodeList =
                    xmlSourceSchema.LastChild.SelectNodes("xs:include", xsdNsmgr);

                if (includedSchemaNodeList != null && includedSchemaNodeList.Count > 0)
                {
                    foreach (XmlNode includedSchemaNode in includedSchemaNodeList)
                    {
                        if (includedSchemaNode.Attributes != null &&
                            includedSchemaNode.Attributes.Count > 0)
                        {
                            XmlAttribute attribute = FindAttributeByName(includedSchemaNode.Attributes, "schemaLocation");
                            if (attribute != null)
                            {
                                string includedSchemaFileName = attribute.InnerText;
                                var    includedXmlSchema      = xmlFileReader.Read(includedSchemaFileName);
                                xmlSourceSchemas.Add(includedXmlSchema);
                            }
                        }
                    }
                }

                var xmlTargetSchemas = new List <XmlDocument>()
                {
                    xmlTargetSchema
                };
                includedSchemaNodeList =
                    xmlTargetSchema.LastChild.SelectNodes("xs:include", xsdNsmgr);

                if (includedSchemaNodeList != null && includedSchemaNodeList.Count > 0)
                {
                    foreach (XmlNode includedSchemaNode in includedSchemaNodeList)
                    {
                        if (includedSchemaNode.Attributes != null &&
                            includedSchemaNode.Attributes.Count > 0)
                        {
                            XmlAttribute attribute = FindAttributeByName(includedSchemaNode.Attributes, "schemaLocation");
                            if (attribute != null)
                            {
                                string includedSchemaFileName = attribute.InnerText;
                                var    includedXmlSchema      = xmlFileReader.Read(includedSchemaFileName);
                                xmlTargetSchemas.Add(includedXmlSchema);
                            }
                        }
                    }
                }

                var schemaParser = new SchemaParser();
                items.AddRange(schemaParser.Parse(xmlSourceSchemas.ToArray(), xmlTargetSchemas.ToArray()));
            }

            int issues =
                items.FindAll(itm => itm.Level != Enumerations.Level.Info && itm.Chapter == 0).Count;

            if (issues != 0)
            {
                items.Add(new ReportItem
                {
                    Level     = Enumerations.Level.Info,
                    Message   = $"Cross referencing source- and target XMLSchema results in {issues} issue{(issues == 1 ? "" : "s")}",
                    TimeStamp = DateTime.Now,
                    Type      = Enumerations.Type.Info
                });
            }

            return(items);
        }