XDR_CheckAttributeDefault() private method

private XDR_CheckAttributeDefault ( DeclBaseInfo decl, SchemaAttDef pAttdef ) : void
decl DeclBaseInfo
pAttdef SchemaAttDef
return void
Ejemplo n.º 1
0
        private static void XDR_EndRoot(XdrBuilder builder)
        {
            //
            // check undefined attribute types
            // We already checked local attribute types, so only need to check global attribute types here 
            //
            while (builder._UndefinedAttributeTypes != null)
            {
                XmlQualifiedName gname = builder._UndefinedAttributeTypes._TypeName;

                // if there is no URN in this name then the name is local to the
                // schema, but the global attribute was still URN qualified, so
                // we need to qualify this name now.
                if (gname.Namespace.Length == 0)
                {
                    gname = new XmlQualifiedName(gname.Name, builder._TargetNamespace);
                }
                SchemaAttDef ad;
                if (builder._SchemaInfo.AttributeDecls.TryGetValue(gname, out ad))
                {
                    builder._UndefinedAttributeTypes._Attdef = (SchemaAttDef)ad.Clone();
                    builder._UndefinedAttributeTypes._Attdef.Name = gname;
                    builder.XDR_CheckAttributeDefault(builder._UndefinedAttributeTypes, builder._UndefinedAttributeTypes._Attdef);
                }
                else
                {
                    builder.SendValidationEvent(SR.Sch_UndeclaredAttribute, gname.Name);
                }
                builder._UndefinedAttributeTypes = builder._UndefinedAttributeTypes._Next;
            }

            foreach (SchemaElementDecl ed in builder._UndeclaredElements.Values)
            {
                builder.SendValidationEvent(SR.Sch_UndeclaredElement, XmlQualifiedName.ToString(ed.Name.Name, ed.Prefix));
            }
        }
Ejemplo n.º 2
0
        private static void XDR_EndElementType(XdrBuilder builder)
        {
            SchemaElementDecl ed = builder._ElementDef._ElementDecl;

            // check undefined attribute types first
            if (builder._UndefinedAttributeTypes != null && builder._ElementDef._AttDefList != null)
            {
                DeclBaseInfo patt = builder._UndefinedAttributeTypes;
                DeclBaseInfo p1 = patt;

                while (patt != null)
                {
                    SchemaAttDef pAttdef = null;

                    if (patt._ElementDecl == ed)
                    {
                        XmlQualifiedName pName = patt._TypeName;
                        pAttdef = (SchemaAttDef)builder._ElementDef._AttDefList[pName];
                        if (pAttdef != null)
                        {
                            patt._Attdef = (SchemaAttDef)pAttdef.Clone();
                            patt._Attdef.Name = pName;
                            builder.XDR_CheckAttributeDefault(patt, pAttdef);

                            // remove it from _pUndefinedAttributeTypes
                            if (patt == builder._UndefinedAttributeTypes)
                            {
                                patt = builder._UndefinedAttributeTypes = patt._Next;
                                p1 = patt;
                            }
                            else
                            {
                                p1._Next = patt._Next;
                                patt = p1._Next;
                            }
                        }
                    }

                    if (pAttdef == null)
                    {
                        if (patt != builder._UndefinedAttributeTypes)
                            p1 = p1._Next;
                        patt = patt._Next;
                    }
                }
            }

            if (builder._ElementDef._MasterGroupRequired)
            {
                // if the content is mixed, there is a group that need to be closed
                builder._contentValidator.CloseGroup();

                if (!builder._ElementDef._ExistTerminal)
                {
                    if (builder._contentValidator.IsOpen)
                    {
                        builder._ElementDef._ElementDecl.ContentValidator = ContentValidator.Any;
                        builder._contentValidator = null;
                    }
                    else
                    {
                        if (builder._ElementDef._ContentAttr != SchemaContentMixed)
                            builder.SendValidationEvent(SR.Sch_ElementMissing);
                    }
                }
                else
                {
                    if (builder._GroupDef._Order == SchemaOrderMany)
                    {
                        builder._contentValidator.AddStar();
                    }
                }
            }
            if (ed.Datatype != null)
            {
                XmlTokenizedType ttype = ed.Datatype.TokenizedType;
                if (ttype == XmlTokenizedType.ENUMERATION &&
                    !builder._ElementDef._EnumerationRequired)
                {
                    builder.SendValidationEvent(SR.Sch_MissDtvaluesAttribute);
                }

                if (ttype != XmlTokenizedType.ENUMERATION &&
                    builder._ElementDef._EnumerationRequired)
                {
                    builder.SendValidationEvent(SR.Sch_RequireEnumeration);
                }
            }
            CompareMinMaxLength(builder._ElementDef._MinLength, builder._ElementDef._MaxLength, builder);
            ed.MaxLength = (long)builder._ElementDef._MaxLength;
            ed.MinLength = (long)builder._ElementDef._MinLength;

            if (builder._contentValidator != null)
            {
                builder._ElementDef._ElementDecl.ContentValidator = builder._contentValidator.Finish(true);
                builder._contentValidator = null;
            }

            builder._ElementDef._ElementDecl = null;
            builder._ElementDef._AttDefList = null;
        }
Ejemplo n.º 3
0
        private static void XDR_BeginAttribute(XdrBuilder builder)
        {
            if (builder._BaseDecl._TypeName.IsEmpty)
            {
                builder.SendValidationEvent(SR.Sch_MissAttribute);
            }

            SchemaAttDef attdef = null;
            XmlQualifiedName qname = builder._BaseDecl._TypeName;
            string prefix = builder._BaseDecl._Prefix;

            // local?
            if (builder._ElementDef._AttDefList != null)
            {
                attdef = (SchemaAttDef)builder._ElementDef._AttDefList[qname];
            }

            // global?
            if (attdef == null)
            {
                // if there is no URN in this name then the name is local to the
                // schema, but the global attribute was still URN qualified, so
                // we need to qualify this name now.
                XmlQualifiedName gname = qname;
                if (prefix.Length == 0)
                    gname = new XmlQualifiedName(qname.Name, builder._TargetNamespace);
                SchemaAttDef ad;
                if (builder._SchemaInfo.AttributeDecls.TryGetValue(gname, out ad))
                {
                    attdef = (SchemaAttDef)ad.Clone();
                    attdef.Name = qname;
                }
                else if (prefix.Length != 0)
                {
                    builder.SendValidationEvent(SR.Sch_UndeclaredAttribute, XmlQualifiedName.ToString(qname.Name, prefix));
                }
            }

            if (attdef != null)
            {
                builder.XDR_CheckAttributeDefault(builder._BaseDecl, attdef);
            }
            else
            {
                // will process undeclared types later
                attdef = new SchemaAttDef(qname, prefix);
                DeclBaseInfo decl = new DeclBaseInfo();
                decl._Checking = true;
                decl._Attdef = attdef;
                decl._TypeName = builder._BaseDecl._TypeName;
                decl._ElementDecl = builder._ElementDef._ElementDecl;
                decl._MinOccurs = builder._BaseDecl._MinOccurs;
                decl._Default = builder._BaseDecl._Default;

                // add undefined attribute types
                decl._Next = builder._UndefinedAttributeTypes;
                builder._UndefinedAttributeTypes = decl;
            }

            builder._ElementDef._ElementDecl.AddAttDef(attdef);
        }
 private static void XDR_BeginAttribute(XdrBuilder builder)
 {
     if (builder._BaseDecl._TypeName.IsEmpty)
     {
         builder.SendValidationEvent("Sch_MissAttribute");
     }
     SchemaAttDef pAttdef = null;
     XmlQualifiedName name = builder._BaseDecl._TypeName;
     string ns = builder._BaseDecl._Prefix;
     if (builder._ElementDef._AttDefList != null)
     {
         pAttdef = (SchemaAttDef) builder._ElementDef._AttDefList[name];
     }
     if (pAttdef == null)
     {
         SchemaAttDef def2;
         XmlQualifiedName key = name;
         if (ns.Length == 0)
         {
             key = new XmlQualifiedName(name.Name, builder._TargetNamespace);
         }
         if (builder._SchemaInfo.AttributeDecls.TryGetValue(key, out def2))
         {
             pAttdef = def2.Clone();
             pAttdef.Name = name;
         }
         else if (ns.Length != 0)
         {
             builder.SendValidationEvent("Sch_UndeclaredAttribute", XmlQualifiedName.ToString(name.Name, ns));
         }
     }
     if (pAttdef != null)
     {
         builder.XDR_CheckAttributeDefault(builder._BaseDecl, pAttdef);
     }
     else
     {
         pAttdef = new SchemaAttDef(name, ns);
         DeclBaseInfo info = new DeclBaseInfo {
             _Checking = true,
             _Attdef = pAttdef,
             _TypeName = builder._BaseDecl._TypeName,
             _ElementDecl = builder._ElementDef._ElementDecl,
             _MinOccurs = builder._BaseDecl._MinOccurs,
             _Default = builder._BaseDecl._Default,
             _Next = builder._UndefinedAttributeTypes
         };
         builder._UndefinedAttributeTypes = info;
     }
     builder._ElementDef._ElementDecl.AddAttDef(pAttdef);
 }
 private static void XDR_EndRoot(XdrBuilder builder)
 {
     while (builder._UndefinedAttributeTypes != null)
     {
         SchemaAttDef def;
         XmlQualifiedName key = builder._UndefinedAttributeTypes._TypeName;
         if (key.Namespace.Length == 0)
         {
             key = new XmlQualifiedName(key.Name, builder._TargetNamespace);
         }
         if (builder._SchemaInfo.AttributeDecls.TryGetValue(key, out def))
         {
             builder._UndefinedAttributeTypes._Attdef = def.Clone();
             builder._UndefinedAttributeTypes._Attdef.Name = key;
             builder.XDR_CheckAttributeDefault(builder._UndefinedAttributeTypes, builder._UndefinedAttributeTypes._Attdef);
         }
         else
         {
             builder.SendValidationEvent("Sch_UndeclaredAttribute", key.Name);
         }
         builder._UndefinedAttributeTypes = builder._UndefinedAttributeTypes._Next;
     }
     foreach (SchemaElementDecl decl in builder._UndeclaredElements.Values)
     {
         builder.SendValidationEvent("Sch_UndeclaredElement", XmlQualifiedName.ToString(decl.Name.Name, decl.Prefix));
     }
 }
 private static void XDR_EndElementType(XdrBuilder builder)
 {
     SchemaElementDecl decl = builder._ElementDef._ElementDecl;
     if ((builder._UndefinedAttributeTypes != null) && (builder._ElementDef._AttDefList != null))
     {
         DeclBaseInfo info = builder._UndefinedAttributeTypes;
         DeclBaseInfo info2 = info;
         while (info != null)
         {
             SchemaAttDef pAttdef = null;
             if (info._ElementDecl == decl)
             {
                 XmlQualifiedName name = info._TypeName;
                 pAttdef = (SchemaAttDef) builder._ElementDef._AttDefList[name];
                 if (pAttdef != null)
                 {
                     info._Attdef = pAttdef.Clone();
                     info._Attdef.Name = name;
                     builder.XDR_CheckAttributeDefault(info, pAttdef);
                     if (info == builder._UndefinedAttributeTypes)
                     {
                         info = builder._UndefinedAttributeTypes = info._Next;
                         info2 = info;
                     }
                     else
                     {
                         info2._Next = info._Next;
                         info = info2._Next;
                     }
                 }
             }
             if (pAttdef == null)
             {
                 if (info != builder._UndefinedAttributeTypes)
                 {
                     info2 = info2._Next;
                 }
                 info = info._Next;
             }
         }
     }
     if (builder._ElementDef._MasterGroupRequired)
     {
         builder._contentValidator.CloseGroup();
         if (!builder._ElementDef._ExistTerminal)
         {
             if (builder._contentValidator.IsOpen)
             {
                 builder._ElementDef._ElementDecl.ContentValidator = ContentValidator.Any;
                 builder._contentValidator = null;
             }
             else if (builder._ElementDef._ContentAttr != 3)
             {
                 builder.SendValidationEvent("Sch_ElementMissing");
             }
         }
         else if (builder._GroupDef._Order == 1)
         {
             builder._contentValidator.AddStar();
         }
     }
     if (decl.Datatype != null)
     {
         XmlTokenizedType tokenizedType = decl.Datatype.TokenizedType;
         if ((tokenizedType == XmlTokenizedType.ENUMERATION) && !builder._ElementDef._EnumerationRequired)
         {
             builder.SendValidationEvent("Sch_MissDtvaluesAttribute");
         }
         if ((tokenizedType != XmlTokenizedType.ENUMERATION) && builder._ElementDef._EnumerationRequired)
         {
             builder.SendValidationEvent("Sch_RequireEnumeration");
         }
     }
     CompareMinMaxLength(builder._ElementDef._MinLength, builder._ElementDef._MaxLength, builder);
     decl.MaxLength = builder._ElementDef._MaxLength;
     decl.MinLength = builder._ElementDef._MinLength;
     if (builder._contentValidator != null)
     {
         builder._ElementDef._ElementDecl.ContentValidator = builder._contentValidator.Finish(true);
         builder._contentValidator = null;
     }
     builder._ElementDef._ElementDecl = null;
     builder._ElementDef._AttDefList = null;
 }
Ejemplo n.º 7
0
        private static void XDR_EndElementType(XdrBuilder builder) {
            SchemaElementDecl ed = builder._ElementDef._ElementDecl;
            CompiledContentModel content = ed.Content;

            // check undefined attribute types first
            if (builder._UndefinedAttributeTypes != null && builder._ElementDef._AttDefList != null) {
                DeclBaseInfo patt = builder._UndefinedAttributeTypes;
                DeclBaseInfo p1 = patt;

                while (patt != null) {
                    SchemaAttDef pAttdef = null;

                    if (patt._ElementDecl == ed) {
                        XmlQualifiedName pName = patt._TypeName;
                        pAttdef = (SchemaAttDef)builder._ElementDef._AttDefList[pName];
                        if (pAttdef != null) {
                            patt._Attdef = (SchemaAttDef)pAttdef.Clone();
                            patt._Attdef.Name = pName;
                            builder.XDR_CheckAttributeDefault(patt, pAttdef);

                            // remove it from _pUndefinedAttributeTypes
                            if (patt == builder._UndefinedAttributeTypes) {
                                patt = builder._UndefinedAttributeTypes = patt._Next;
                                p1 = patt;
                            }
                            else {
                                p1._Next = patt._Next;
                                patt = p1._Next;
                            }
                        }
                    }

                    if (pAttdef == null) {
                        if (patt != builder._UndefinedAttributeTypes)
                            p1 = p1._Next;
                        patt = patt._Next;
                    }
                }
            }

            if (builder._ElementDef._MasterGroupRequired) {
                if (!builder._ElementDef._ExistTerminal) {
                    if (content.IsOpen) {
                        content.ContentType = CompiledContentModel.Type.Any;
                        // must have something here, since we opened up a group...  since when we have no elements
                        // and content="eltOnly" model="open"  we can have anything here...
                        content.AddTerminal(builder._SchemaNames.QnPCData, null, null);
                    }
                    else {
                        // we must have elements when we say content="eltOnly" model="close"
                        builder.SendValidationEvent(Res.Sch_ElementMissing);
                    }
                }

                // if the content is mixed, there is a group that need to be closed
                content.CloseGroup();

                if (builder._GroupDef._Order == SCHEMA_ORDER_MANY) {
                    content.Star();
                }
            }
            if (ed.Datatype != null) {
                XmlTokenizedType ttype = ed.Datatype.TokenizedType;
                if (ttype == XmlTokenizedType.ENUMERATION && 
                    !builder._ElementDef._EnumerationRequired) {
                    builder.SendValidationEvent(Res.Sch_MissDtvaluesAttribute);
                }

                if (ttype != XmlTokenizedType.ENUMERATION && 
                    builder._ElementDef._EnumerationRequired) {
                    builder.SendValidationEvent(Res.Sch_RequireEnumeration);
                }
            }
            CompareMinMaxLength(builder._ElementDef._MinLength, builder._ElementDef._MaxLength, builder);
            ed.MaxLength = (long)builder._ElementDef._MaxLength;
            ed.MinLength = (long)builder._ElementDef._MinLength;

            content.Finish(builder.validationEventHandler, true);

            builder._ElementDef._ElementDecl = null;
            builder._ElementDef._AttDefList = null;
        }