internal SchemaAttDef GetAttributeXsd(SchemaElementDecl ed, XmlQualifiedName qname, XmlSchemaObject partialValidationType, out AttributeMatchState attributeMatchState)
        {
            SchemaAttDef attdef = null;

            attributeMatchState = AttributeMatchState.UndeclaredAttribute;
            if (ed != null)
            {
                attdef = ed.GetAttDef(qname);
                if (attdef != null)
                {
                    attributeMatchState = AttributeMatchState.AttributeFound;
                    return(attdef);
                }
                XmlSchemaAnyAttribute any = ed.AnyAttribute;
                if (any != null)
                {
                    if (!any.NamespaceList.Allows(qname))
                    {
                        attributeMatchState = AttributeMatchState.ProhibitedAnyAttribute;
                    }
                    else if (any.ProcessContentsCorrect != XmlSchemaContentProcessing.Skip)
                    {
                        if (attributeDecls.TryGetValue(qname, out attdef))
                        {
                            if (attdef.Datatype.TypeCode == XmlTypeCode.Id)   //anyAttribute match whose type is ID
                            {
                                attributeMatchState = AttributeMatchState.AnyIdAttributeFound;
                            }
                            else
                            {
                                attributeMatchState = AttributeMatchState.AttributeFound;
                            }
                        }
                        else if (any.ProcessContentsCorrect == XmlSchemaContentProcessing.Lax)
                        {
                            attributeMatchState = AttributeMatchState.AnyAttributeLax;
                        }
                    }
                    else
                    {
                        attributeMatchState = AttributeMatchState.AnyAttributeSkip;
                    }
                }
                else if (ed.ProhibitedAttributes.ContainsKey(qname))
                {
                    attributeMatchState = AttributeMatchState.ProhibitedAttribute;
                }
            }
            else if (partialValidationType != null)
            {
                XmlSchemaAttribute attr = partialValidationType as XmlSchemaAttribute;
                if (attr != null)
                {
                    if (qname.Equals(attr.QualifiedName))
                    {
                        attdef = attr.AttDef;
                        attributeMatchState = AttributeMatchState.AttributeFound;
                    }
                    else
                    {
                        attributeMatchState = AttributeMatchState.AttributeNameMismatch;
                    }
                }
                else
                {
                    attributeMatchState = AttributeMatchState.ValidateAttributeInvalidCall;
                }
            }
            else
            {
                if (attributeDecls.TryGetValue(qname, out attdef))
                {
                    attributeMatchState = AttributeMatchState.AttributeFound;
                }
                else
                {
                    attributeMatchState = AttributeMatchState.UndeclaredElementAndAttribute;
                }
            }
            return(attdef);
        }
Esempio n. 2
0
        internal SchemaAttDef?GetAttributeXsd(SchemaElementDecl?ed, XmlQualifiedName qname, XmlSchemaObject?partialValidationType, out AttributeMatchState attributeMatchState)
        {
            SchemaAttDef?attdef = null;

            attributeMatchState = AttributeMatchState.UndeclaredAttribute;
            if (ed != null)
            {
                attdef = ed.GetAttDef(qname);
                if (attdef != null)
                {
                    attributeMatchState = AttributeMatchState.AttributeFound;
                    return(attdef);
                }
                XmlSchemaAnyAttribute?any = ed.AnyAttribute;
                if (any != null)
                {
                    if (!any.NamespaceList !.Allows(qname))
                    {
                        attributeMatchState = AttributeMatchState.ProhibitedAnyAttribute;
                    }
                    else if (any.ProcessContentsCorrect != XmlSchemaContentProcessing.Skip)
                    {
                        if (_attributeDecls.TryGetValue(qname, out attdef))
                        {
                            if (attdef.Datatype.TypeCode == XmlTypeCode.Id)
                            { //anyAttribute match whose type is ID
                                attributeMatchState = AttributeMatchState.AnyIdAttributeFound;
                            }
                            else
                            {
                                attributeMatchState = AttributeMatchState.AttributeFound;
                            }
                        }
                        else if (any.ProcessContentsCorrect == XmlSchemaContentProcessing.Lax)
                        {
                            attributeMatchState = AttributeMatchState.AnyAttributeLax;
                        }
                    }
                    else
                    {
                        attributeMatchState = AttributeMatchState.AnyAttributeSkip;
                    }
                }
                else if (ed.ProhibitedAttributes.ContainsKey(qname))
                {
                    attributeMatchState = AttributeMatchState.ProhibitedAttribute;
                }
            }
Esempio n. 3
0
 internal SchemaAttDef GetAttributeXsd(SchemaElementDecl ed, XmlQualifiedName qname, XmlSchemaObject partialValidationType, out AttributeMatchState attributeMatchState) {
     SchemaAttDef attdef = null;
     attributeMatchState = AttributeMatchState.UndeclaredAttribute;
     if (ed != null) {
         attdef = ed.GetAttDef(qname);
         if (attdef != null) {
             attributeMatchState = AttributeMatchState.AttributeFound;
             return attdef;
         }
         XmlSchemaAnyAttribute any = ed.AnyAttribute;
         if (any != null) {
             if (!any.NamespaceList.Allows(qname)) {
                 attributeMatchState = AttributeMatchState.ProhibitedAnyAttribute;
             }
             else if (any.ProcessContentsCorrect != XmlSchemaContentProcessing.Skip) {
                 if (attributeDecls.TryGetValue(qname, out attdef)) {
                     if (attdef.Datatype.TypeCode == XmlTypeCode.Id) { //anyAttribute match whose type is ID
                         attributeMatchState = AttributeMatchState.AnyIdAttributeFound;
                     }
                     else {
                         attributeMatchState = AttributeMatchState.AttributeFound;
                     }
                 }
                 else if (any.ProcessContentsCorrect == XmlSchemaContentProcessing.Lax) {
                     attributeMatchState = AttributeMatchState.AnyAttributeLax;
                 }
             }
             else {
                 attributeMatchState = AttributeMatchState.AnyAttributeSkip;
             }
         }
         else if (ed.ProhibitedAttributes.ContainsKey(qname)) {
             attributeMatchState = AttributeMatchState.ProhibitedAttribute;
         }
     }
     else if (partialValidationType != null) {
         XmlSchemaAttribute attr = partialValidationType as XmlSchemaAttribute;
         if (attr != null) {
             if (qname.Equals(attr.QualifiedName)) {
                 attdef = attr.AttDef;
                 attributeMatchState = AttributeMatchState.AttributeFound;
             }
             else {
                 attributeMatchState = AttributeMatchState.AttributeNameMismatch;
             }
         }
         else {
             attributeMatchState = AttributeMatchState.ValidateAttributeInvalidCall;
         }
     }
     else {
         if (attributeDecls.TryGetValue(qname, out attdef)) {
             attributeMatchState = AttributeMatchState.AttributeFound;
         }
         else {
             attributeMatchState = AttributeMatchState.UndeclaredElementAndAttribute;
         }
     }
     return attdef;
 }