public ComponentTemplate ParseComponentTemplate(SourceCodeInfo sourceInfo)
        {
            if (sourceInfo == null)
            {
                throw new ArgumentNullException(nameof(sourceInfo));
            }

            var xml = new XmlDocument();

            try
            {
                using (var stream = sourceInfo.GetStream())
                    xml.Load(stream);
            }
            catch (XmlException ex)
            {
                throw new AGPxException(ex.Message);
            }

            if (xml.DocumentElement.Name != componentTemplateTag)
            {
                throw new AGPxException($"All elements must be inserted into root element '{componentTemplateTag}'!");
            }

            var namespaces = ParseNamespaces(xml);

            var componentName = xml.DocumentElement.Attributes["Name"];

            if (componentName == null)
            {
                throw new AGPxException($"'{componentTemplateTag}' must have 'Name' attribute!");
            }

            var rootComponentType = componentTypeResolver.FindComponentType(componentName.Value, namespaces);
            var rootTemplate      = new ComponentTemplate(null, componentName.Value, rootComponentType);

            foreach (XmlNode node in xml.DocumentElement.ChildNodes)
            {
                rootTemplate.Templates.Add(ParseNode(rootTemplate, "default", node, namespaces));
            }

            return(rootTemplate);
        }
        public void ParseInto(DssInstructions dssInstructions, SourceCodeInfo sourceInfo)
        {
            if (sourceInfo == null)
            {
                throw new ArgumentNullException(nameof(sourceInfo));
            }

            Internal.DssLexer lexer;
            using (var stream = sourceInfo.GetStream())
                lexer = new Internal.DssLexer(new AntlrInputStream(stream));

            var tokens = new CommonTokenStream(lexer);
            var parser = new Internal.DssParser(tokens);

            var errorListener = new ErrorListener(sourceInfo.SourceName);

            //parser.RemoveErrorListeners();
            parser.AddErrorListener(errorListener);

            var listener = new StylesheetListener(sourceInfo.SourceName, dssInstructions);

            listener.EnterStylesheet(parser.stylesheet());
        }