System.Xml.DTDReader.ReadAttributeDefinition C# (CSharp) Méthode

ReadAttributeDefinition() private méthode

private ReadAttributeDefinition ( ) : DTDAttributeDefinition
Résultat DTDAttributeDefinition
		private DTDAttributeDefinition ReadAttributeDefinition ()
		{
#if NET_2_1_HACK
			throw new NotImplementedException ();
#else
			DTDAttributeDefinition def = new DTDAttributeDefinition (DTD);
			def.IsInternalSubset = this.processingInternalSubset;

			// attr_name
			TryExpandPERef ();
			def.Name = ReadName ();
			if (!SkipWhitespace ())
				throw NotWFError ("Whitespace is required between name and content in DTD attribute definition.");

			// attr_value
			TryExpandPERef ();
			switch(PeekChar ()) {
			case 'C':	// CDATA
				Expect ("CDATA");
				def.Datatype = XmlSchemaDatatype.FromName ("normalizedString", XmlSchema.Namespace);
				break;
			case 'I':	// ID, IDREF, IDREFS
				Expect ("ID");
				if(PeekChar () == 'R') {
					Expect ("REF");
					if(PeekChar () == 'S') {
						// IDREFS
						ReadChar ();
						def.Datatype = XmlSchemaDatatype.FromName ("IDREFS", XmlSchema.Namespace);
					}
					else	// IDREF
						def.Datatype = XmlSchemaDatatype.FromName ("IDREF", XmlSchema.Namespace);
				}
				else	// ID
					def.Datatype = XmlSchemaDatatype.FromName ("ID", XmlSchema.Namespace);
				break;
			case 'E':	// ENTITY, ENTITIES
				Expect ("ENTIT");
				switch(ReadChar ()) {
					case 'Y':	// ENTITY
						def.Datatype = XmlSchemaDatatype.FromName ("ENTITY", XmlSchema.Namespace);
						break;
					case 'I':	// ENTITIES
						Expect ("ES");
						def.Datatype = XmlSchemaDatatype.FromName ("ENTITIES", XmlSchema.Namespace);
						break;
				}
				break;
			case 'N':	// NMTOKEN, NMTOKENS, NOTATION
				ReadChar ();
				switch(PeekChar ()) {
				case 'M':
					Expect ("MTOKEN");
					if(PeekChar ()=='S') {	// NMTOKENS
						ReadChar ();
						def.Datatype = XmlSchemaDatatype.FromName ("NMTOKENS", XmlSchema.Namespace);
					}
					else	// NMTOKEN
						def.Datatype = XmlSchemaDatatype.FromName ("NMTOKEN", XmlSchema.Namespace);
					break;
				case 'O':
					Expect ("OTATION");
					def.Datatype = XmlSchemaDatatype.FromName ("NOTATION", XmlSchema.Namespace);
					TryExpandPERefSpaceKeep ();
					if (!SkipWhitespace ())
						throw NotWFError ("Whitespace is required after notation name in DTD attribute definition.");
					Expect ('(');
					SkipWhitespace ();
					TryExpandPERef ();
					def.EnumeratedNotations.Add (ReadName ());		// notation name
					SkipWhitespace ();
					TryExpandPERef ();
					while(PeekChar () == '|') {
						ReadChar ();
						SkipWhitespace ();
						TryExpandPERef ();
						def.EnumeratedNotations.Add (ReadName ());	// notation name
						SkipWhitespace ();
						TryExpandPERef ();
					}
					Expect (')');
					break;
				default:
					throw NotWFError ("attribute declaration syntax error.");
				}
				break;
			default:	// Enumerated Values
				def.Datatype = XmlSchemaDatatype.FromName ("NMTOKEN", XmlSchema.Namespace);
				TryExpandPERef ();
				Expect ('(');
				SkipWhitespace ();
				TryExpandPERef ();
				def.EnumeratedAttributeDeclaration.Add (
					def.Datatype.Normalize (ReadNmToken ()));	// enum value
				SkipWhitespace ();
				while(PeekChar () == '|') {
					ReadChar ();
					SkipWhitespace ();
					TryExpandPERef ();
					def.EnumeratedAttributeDeclaration.Add (
						def.Datatype.Normalize (ReadNmToken ()));	// enum value
					SkipWhitespace ();
					TryExpandPERef ();
				}
				Expect (')');
				break;
			}
			TryExpandPERefSpaceKeep ();
			if (!SkipWhitespace ())
				throw NotWFError ("Whitespace is required between type and occurence in DTD attribute definition.");

			// def_value
			ReadAttributeDefaultValue (def);

			return def;
#endif
		}