Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ValidateAttribute() [3/3]

object System.Xml.Schema.XmlSchemaValidator.ValidateAttribute ( string localName,
string namespaceUri,
XmlValueGetter attributeValueGetter,
string attributeStringValue,
XmlSchemaInfo schemaInfo )
inlineprivate

Definition at line 585 of file XmlSchemaValidator.cs.

586 {
587 if (localName == null)
588 {
589 throw new ArgumentNullException("localName");
590 }
591 if (namespaceUri == null)
592 {
593 throw new ArgumentNullException("namespaceUri");
594 }
595 ValidatorState validatorState = ((_validationStack.Length > 1) ? ValidatorState.Attribute : ValidatorState.TopLevelAttribute);
597 object obj = null;
598 _attrValid = true;
599 XmlSchemaValidity validity = XmlSchemaValidity.NotKnown;
600 XmlSchemaAttribute xmlSchemaAttribute = null;
601 XmlSchemaSimpleType memberType = null;
602 namespaceUri = _nameTable.Add(namespaceUri);
603 if (Ref.Equal(namespaceUri, _nsXmlNs))
604 {
605 return null;
606 }
607 SchemaAttDef schemaAttDef = null;
608 SchemaElementDecl elementDecl = _context.ElementDecl;
609 XmlQualifiedName xmlQualifiedName = new XmlQualifiedName(localName, namespaceUri);
610 if (_attPresence[xmlQualifiedName] != null)
611 {
613 schemaInfo?.Clear();
614 return null;
615 }
616 if (!Ref.Equal(namespaceUri, _nsXsi))
617 {
618 XmlSchemaObject xmlSchemaObject = ((_currentState == ValidatorState.TopLevelAttribute) ? _partialValidationType : null);
620 switch (attributeMatchState)
621 {
622 case AttributeMatchState.UndeclaredElementAndAttribute:
624 {
625 if (elementDecl == null && _processContents == XmlSchemaContentProcessing.Strict && xmlQualifiedName.Namespace.Length != 0 && _compiledSchemaInfo.Contains(xmlQualifiedName.Namespace))
626 {
627 _attrValid = false;
629 }
630 else if (_processContents != XmlSchemaContentProcessing.Skip)
631 {
633 }
634 break;
635 }
636 goto case AttributeMatchState.AttributeFound;
637 case AttributeMatchState.UndeclaredAttribute:
639 {
640 _attrValid = false;
642 break;
643 }
644 goto case AttributeMatchState.AttributeFound;
645 case AttributeMatchState.ProhibitedAnyAttribute:
647 {
648 _attrValid = false;
650 break;
651 }
652 goto case AttributeMatchState.AttributeFound;
653 case AttributeMatchState.ProhibitedAttribute:
654 _attrValid = false;
656 break;
657 case AttributeMatchState.AttributeNameMismatch:
658 _attrValid = false;
660 {
661 xmlQualifiedName.ToString(),
662 ((XmlSchemaAttribute)xmlSchemaObject).QualifiedName.ToString()
663 });
664 break;
665 case AttributeMatchState.ValidateAttributeInvalidCall:
666 _currentState = ValidatorState.Start;
667 _attrValid = false;
669 break;
670 case AttributeMatchState.AnyIdAttributeFound:
671 if (_wildID == null)
672 {
674 XmlSchemaComplexType xmlSchemaComplexType = elementDecl.SchemaType as XmlSchemaComplexType;
675 if (xmlSchemaComplexType.ContainsIdAttribute(findAll: false))
676 {
678 break;
679 }
680 goto case AttributeMatchState.AttributeFound;
681 }
683 break;
684 case AttributeMatchState.AttributeFound:
685 {
686 xmlSchemaAttribute = schemaAttDef.SchemaAttribute;
687 if (elementDecl != null)
688 {
690 }
693 XmlSchemaDatatype datatype = schemaAttDef.Datatype;
694 if (datatype.Variety == XmlSchemaDatatypeVariety.Union && obj != null)
695 {
696 XsdSimpleValue xsdSimpleValue = obj as XsdSimpleValue;
697 memberType = xsdSimpleValue.XmlType;
698 datatype = xsdSimpleValue.XmlType.Datatype;
699 obj = xsdSimpleValue.TypedValue;
700 }
703 {
704 AttributeIdentityConstraints(xmlQualifiedName.Name, xmlQualifiedName.Namespace, obj, obj2.ToString(), datatype);
705 }
706 break;
707 }
708 case AttributeMatchState.AnyAttributeLax:
710 break;
711 }
712 }
713 else
714 {
715 localName = _nameTable.Add(localName);
716 if (Ref.Equal(localName, _xsiTypeString) || Ref.Equal(localName, _xsiNilString) || Ref.Equal(localName, _xsiSchemaLocationString) || Ref.Equal(localName, _xsiNoNamespaceSchemaLocationString))
717 {
718 _attPresence.Add(xmlQualifiedName, SchemaAttDef.Empty);
719 }
720 else
721 {
722 _attrValid = false;
724 }
725 }
726 if (!_attrValid)
727 {
728 validity = XmlSchemaValidity.Invalid;
729 }
730 else if (schemaAttDef != null)
731 {
732 validity = XmlSchemaValidity.Valid;
733 }
734 if (schemaInfo != null)
735 {
737 schemaInfo.SchemaType = xmlSchemaAttribute?.AttributeSchemaType;
739 schemaInfo.IsDefault = false;
741 }
742 if (ProcessSchemaHints && _validatedNamespaces[namespaceUri] == null)
743 {
744 _validatedNamespaces.Add(namespaceUri, namespaceUri);
745 }
746 return obj;
747 }
virtual void Add(object key, object? value)
Definition Hashtable.cs:676
static string Sch_NotXsiAttribute
Definition SR.cs:1168
static string Sch_SchemaAttributeNameMismatch
Definition SR.cs:1198
static string Sch_MoreThanOneWildId
Definition SR.cs:958
static string Sch_NoAttributeSchemaFound
Definition SR.cs:788
static string Sch_ValidateAttributeInvalidCall
Definition SR.cs:1200
static string Sch_ProhibitedAttribute
Definition SR.cs:950
static string Sch_DuplicateAttribute
Definition SR.cs:1192
static string Sch_AttrUseAndWildId
Definition SR.cs:956
static string Sch_UndeclaredAttribute
Definition SR.cs:414
Definition SR.cs:7
SchemaAttDef GetAttributeXsd(SchemaElementDecl ed, XmlQualifiedName qname, XmlSchemaObject partialValidationType, out AttributeMatchState attributeMatchState)
void CheckStateTransition(ValidatorState toState, string methodName)
object CheckAttributeValue(object value, SchemaAttDef attdef)
void CheckTokenizedTypes(XmlSchemaDatatype dtype, object typedValue, bool attrValue)
void AttributeIdentityConstraints(string name, string ns, object obj, string sobj, XmlSchemaDatatype datatype)
XmlSchemaContentProcessing _processContents
SchemaAttDef CheckIsXmlAttribute(XmlQualifiedName attQName)
string Add(char[] array, int offset, int length)

References System.Xml.Schema.XmlSchemaValidator._attPresence, System.Xml.Schema.XmlSchemaValidator._attrValid, System.Xml.Schema.XmlSchemaValidator._compiledSchemaInfo, System.Xml.Schema.XmlSchemaValidator._context, System.Xml.Schema.XmlSchemaValidator._currentState, System.Xml.Schema.XmlSchemaValidator._nameTable, System.Xml.Schema.XmlSchemaValidator._nsXmlNs, System.Xml.Schema.XmlSchemaValidator._nsXsi, System.Xml.Schema.XmlSchemaValidator._partialValidationType, System.Xml.Schema.XmlSchemaValidator._processContents, System.Xml.Schema.XmlSchemaValidator._validatedNamespaces, System.Xml.Schema.XmlSchemaValidator._wildID, System.Xml.Schema.XmlSchemaValidator._xsiNilString, System.Xml.Schema.XmlSchemaValidator._xsiNoNamespaceSchemaLocationString, System.Xml.Schema.XmlSchemaValidator._xsiSchemaLocationString, System.Xml.Schema.XmlSchemaValidator._xsiTypeString, System.Xml.XmlNameTable.Add(), System.Collections.Hashtable.Add(), System.Xml.Schema.XmlSchemaValidator.AttributeIdentityConstraints(), System.Xml.Schema.XmlSchemaValidator.CheckAttributeValue(), System.Xml.Schema.XmlSchemaValidator.CheckIsXmlAttribute(), System.Xml.Schema.XmlSchemaValidator.CheckStateTransition(), System.Xml.Schema.XmlSchemaValidator.CheckTokenizedTypes(), System.Xml.Schema.XmlSchemaInfo.Clear(), System.Xml.Schema.SchemaInfo.Contains(), System.Xml.Dictionary, System.Xml.Schema.ValidationState.ElementDecl, System.Xml.Schema.SchemaAttDef.Empty, System.Xml.Ref.Equal(), System.Xml.Schema.SchemaInfo.GetAttributeXsd(), System.Xml.Schema.XmlSchemaValidator.HasIdentityConstraints, System.obj, System.Xml.Schema.XmlSchemaValidator.ProcessSchemaHints, System.Xml.Schema.XmlSchemaValidator.s_methodNames, System.SR.Sch_AttrUseAndWildId, System.SR.Sch_DuplicateAttribute, System.SR.Sch_MoreThanOneWildId, System.SR.Sch_NoAttributeSchemaFound, System.SR.Sch_NotXsiAttribute, System.SR.Sch_ProhibitedAttribute, System.SR.Sch_SchemaAttributeNameMismatch, System.SR.Sch_UndeclaredAttribute, System.SR.Sch_ValidateAttributeInvalidCall, System.Xml.Schema.XmlSchemaValidator.SendValidationEvent(), and System.Xml.Schema.XmlSchemaDatatype.Variety.