private AttributePSVIInfo AddAttributePSVI(int attIndex)
 {
     AttributePSVIInfo info = this.attributePSVINodes[attIndex];
     if (info != null)
     {
         info.Reset();
         return info;
     }
     if (attIndex >= (this.attributePSVINodes.Length - 1))
     {
         AttributePSVIInfo[] destinationArray = new AttributePSVIInfo[this.attributePSVINodes.Length * 2];
         Array.Copy(this.attributePSVINodes, 0, destinationArray, 0, this.attributePSVINodes.Length);
         this.attributePSVINodes = destinationArray;
     }
     info = this.attributePSVINodes[attIndex];
     if (info == null)
     {
         info = new AttributePSVIInfo();
         this.attributePSVINodes[attIndex] = info;
     }
     return info;
 }
コード例 #2
0
 private void ClearAttributesInfo() {
     attributeCount = 0;
     coreReaderAttributeCount = 0;
     currentAttrIndex = -1;
     defaultAttributes.Clear();
     attributePSVI = null;
 }
コード例 #3
0
        private void ValidateAttributes() {
            attributeCount = coreReaderAttributeCount = coreReader.AttributeCount;
            AttributePSVIInfo attributePSVI;
            int attIndex = 0;
            bool attributeInvalid = false;
            if (coreReader.MoveToFirstAttribute()) {
                do {
                    string localName = coreReader.LocalName;
                    string ns = coreReader.NamespaceURI;

                    attributePSVI = AddAttributePSVI(attIndex);
                    attributePSVI.localName = localName;
                    attributePSVI.namespaceUri = ns;

                    if ((object)ns == (object)NsXmlNs) {
                        attIndex++;
                        continue;
                    }
                    attributePSVI.typedAttributeValue = validator.ValidateAttribute(localName, ns, valueGetter, attributePSVI.attributeSchemaInfo);
                    if (!attributeInvalid) {
                        attributeInvalid = attributePSVI.attributeSchemaInfo.Validity == XmlSchemaValidity.Invalid;
                    }
                    attIndex++;

                } while (coreReader.MoveToNextAttribute());
            }
            coreReader.MoveToElement();
            if (attributeInvalid) { //If any of the attributes are invalid, Need to report element's validity as invalid
                xmlSchemaInfo.Validity = XmlSchemaValidity.Invalid;
            }
            validator.GetUnspecifiedDefaultAttributes(defaultAttributes, true);
            attributeCount += defaultAttributes.Count;
        }
コード例 #4
0
 // Moves to the next attribute.
 public override bool MoveToNextAttribute() {
     if (currentAttrIndex + 1 < coreReaderAttributeCount) {
         bool moveTo = coreReader.MoveToNextAttribute();
         Debug.Assert(moveTo);
         currentAttrIndex++;
         if (inlineSchemaParser == null) {
             attributePSVI = attributePSVINodes[currentAttrIndex];
         }
         else {
             attributePSVI = null;
         }
         validationState = ValidatingReaderState.OnAttribute;
         goto Found;
     }
     else if (currentAttrIndex + 1 < attributeCount) { //default attribute
         int defaultIndex = ++currentAttrIndex - coreReaderAttributeCount;
         cachedNode = (ValidatingReaderNodeData)defaultAttributes[defaultIndex];
         attributePSVI = cachedNode.AttInfo;
         validationState = ValidatingReaderState.OnDefaultAttribute;
         goto Found;
     }
     return false;
 Found:
     if (validationState == ValidatingReaderState.OnReadBinaryContent) {
         readBinaryHelper.Finish();
         validationState = savedState;
     }
     return true;
 }
コード例 #5
0
 // Moves to the first attribute.
 public override bool MoveToFirstAttribute() {
     if (coreReader.MoveToFirstAttribute()) {
         currentAttrIndex = 0;
         if (inlineSchemaParser == null) {
             attributePSVI = attributePSVINodes[0];
         }
         else {
             attributePSVI = null;
         }
         validationState = ValidatingReaderState.OnAttribute;
         goto Found;
     }
     else if (defaultAttributes.Count > 0) { //check for default
         cachedNode = (ValidatingReaderNodeData)defaultAttributes[0];
         attributePSVI = cachedNode.AttInfo;
         currentAttrIndex = 0;
         validationState = ValidatingReaderState.OnDefaultAttribute;
         goto Found;
     }
     return false;
 Found:
     if (validationState == ValidatingReaderState.OnReadBinaryContent) {
         readBinaryHelper.Finish();
         validationState = savedState;
     }
     return true;
 }
 internal void GetUnspecifiedDefaultAttributes(ArrayList defaultAttributes, bool createNodeData)
 {
     this.currentState = ValidatorState.Attribute;
     SchemaElementDecl elementDecl = this.context.ElementDecl;
     if ((elementDecl != null) && elementDecl.HasDefaultAttribute)
     {
         for (int i = 0; i < elementDecl.DefaultAttDefs.Count; i++)
         {
             SchemaAttDef def = (SchemaAttDef) elementDecl.DefaultAttDefs[i];
             if (!this.attPresence.Contains(def.Name) && (def.DefaultValueTyped != null))
             {
                 string attributeNS = this.nameTable.Add(def.Name.Namespace);
                 string array = string.Empty;
                 if (attributeNS.Length > 0)
                 {
                     array = this.GetDefaultAttributePrefix(attributeNS);
                     if ((array == null) || (array.Length == 0))
                     {
                         this.SendValidationEvent("Sch_DefaultAttributeNotApplied", new string[] { def.Name.ToString(), QNameString(this.context.LocalName, this.context.Namespace) });
                         continue;
                     }
                 }
                 XmlSchemaDatatype dtype = def.Datatype;
                 if (createNodeData)
                 {
                     ValidatingReaderNodeData data = new ValidatingReaderNodeData {
                         LocalName = this.nameTable.Add(def.Name.Name),
                         Namespace = attributeNS,
                         Prefix = this.nameTable.Add(array),
                         NodeType = XmlNodeType.Attribute
                     };
                     AttributePSVIInfo info = new AttributePSVIInfo();
                     XmlSchemaInfo attributeSchemaInfo = info.attributeSchemaInfo;
                     if (def.Datatype.Variety == XmlSchemaDatatypeVariety.Union)
                     {
                         XsdSimpleValue defaultValueTyped = def.DefaultValueTyped as XsdSimpleValue;
                         attributeSchemaInfo.MemberType = defaultValueTyped.XmlType;
                         dtype = defaultValueTyped.XmlType.Datatype;
                         info.typedAttributeValue = defaultValueTyped.TypedValue;
                     }
                     else
                     {
                         info.typedAttributeValue = def.DefaultValueTyped;
                     }
                     attributeSchemaInfo.IsDefault = true;
                     attributeSchemaInfo.Validity = XmlSchemaValidity.Valid;
                     attributeSchemaInfo.SchemaType = def.SchemaType;
                     attributeSchemaInfo.SchemaAttribute = def.SchemaAttribute;
                     data.RawValue = attributeSchemaInfo.XmlType.ValueConverter.ToString(info.typedAttributeValue);
                     data.AttInfo = info;
                     defaultAttributes.Add(data);
                 }
                 else
                 {
                     defaultAttributes.Add(def.SchemaAttribute);
                 }
                 this.CheckTokenizedTypes(dtype, def.DefaultValueTyped, true);
                 if (this.HasIdentityConstraints)
                 {
                     this.AttributeIdentityConstraints(def.Name.Name, def.Name.Namespace, def.DefaultValueTyped, def.DefaultValueRaw, dtype);
                 }
             }
         }
     }
 }
 public override void MoveToAttribute(int i)
 {
     if ((i < 0) || (i >= this.attributeCount))
     {
         throw new ArgumentOutOfRangeException("i");
     }
     this.currentAttrIndex = i;
     if (i < this.coreReaderAttributeCount)
     {
         this.coreReader.MoveToAttribute(i);
         if (this.inlineSchemaParser == null)
         {
             this.attributePSVI = this.attributePSVINodes[i];
         }
         else
         {
             this.attributePSVI = null;
         }
         this.validationState = ValidatingReaderState.OnAttribute;
     }
     else
     {
         int num = i - this.coreReaderAttributeCount;
         this.cachedNode = (ValidatingReaderNodeData) this.defaultAttributes[num];
         this.attributePSVI = this.cachedNode.AttInfo;
         this.validationState = ValidatingReaderState.OnDefaultAttribute;
     }
     if (this.validationState == ValidatingReaderState.OnReadBinaryContent)
     {
         this.readBinaryHelper.Finish();
         this.validationState = this.savedState;
     }
 }
コード例 #8
0
 // Moves to the attribute with the specified LocalName and NamespaceURI
 public override bool MoveToAttribute(string name, string ns) {
     //Check atomized local name and ns
     name = coreReaderNameTable.Get(name);
     ns = ns != null ? coreReaderNameTable.Get(ns) : string.Empty;
     if (name == null || ns == null) { //Name or ns not found in the nameTable, then attribute is not found
         return false;
     }
     if (coreReader.MoveToAttribute(name, ns)) {
         validationState = ValidatingReaderState.OnAttribute;
         if (inlineSchemaParser == null) {
             attributePSVI = GetAttributePSVI(name, ns);
             Debug.Assert(attributePSVI != null);
         }
         else { //Parsing inline schema, no PSVI for schema attributes
             attributePSVI = null;
         }
         goto Found;
     }
     else { //Default attribute
         ValidatingReaderNodeData defaultNode = GetDefaultAttribute(name, ns, true);
         if (defaultNode != null) {
             attributePSVI = defaultNode.AttInfo;
             cachedNode = defaultNode;
             validationState = ValidatingReaderState.OnDefaultAttribute;
             goto Found;
         }
     }
     return false;
 Found:
     if (validationState == ValidatingReaderState.OnReadBinaryContent) {
         readBinaryHelper.Finish();
         validationState = savedState;
     }
     return true;
 }
コード例 #9
0
ファイル: XsdValidatingReader.cs プロジェクト: dotnet/corefx
 // Moves to the attribute with the specified index
 public override void MoveToAttribute(int i)
 {
     if (i < 0 || i >= _attributeCount)
     {
         throw new ArgumentOutOfRangeException(nameof(i));
     }
     _currentAttrIndex = i;
     if (i < _coreReaderAttributeCount)
     { //reader attribute
         _coreReader.MoveToAttribute(i);
         if (_inlineSchemaParser == null)
         {
             _attributePSVI = _attributePSVINodes[i];
         }
         else
         {
             _attributePSVI = null;
         }
         _validationState = ValidatingReaderState.OnAttribute;
     }
     else
     { //default attribute
         int defaultIndex = i - _coreReaderAttributeCount;
         _cachedNode = (ValidatingReaderNodeData)_defaultAttributes[defaultIndex];
         _attributePSVI = _cachedNode.AttInfo;
         _validationState = ValidatingReaderState.OnDefaultAttribute;
     }
     if (_validationState == ValidatingReaderState.OnReadBinaryContent)
     {
         _readBinaryHelper.Finish();
         _validationState = _savedState;
     }
 }
コード例 #10
0
        internal void GetUnspecifiedDefaultAttributes(ArrayList defaultAttributes, bool createNodeData) {
            currentState = ValidatorState.Attribute;
            SchemaElementDecl currentElementDecl = context.ElementDecl;

            if (currentElementDecl != null && currentElementDecl.HasDefaultAttribute) {
                for (int i = 0; i < currentElementDecl.DefaultAttDefs.Count; ++i) {
                    SchemaAttDef attdef = (SchemaAttDef)currentElementDecl.DefaultAttDefs[i];
                    if (!attPresence.Contains(attdef.Name)) {
                        if (attdef.DefaultValueTyped == null) { //Invalid attribute default in the schema
                            continue;
                        }

                        //Check to see default attributes WILL be qualified if attributeFormDefault = qualified in schema
                        string attributeNS = nameTable.Add(attdef.Name.Namespace);
                        string defaultPrefix = string.Empty;
                        if (attributeNS.Length > 0) {
                            defaultPrefix = GetDefaultAttributePrefix(attributeNS);
                            if (defaultPrefix == null || defaultPrefix.Length == 0) {
                                SendValidationEvent(Res.Sch_DefaultAttributeNotApplied, new string[2] { attdef.Name.ToString(), QNameString(context.LocalName, context.Namespace)});
                                continue;
                            }
                        }
                        XmlSchemaDatatype datatype = attdef.Datatype;
                        if (createNodeData) {
                            ValidatingReaderNodeData attrData = new ValidatingReaderNodeData();
                            attrData.LocalName = nameTable.Add(attdef.Name.Name);
                            attrData.Namespace = attributeNS;
                            attrData.Prefix = nameTable.Add(defaultPrefix);
                            attrData.NodeType = XmlNodeType.Attribute;

                            //set PSVI properties
                            AttributePSVIInfo attrValidInfo = new AttributePSVIInfo();
                            XmlSchemaInfo attSchemaInfo = attrValidInfo.attributeSchemaInfo;
                            Debug.Assert(attSchemaInfo != null);
                            if (attdef.Datatype.Variety == XmlSchemaDatatypeVariety.Union) {
                                XsdSimpleValue simpleValue = attdef.DefaultValueTyped as XsdSimpleValue;
                                attSchemaInfo.MemberType = simpleValue.XmlType;
                                datatype = simpleValue.XmlType.Datatype;
                                attrValidInfo.typedAttributeValue = simpleValue.TypedValue;
                            }
                            else {
                                attrValidInfo.typedAttributeValue = attdef.DefaultValueTyped;
                            }
                            attSchemaInfo.IsDefault = true;
                            attSchemaInfo.Validity = XmlSchemaValidity.Valid;
                            attSchemaInfo.SchemaType = attdef.SchemaType;
                            attSchemaInfo.SchemaAttribute = attdef.SchemaAttribute;
                            attrData.RawValue = attSchemaInfo.XmlType.ValueConverter.ToString(attrValidInfo.typedAttributeValue);

                            attrData.AttInfo = attrValidInfo;
                            defaultAttributes.Add(attrData);
                        }
                        else {
                            defaultAttributes.Add(attdef.SchemaAttribute);
                        }
                        CheckTokenizedTypes(datatype, attdef.DefaultValueTyped, true);
                        if (HasIdentityConstraints) {
                            AttributeIdentityConstraints(attdef.Name.Name, attdef.Name.Namespace, attdef.DefaultValueTyped, attdef.DefaultValueRaw, datatype);
                        }
                    }
                }
            }
            return;
        }
 public override bool MoveToNextAttribute()
 {
     if ((this.currentAttrIndex + 1) < this.coreReaderAttributeCount)
     {
         this.coreReader.MoveToNextAttribute();
         this.currentAttrIndex++;
         if (this.inlineSchemaParser == null)
         {
             this.attributePSVI = this.attributePSVINodes[this.currentAttrIndex];
         }
         else
         {
             this.attributePSVI = null;
         }
         this.validationState = ValidatingReaderState.OnAttribute;
     }
     else if ((this.currentAttrIndex + 1) < this.attributeCount)
     {
         int num = ++this.currentAttrIndex - this.coreReaderAttributeCount;
         this.cachedNode = (ValidatingReaderNodeData) this.defaultAttributes[num];
         this.attributePSVI = this.cachedNode.AttInfo;
         this.validationState = ValidatingReaderState.OnDefaultAttribute;
     }
     else
     {
         return false;
     }
     if (this.validationState == ValidatingReaderState.OnReadBinaryContent)
     {
         this.readBinaryHelper.Finish();
         this.validationState = this.savedState;
     }
     return true;
 }
 public override bool MoveToAttribute(string name, string ns)
 {
     name = this.coreReaderNameTable.Get(name);
     ns = (ns != null) ? this.coreReaderNameTable.Get(ns) : string.Empty;
     if ((name == null) || (ns == null))
     {
         return false;
     }
     if (this.coreReader.MoveToAttribute(name, ns))
     {
         this.validationState = ValidatingReaderState.OnAttribute;
         if (this.inlineSchemaParser == null)
         {
             this.attributePSVI = this.GetAttributePSVI(name, ns);
         }
         else
         {
             this.attributePSVI = null;
         }
     }
     else
     {
         ValidatingReaderNodeData data = this.GetDefaultAttribute(name, ns, true);
         if (data != null)
         {
             this.attributePSVI = data.AttInfo;
             this.cachedNode = data;
             this.validationState = ValidatingReaderState.OnDefaultAttribute;
         }
         else
         {
             return false;
         }
     }
     if (this.validationState == ValidatingReaderState.OnReadBinaryContent)
     {
         this.readBinaryHelper.Finish();
         this.validationState = this.savedState;
     }
     return true;
 }
 public override bool MoveToAttribute(string name)
 {
     if (this.coreReader.MoveToAttribute(name))
     {
         this.validationState = ValidatingReaderState.OnAttribute;
         this.attributePSVI = this.GetAttributePSVI(name);
     }
     else
     {
         if (this.attributeCount > 0)
         {
             ValidatingReaderNodeData defaultAttribute = this.GetDefaultAttribute(name, true);
             if (defaultAttribute != null)
             {
                 this.validationState = ValidatingReaderState.OnDefaultAttribute;
                 this.attributePSVI = defaultAttribute.AttInfo;
                 this.cachedNode = defaultAttribute;
                 goto Label_0057;
             }
         }
         return false;
     }
 Label_0057:
     if (this.validationState == ValidatingReaderState.OnReadBinaryContent)
     {
         this.readBinaryHelper.Finish();
         this.validationState = this.savedState;
     }
     return true;
 }
コード例 #14
0
 private AttributePSVIInfo AddAttributePSVI(int attIndex) {
     Debug.Assert(attIndex <= attributePSVINodes.Length);
     AttributePSVIInfo attInfo = attributePSVINodes[attIndex];
     if (attInfo != null) {
         attInfo.Reset();
         return attInfo;
     }
     if (attIndex >= attributePSVINodes.Length - 1) { //reached capacity of PSVIInfo array, Need to increase capacity to twice the initial
         AttributePSVIInfo[] newPSVINodes = new AttributePSVIInfo[attributePSVINodes.Length * 2];
         Array.Copy(attributePSVINodes, 0, newPSVINodes, 0, attributePSVINodes.Length);
         attributePSVINodes = newPSVINodes;
     }
     attInfo = attributePSVINodes[attIndex];
     if (attInfo == null) {
         attInfo = new AttributePSVIInfo();
         attributePSVINodes[attIndex] = attInfo;
     }
     return attInfo;
 }
コード例 #15
0
ファイル: XsdValidatingReader.cs プロジェクト: dotnet/corefx
 // Moves to the first attribute.
 public override bool MoveToFirstAttribute()
 {
     if (_coreReader.MoveToFirstAttribute())
     {
         _currentAttrIndex = 0;
         if (_inlineSchemaParser == null)
         {
             _attributePSVI = _attributePSVINodes[0];
         }
         else
         {
             _attributePSVI = null;
         }
         _validationState = ValidatingReaderState.OnAttribute;
         goto Found;
     }
     else if (_defaultAttributes.Count > 0)
     { //check for default
         _cachedNode = (ValidatingReaderNodeData)_defaultAttributes[0];
         _attributePSVI = _cachedNode.AttInfo;
         _currentAttrIndex = 0;
         _validationState = ValidatingReaderState.OnDefaultAttribute;
         goto Found;
     }
     return false;
 Found:
     if (_validationState == ValidatingReaderState.OnReadBinaryContent)
     {
         _readBinaryHelper.Finish();
         _validationState = _savedState;
     }
     return true;
 }
コード例 #16
0
        // Moves to the attribute with the specified Name
        public override bool MoveToAttribute(string name) {

            if (coreReader.MoveToAttribute(name)) {
                validationState = ValidatingReaderState.OnAttribute;
                attributePSVI = GetAttributePSVI(name);
                goto Found;
            }
            else if (attributeCount > 0) { //Default attribute
                ValidatingReaderNodeData defaultNode = GetDefaultAttribute(name, true);
                if (defaultNode != null) {
                    validationState = ValidatingReaderState.OnDefaultAttribute;
                    attributePSVI = defaultNode.AttInfo;
                    cachedNode = defaultNode;
                    goto Found;
                }
            }
            return false;
        Found:
            if (validationState == ValidatingReaderState.OnReadBinaryContent) {
                readBinaryHelper.Finish();
                validationState = savedState;
            }
            return true;
        }
コード例 #17
0
ファイル: XsdValidatingReader.cs プロジェクト: dotnet/corefx
 // Moves to the next attribute.
 public override bool MoveToNextAttribute()
 {
     if (_currentAttrIndex + 1 < _coreReaderAttributeCount)
     {
         bool moveTo = _coreReader.MoveToNextAttribute();
         Debug.Assert(moveTo);
         _currentAttrIndex++;
         if (_inlineSchemaParser == null)
         {
             _attributePSVI = _attributePSVINodes[_currentAttrIndex];
         }
         else
         {
             _attributePSVI = null;
         }
         _validationState = ValidatingReaderState.OnAttribute;
         goto Found;
     }
     else if (_currentAttrIndex + 1 < _attributeCount)
     { //default attribute
         int defaultIndex = ++_currentAttrIndex - _coreReaderAttributeCount;
         _cachedNode = (ValidatingReaderNodeData)_defaultAttributes[defaultIndex];
         _attributePSVI = _cachedNode.AttInfo;
         _validationState = ValidatingReaderState.OnDefaultAttribute;
         goto Found;
     }
     return false;
 Found:
     if (_validationState == ValidatingReaderState.OnReadBinaryContent)
     {
         _readBinaryHelper.Finish();
         _validationState = _savedState;
     }
     return true;
 }
コード例 #18
0
 // Moves to the attribute with the specified index
 public override void MoveToAttribute(int i) {
     if (i < 0 || i >= attributeCount) {
         throw new ArgumentOutOfRangeException("i");
     }
     currentAttrIndex = i;
     if (i < coreReaderAttributeCount) { //reader attribute
         coreReader.MoveToAttribute(i);
         if (inlineSchemaParser == null) {
             attributePSVI = attributePSVINodes[i];
         }
         else {
             attributePSVI = null;
         }
         validationState = ValidatingReaderState.OnAttribute;
     }
     else { //default attribute
         int defaultIndex = i - coreReaderAttributeCount;
         cachedNode = (ValidatingReaderNodeData)defaultAttributes[defaultIndex];
         attributePSVI = cachedNode.AttInfo;
         validationState = ValidatingReaderState.OnDefaultAttribute;
     }
     if (validationState == ValidatingReaderState.OnReadBinaryContent) {
         readBinaryHelper.Finish();
         validationState = savedState;
     }
 }
 private void ClearAttributesInfo()
 {
     this.attributeCount = 0;
     this.coreReaderAttributeCount = 0;
     this.currentAttrIndex = -1;
     this.defaultAttributes.Clear();
     this.attributePSVI = null;
 }