Пример #1
0
        internal void ValidateDefaultAttributeOnUse(IDtdDefaultAttributeInfo defaultAttribute, XmlTextReaderImpl coreReader)
        {
            SchemaAttDef attdef = defaultAttribute as SchemaAttDef;

            if ((attdef != null) && !attdef.DefaultValueChecked)
            {
                SchemaInfo dtdInfo = coreReader.DtdInfo as SchemaInfo;
                if (dtdInfo != null)
                {
                    DtdValidator.CheckDefaultValue(attdef, dtdInfo, this.eventHandling, coreReader.BaseURI);
                }
            }
        }
        private void SetDefaultAttributeSchemaInfo(XmlSchemaAttribute schemaAttribute)
        {
            this.attributeSchemaInfo.Clear();
            this.attributeSchemaInfo.IsDefault       = true;
            this.attributeSchemaInfo.IsNil           = false;
            this.attributeSchemaInfo.SchemaType      = schemaAttribute.AttributeSchemaType;
            this.attributeSchemaInfo.SchemaAttribute = schemaAttribute;
            SchemaAttDef attDef = schemaAttribute.AttDef;

            if (attDef.Datatype.Variety == XmlSchemaDatatypeVariety.Union)
            {
                XsdSimpleValue defaultValueTyped = attDef.DefaultValueTyped as XsdSimpleValue;
                this.attributeSchemaInfo.MemberType = defaultValueTyped.XmlType;
            }
            this.attributeSchemaInfo.Validity = XmlSchemaValidity.Valid;
        }
Пример #3
0
        internal void ValidateDefaultAttributeOnUse(IDtdDefaultAttributeInfo defaultAttribute, XmlTextReaderImpl coreReader)
        {
            SchemaAttDef attdef = defaultAttribute as SchemaAttDef;

            if (attdef == null)
            {
                return;
            }

            SchemaInfo schemaInfo = coreReader.DtdInfo as SchemaInfo;

            if (schemaInfo == null)
            {
                return;
            }
            DtdValidator.CheckDefaultValue(attdef, schemaInfo, _eventHandling, coreReader.BaseURI);
        }
Пример #4
0
        private void SetDefaultAttributeSchemaInfo(XmlSchemaAttribute schemaAttribute)
        {
            Debug.Assert(_attributeSchemaInfo != null);
            _attributeSchemaInfo.Clear();
            _attributeSchemaInfo.IsDefault       = true;
            _attributeSchemaInfo.IsNil           = false;
            _attributeSchemaInfo.SchemaType      = schemaAttribute.AttributeSchemaType;
            _attributeSchemaInfo.SchemaAttribute = schemaAttribute;

            //Get memberType for default attribute
            SchemaAttDef attributeDef = schemaAttribute.AttDef;

            if (attributeDef.Datatype.Variety == XmlSchemaDatatypeVariety.Union)
            {
                XsdSimpleValue simpleValue = attributeDef.DefaultValueTyped as XsdSimpleValue;
                Debug.Assert(simpleValue != null);
                _attributeSchemaInfo.MemberType = simpleValue.XmlType;
            }
            _attributeSchemaInfo.Validity = XmlSchemaValidity.Valid;
        }
Пример #5
0
        private void LoadDocumentType(IDtdInfo dtdInfo, XmlDocumentType dtNode)
        {
            SchemaInfo schInfo = dtdInfo as SchemaInfo;

            if (schInfo == null)
            {
                throw new XmlException(SR.Xml_InternalError, string.Empty);
            }

            dtNode.DtdSchemaInfo = schInfo;
            if (schInfo != null)
            {
                //set the schema information into the document
                _doc.DtdSchemaInfo = schInfo;

                // Notation hashtable
                if (schInfo.Notations != null)
                {
                    foreach (SchemaNotation scNot in schInfo.Notations.Values)
                    {
                        dtNode.Notations.SetNamedItem(new XmlNotation(scNot.Name.Name, scNot.Pubid, scNot.SystemLiteral, _doc));
                    }
                }

                // Entity hashtables
                if (schInfo.GeneralEntities != null)
                {
                    foreach (SchemaEntity scEnt in schInfo.GeneralEntities.Values)
                    {
                        XmlEntity ent = new XmlEntity(scEnt.Name.Name, scEnt.Text, scEnt.Pubid, scEnt.Url, scEnt.NData.IsEmpty ? null : scEnt.NData.Name, _doc);
                        ent.SetBaseURI(scEnt.DeclaredURI);
                        dtNode.Entities.SetNamedItem(ent);
                    }
                }

                if (schInfo.ParameterEntities != null)
                {
                    foreach (SchemaEntity scEnt in schInfo.ParameterEntities.Values)
                    {
                        XmlEntity ent = new XmlEntity(scEnt.Name.Name, scEnt.Text, scEnt.Pubid, scEnt.Url, scEnt.NData.IsEmpty ? null : scEnt.NData.Name, _doc);
                        ent.SetBaseURI(scEnt.DeclaredURI);
                        dtNode.Entities.SetNamedItem(ent);
                    }
                }
                _doc.Entities = dtNode.Entities;

                //extract the elements which has attribute defined as ID from the element declarations
                IDictionaryEnumerator elementDecls = schInfo.ElementDecls.GetEnumerator();
                if (elementDecls != null)
                {
                    elementDecls.Reset();
                    while (elementDecls.MoveNext())
                    {
                        SchemaElementDecl elementDecl = (SchemaElementDecl)elementDecls.Value;
                        if (elementDecl.AttDefs != null)
                        {
                            IDictionaryEnumerator attDefs = elementDecl.AttDefs.GetEnumerator();
                            while (attDefs.MoveNext())
                            {
                                SchemaAttDef attdef = (SchemaAttDef)attDefs.Value;
                                if (attdef.Datatype.TokenizedType == XmlTokenizedType.ID)
                                {
                                    //we only register the XmlElement based on their Prefix/LocalName and skip the namespace
                                    _doc.AddIdInfo(
                                        _doc.AddXmlName(elementDecl.Prefix, elementDecl.Name.Name, string.Empty, null),
                                        _doc.AddAttrXmlName(attdef.Prefix, attdef.Name.Name, string.Empty, null));
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
 internal bool AddDefaultAttribute(SchemaAttDef attdef)
 {
     return(coreReaderImpl.AddDefaultAttributeNonDtd(attdef));
 }
Пример #7
0
        private void LoadDocumentType(IDtdInfo dtdInfo, XmlDocumentType dtNode)
        {
            SchemaInfo info = dtdInfo as SchemaInfo;

            if (info == null)
            {
                throw new XmlException("Xml_InternalError", string.Empty);
            }
            dtNode.DtdSchemaInfo = info;
            if (info != null)
            {
                this.doc.DtdSchemaInfo = info;
                if (info.Notations != null)
                {
                    foreach (SchemaNotation notation in info.Notations.Values)
                    {
                        dtNode.Notations.SetNamedItem(new XmlNotation(notation.Name.Name, notation.Pubid, notation.SystemLiteral, this.doc));
                    }
                }
                if (info.GeneralEntities != null)
                {
                    foreach (SchemaEntity entity in info.GeneralEntities.Values)
                    {
                        XmlEntity node = new XmlEntity(entity.Name.Name, entity.Text, entity.Pubid, entity.Url, entity.NData.IsEmpty ? null : entity.NData.Name, this.doc);
                        node.SetBaseURI(entity.DeclaredURI);
                        dtNode.Entities.SetNamedItem(node);
                    }
                }
                if (info.ParameterEntities != null)
                {
                    foreach (SchemaEntity entity3 in info.ParameterEntities.Values)
                    {
                        XmlEntity entity4 = new XmlEntity(entity3.Name.Name, entity3.Text, entity3.Pubid, entity3.Url, entity3.NData.IsEmpty ? null : entity3.NData.Name, this.doc);
                        entity4.SetBaseURI(entity3.DeclaredURI);
                        dtNode.Entities.SetNamedItem(entity4);
                    }
                }
                this.doc.Entities = dtNode.Entities;
                IDictionaryEnumerator enumerator = info.ElementDecls.GetEnumerator();
                if (enumerator != null)
                {
                    enumerator.Reset();
                    while (enumerator.MoveNext())
                    {
                        SchemaElementDecl decl = (SchemaElementDecl)enumerator.Value;
                        if (decl.AttDefs != null)
                        {
                            IDictionaryEnumerator enumerator2 = decl.AttDefs.GetEnumerator();
                            while (enumerator2.MoveNext())
                            {
                                SchemaAttDef def = (SchemaAttDef)enumerator2.Value;
                                if (def.Datatype.TokenizedType == XmlTokenizedType.ID)
                                {
                                    this.doc.AddIdInfo(this.doc.AddXmlName(decl.Prefix, decl.Name.Name, string.Empty, null), this.doc.AddAttrXmlName(def.Prefix, def.Name.Name, string.Empty, null));
                                    continue;
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #8
0
        private void LoadDocumentType(XmlValidatingReader vr, XmlDocumentType dtNode)
        {
            SchemaInfo schInfo = vr.GetSchemaInfo();

            if (schInfo != null)
            {
                //set the schema information into the document
                doc.SchemaInformation = schInfo;

                // Notation hashtable
                if (schInfo.Notations != null)
                {
                    foreach (SchemaNotation scNot in schInfo.Notations.Values)
                    {
                        dtNode.Notations.SetNamedItem(new XmlNotation(scNot.Name.Name, scNot.Pubid, scNot.SystemLiteral, doc));
                    }
                }

                // Entity hashtables
                if (schInfo.GeneralEntities != null)
                {
                    foreach (SchemaEntity scEnt in schInfo.GeneralEntities.Values)
                    {
                        XmlEntity ent = new XmlEntity(scEnt.Name.Name, scEnt.Text, scEnt.Pubid, scEnt.Url, scEnt.NData.IsEmpty ? null : scEnt.NData.Name, doc);
                        ent.SetBaseURI(scEnt.DeclaredURI);
                        dtNode.Entities.SetNamedItem(ent);
                    }
                }

                if (schInfo.ParameterEntities != null)
                {
                    foreach (SchemaEntity scEnt in schInfo.ParameterEntities.Values)
                    {
                        XmlEntity ent = new XmlEntity(scEnt.Name.Name, scEnt.Text, scEnt.Pubid, scEnt.Url, scEnt.NData.IsEmpty ? null : scEnt.NData.Name, doc);
                        ent.SetBaseURI(scEnt.DeclaredURI);
                        dtNode.Entities.SetNamedItem(ent);
                    }
                }
                doc.Entities = dtNode.Entities;

                //extract the elements which has attribute defined as ID from the element declarations
                IDictionaryEnumerator elementDecls = schInfo.ElementDecls.GetEnumerator();
                if (elementDecls != null)
                {
                    elementDecls.Reset();
                    while (elementDecls.MoveNext())
                    {
                        SchemaElementDecl elementDecl = (SchemaElementDecl)elementDecls.Value;
                        if (elementDecl.AttDefs != null)
                        {
                            IDictionaryEnumerator attDefs = elementDecl.AttDefs.GetEnumerator();
                            while (attDefs.MoveNext())
                            {
                                SchemaAttDef attdef = (SchemaAttDef)attDefs.Value;
                                if (attdef.Datatype.TokenizedType == XmlTokenizedType.ID)
                                {
                                    doc.AddIdInfo(
                                        doc.GetXmlName(elementDecl.Name.Name, elementDecl.Name.Namespace),
                                        doc.GetXmlName(attdef.Name.Name, attdef.Name.Namespace));
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }