private void CreateDTDAttributesForElement(DTDElement element) { element.Attribute = new List <DTDAttribut>(); Match match1 = new Regex("(?<attributliste><!ATTLIST " + element.Name + "[\\t\\r\\n ]+(?<attribute>[^>]+?)[\\t\\r\\n ]?>)").Match(this._workingInhalt); if (!match1.Success) { return; } string input = match1.Groups["attribute"].Value; Match match2 = new Regex("[\\t\\r\\n ]?(?<name>[\\w-_]+)[\\t\\r\\n ]+(?<typ>CDATA|ID|IDREF|IDREFS|NMTOKEN|NMTOKENS|ENTITY|ENTITIES|NOTATION|xml:|[(][|\\w-_ \\t\\r\\n]+[)])[\\t\\r\\n ]+(?:(?<anzahl>#REQUIRED|#IMPLIED|#FIXED)[\\t\\r\\n ]+)?(?:\"(?<vorgabewert>[\\w-_]+)\")?[\\t\\r\\n ]?").Match(input); if (!match2.Success) { throw new ApplicationException(string.Format(ResReader.Reader.GetString("KeineAttributeInAttributListe"), (object)input)); } char[] charArray = "|".ToCharArray(); for (; match2.Success; match2 = match2.NextMatch()) { DTDAttribut dtdAttribut = new DTDAttribut(); dtdAttribut.Name = match2.Groups["name"].Value; dtdAttribut.StandardWert = match2.Groups["vorgabewert"].Value; string str1 = match2.Groups["anzahl"].Value; if (!(str1 == "#REQUIRED")) { if (!(str1 == "#IMPLIED") && (str1 == null || str1.Length != 0)) { if (!(str1 == "#FIXED")) { throw new ApplicationException(string.Format(ResReader.Reader.GetString("UnbekannteAttributAnzahl"), (object)match2.Groups["anzahl"].Value, (object)match2.Value, (object)element.Name)); } dtdAttribut.Pflicht = DTDAttribut.PflichtArten.Konstante; } else { dtdAttribut.Pflicht = DTDAttribut.PflichtArten.Optional; } } else { dtdAttribut.Pflicht = DTDAttribut.PflichtArten.Pflicht; } string str2 = match2.Groups["typ"].Value.Trim(); if (str2.StartsWith("(")) { dtdAttribut.Typ = ""; foreach (string str3 in str2.Replace("(", "").Replace(")", "").Replace(")", "").Split(charArray)) { string str4 = str3.Replace("\n", " ").Trim(); dtdAttribut.ErlaubteWerte.Add(str4); } } else { dtdAttribut.Typ = str2; } element.Attribute.Add(dtdAttribut); } }
private void CreateDTDAttributesForElement(DTDElement element) { element.Attribute = new List <DTDAttribut>(); string pattern = "(?<attributliste><!ATTLIST " + element.Name + "[\\t\\r\\n ]+(?<attribute>[^>]+?)[\\t\\r\\n ]?>)"; Regex regex = new Regex(pattern); Match match = regex.Match(this._workingInhalt); if (!match.Success) { return; } string value = match.Groups["attribute"].Value; string pattern2 = "[\\t\\r\\n ]?(?<name>[\\w-_]+)[\\t\\r\\n ]+(?<typ>CDATA|ID|IDREF|IDREFS|NMTOKEN|NMTOKENS|ENTITY|ENTITIES|NOTATION|xml:|[(][|\\w-_ \\t\\r\\n]+[)])[\\t\\r\\n ]+(?:(?<anzahl>#REQUIRED|#IMPLIED|#FIXED)[\\t\\r\\n ]+)?(?:\"(?<vorgabewert>[\\w-_]+)\")?[\\t\\r\\n ]?"; Regex regex2 = new Regex(pattern2); match = regex2.Match(value); if (match.Success) { string text = "|"; char[] separator = text.ToCharArray(); while (match.Success) { DTDAttribut dTDAttribut = new DTDAttribut(); dTDAttribut.Name = match.Groups["name"].Value; dTDAttribut.StandardWert = match.Groups["vorgabewert"].Value; string value2 = match.Groups["anzahl"].Value; switch (value2) { default: if (value2.Length != 0) { goto case null; } goto case "#IMPLIED"; case null: if (value2 == "#FIXED") { dTDAttribut.Pflicht = DTDAttribut.PflichtArten.Konstante; break; } throw new ApplicationException(string.Format(ResReader.Reader.GetString("UnbekannteAttributAnzahl"), match.Groups["anzahl"].Value, match.Value, element.Name)); case "#REQUIRED": dTDAttribut.Pflicht = DTDAttribut.PflichtArten.Pflicht; break; case "#IMPLIED": dTDAttribut.Pflicht = DTDAttribut.PflichtArten.Optional; break; } string value3 = match.Groups["typ"].Value; value3 = value3.Trim(); if (value3.StartsWith("(")) { dTDAttribut.Typ = ""; value3 = value3.Replace("(", ""); value3 = value3.Replace(")", ""); value3 = value3.Replace(")", ""); string[] array = value3.Split(separator); string[] array2 = array; foreach (string text2 in array2) { string text3 = text2.Replace("\n", " "); text3 = text3.Trim(); dTDAttribut.ErlaubteWerte.Add(text3); } } else { dTDAttribut.Typ = value3; } element.Attribute.Add(dTDAttribut); match = match.NextMatch(); } return; } throw new ApplicationException(string.Format(ResReader.Reader.GetString("KeineAttributeInAttributListe"), value)); }