public static DefaultHighlightingStrategy Parse(SyntaxMode syntaxMode, XmlTextReader xmlTextReader)
        {
            try {
                XmlValidatingReader validatingReader = new XmlValidatingReader(xmlTextReader);
                Stream shemaStream = Assembly.GetCallingAssembly().GetManifestResourceStream("Mode.xsd");
                validatingReader.Schemas.Add("", new XmlTextReader(shemaStream));
                validatingReader.ValidationType = ValidationType.Schema;
                validatingReader.ValidationEventHandler += new ValidationEventHandler (ValidationHandler);

                XmlDocument doc = new XmlDocument();
                doc.Load(validatingReader);

                DefaultHighlightingStrategy highlighter = new DefaultHighlightingStrategy(doc.DocumentElement.Attributes["name"].InnerText);

                if (doc.DocumentElement.Attributes["extensions"]!= null) {
                    highlighter.Extensions = doc.DocumentElement.Attributes["extensions"].InnerText.Split(new char[] { ';', '|' });
                }
                /*
                if (doc.DocumentElement.Attributes["indent"]!= null) {
                    highlighter.DoIndent = Boolean.Parse(doc.DocumentElement.Attributes["indent"].InnerText);
                }
                */
                XmlElement environment = doc.DocumentElement["Environment"];

                highlighter.SetDefaultColor(new HighlightBackground(environment["Default"]));

                foreach (string aColorName in environmentColors) {
                    highlighter.SetColorFor(aColorName, new HighlightColor(environment[aColorName]));
                }

                // parse properties
                if (doc.DocumentElement["Properties"]!= null) {
                    foreach (XmlElement propertyElement in doc.DocumentElement["Properties"].ChildNodes) {
                        highlighter.Properties[propertyElement.Attributes["name"].InnerText] =  propertyElement.Attributes["value"].InnerText;
                    }
                }

                if (doc.DocumentElement["Digits"]!= null) {
                    highlighter.SetColorFor("Digits", new HighlightColor(doc.DocumentElement["Digits"]));
                }

                XmlNodeList nodes = doc.DocumentElement.GetElementsByTagName("RuleSet");
                foreach (XmlElement element in nodes) {
                    highlighter.AddRuleSet(new HighlightRuleSet(element));
                }

                xmlTextReader.Close();

                if(errors!=null) {
                    ReportErrors(syntaxMode.FileName);
                    errors = null;
                    return null;
                } else {
                    return highlighter;
                }
            } catch (Exception) {
                //MessageBox.Show("Could not load mode definition file.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                return null;
            }
        }
 public XmlTextReader GetSyntaxModeFile(SyntaxMode syntaxMode)
 {
     string syntaxModeFile = Path.Combine(directory, syntaxMode.FileName);
     if (!File.Exists(syntaxModeFile)) {
         //MessageBox.Show("Can't load highlighting definition " + syntaxModeFile + " (file not found)!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
         return null;
     }
     return new XmlTextReader(File.OpenRead(syntaxModeFile));
 }
 public XmlTextReader GetSyntaxModeFile(SyntaxMode syntaxMode)
 {
     Assembly assembly = typeof(SyntaxMode).Assembly;
     return new XmlTextReader(assembly.GetManifestResourceStream(syntaxMode.FileName));
 }