本文整理匯總了C#中System.Xml.Schema.SchemaAttDef.AddValue方法的典型用法代碼示例。如果您正苦於以下問題:C# SchemaAttDef.AddValue方法的具體用法?C# SchemaAttDef.AddValue怎麽用?C# SchemaAttDef.AddValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.Schema.SchemaAttDef
的用法示例。
在下文中一共展示了SchemaAttDef.AddValue方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ParseAttlistType
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;
//.........這裏部分代碼省略.........
示例2: ParseAttlistType
private void ParseAttlistType( SchemaAttDef attrDef, SchemaElementDecl elementDecl ) {
Token token = GetToken( true );
if ( token != Token.CDATA ) {
elementDecl.HasNonCDataAttribute = true;
}
if ( IsAttributeValueType( token ) ) {
attrDef.Datatype = XmlSchemaDatatype.FromXmlTokenizedType( (XmlTokenizedType)(int)token );
attrDef.SchemaType = XmlSchemaType.GetBuiltInSimpleType( attrDef.Datatype.TypeCode );
switch ( token ) {
case Token.NOTATION:
break;
case Token.ID:
if ( validate && elementDecl.IsIdDeclared ) {
SchemaAttDef idAttrDef = elementDecl.GetAttDef( attrDef.Name );
if ( idAttrDef == null || idAttrDef.Datatype.TokenizedType != XmlTokenizedType.ID ) {
SendValidationEvent( XmlSeverityType.Error, Res.Sch_IdAttrDeclared, elementDecl.Name.ToString() );
}
}
elementDecl.IsIdDeclared = true;
return;
default:
return;
}
// check notation constrains
if ( validate ) {
if ( elementDecl.IsNotationDeclared ) {
SendValidationEvent( curPos - 8, XmlSeverityType.Error, Res.Sch_DupNotationAttribute, elementDecl.Name.ToString() ); // 8 == strlen("NOTATION")
}
else {
if ( elementDecl.ContentValidator != null &&
elementDecl.ContentValidator.ContentType == XmlSchemaContentType.Empty ) {
SendValidationEvent( curPos - 8, XmlSeverityType.Error, Res.Sch_NotationAttributeOnEmptyElement, elementDecl.Name.ToString() );// 8 == strlen("NOTATION")
}
elementDecl.IsNotationDeclared = true;
}
}
if ( GetToken( true ) != Token.LeftParen ) {
goto UnexpectedError;
}
// parse notation list
if ( GetToken( false ) != Token.Name ) {
goto UnexpectedError;
}
for (;;) {
string notationName = GetNameString();
if ( schemaInfo.Notations[notationName] == null ) {
if ( undeclaredNotations == null ) {
undeclaredNotations = new Hashtable();
}
UndeclaredNotation un = new UndeclaredNotation( notationName, LineNo, LinePos - notationName.Length );
UndeclaredNotation loggedUn = (UndeclaredNotation)undeclaredNotations[notationName];
if ( loggedUn != null ) {
un.next = loggedUn.next;
loggedUn.next = un;
}
else {
undeclaredNotations.Add( notationName, un );
}
}
if ( validate && !v1Compat && attrDef.Values != null && attrDef.Values.Contains( notationName ) ) {
SendValidationEvent( XmlSeverityType.Error, new XmlSchemaException( Res.Xml_AttlistDuplNotationValue, notationName, BaseUriStr, (int)LineNo, (int)LinePos ) );
}
attrDef.AddValue( notationName );
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.Datatype = XmlSchemaDatatype.FromXmlTokenizedType( XmlTokenizedType.ENUMERATION );
attrDef.SchemaType = XmlSchemaType.GetBuiltInSimpleType( attrDef.Datatype.TypeCode );
// parse nmtoken list
if ( GetToken( false ) != Token.Nmtoken )
goto UnexpectedError;
attrDef.AddValue( GetNameString() );
for (;;) {
switch ( GetToken( false ) ) {
case Token.Or:
if ( GetToken( false ) != Token.Nmtoken )
goto UnexpectedError;
string nmtoken = GetNmtokenString();
if ( validate && !v1Compat && attrDef.Values != null && attrDef.Values.Contains( nmtoken ) ) {
SendValidationEvent( XmlSeverityType.Error, new XmlSchemaException( Res.Xml_AttlistDuplEnumValue, nmtoken, BaseUriStr, (int)LineNo, (int)LinePos ) );
}
//.........這裏部分代碼省略.........