private void ParseAttlistType(SchemaAttDef attrDef, SchemaElementDecl elementDecl, bool ignoreErrors)
{
Token token = GetToken(true);
if (token != Token.CDATA)
{
elementDecl.HasNonCDataAttribute = true;
}
if (IsAttributeValueType(token))
{
attrDef.TokenizedType = (XmlTokenizedType)(int)token;
#if !SILVERLIGHT
attrDef.SchemaType = XmlSchemaType.GetBuiltInSimpleType(attrDef.Datatype.TypeCode);
#endif
switch (token)
{
case Token.NOTATION:
break;
case Token.ID:
#if !SILVERLIGHT
if (_validate && elementDecl.IsIdDeclared)
{
SchemaAttDef idAttrDef = elementDecl.GetAttDef(attrDef.Name);
if ((idAttrDef == null || idAttrDef.Datatype.TokenizedType != XmlTokenizedType.ID) && !ignoreErrors)
{
SendValidationEvent(XmlSeverityType.Error, SR.Sch_IdAttrDeclared, elementDecl.Name.ToString());
}
}
#endif
elementDecl.IsIdDeclared = true;
return;
default:
return;
}
#if !SILVERLIGHT
// check notation constrains
if (_validate)
{
if (elementDecl.IsNotationDeclared && !ignoreErrors)
{
SendValidationEvent(_curPos - 8, XmlSeverityType.Error, SR.Sch_DupNotationAttribute, elementDecl.Name.ToString()); // 8 == strlen("NOTATION")
}
else
{
if (elementDecl.ContentValidator != null &&
elementDecl.ContentValidator.ContentType == XmlSchemaContentType.Empty &&
!ignoreErrors)
{
SendValidationEvent(_curPos - 8, XmlSeverityType.Error, SR.Sch_NotationAttributeOnEmptyElement, elementDecl.Name.ToString());// 8 == strlen("NOTATION")
}
elementDecl.IsNotationDeclared = true;
}
}
#endif
if (GetToken(true) != Token.LeftParen)
{
goto UnexpectedError;
}
// parse notation list
if (GetToken(false) != Token.Name)
{
goto UnexpectedError;
}
for (;;)
{
string notationName = GetNameString();
#if !SILVERLIGHT
if (!_schemaInfo.Notations.ContainsKey(notationName))
{
AddUndeclaredNotation(notationName);
}
if (_validate && !_v1Compat && attrDef.Values != null && attrDef.Values.Contains(notationName) && !ignoreErrors)
{
SendValidationEvent(XmlSeverityType.Error, new XmlSchemaException(SR.Xml_AttlistDuplNotationValue, notationName, BaseUriStr, (int)LineNo, (int)LinePos));
}
attrDef.AddValue(notationName);
#endif
switch (GetToken(false))
{
case Token.Or:
if (GetToken(false) != Token.Name)
{
goto UnexpectedError;
}
continue;
case Token.RightParen:
return;
default:
goto UnexpectedError;
}
}
}
else if (token == Token.LeftParen)
{
attrDef.TokenizedType = XmlTokenizedType.ENUMERATION;
#if !SILVERLIGHT
attrDef.SchemaType = XmlSchemaType.GetBuiltInSimpleType(attrDef.Datatype.TypeCode);
#endif
// parse nmtoken list
if (GetToken(false) != Token.Nmtoken)
goto UnexpectedError;
#if !SILVERLIGHT
attrDef.AddValue(GetNameString());
#endif
for (;;)
{
switch (GetToken(false))
{
case Token.Or:
if (GetToken(false) != Token.Nmtoken)
goto UnexpectedError;
string nmtoken = GetNmtokenString();
#if !SILVERLIGHT
if (_validate && !_v1Compat && attrDef.Values != null && attrDef.Values.Contains(nmtoken) && !ignoreErrors)
{
SendValidationEvent(XmlSeverityType.Error, new XmlSchemaException(SR.Xml_AttlistDuplEnumValue, nmtoken, BaseUriStr, (int)LineNo, (int)LinePos));
}
attrDef.AddValue(nmtoken);
#endif
break;
case Token.RightParen:
return;
default:
goto UnexpectedError;
}
}
}
else
{
goto UnexpectedError;
}
UnexpectedError:
OnUnexpectedError();
}