private void CompileSimpleContentExtension(XmlSchemaComplexType complexType, XmlSchemaSimpleContentExtension simpleExtension)
 {
     XmlSchemaComplexType redefined = null;
     if ((complexType.Redefined != null) && (simpleExtension.BaseTypeName == complexType.Redefined.QualifiedName))
     {
         redefined = (XmlSchemaComplexType) complexType.Redefined;
         this.CompileComplexType(redefined);
         complexType.SetBaseSchemaType(redefined);
         complexType.SetDatatype(redefined.Datatype);
     }
     else
     {
         XmlSchemaType anySchemaType = this.GetAnySchemaType(simpleExtension.BaseTypeName);
         if (anySchemaType == null)
         {
             base.SendValidationEvent("Sch_UndeclaredType", simpleExtension.BaseTypeName.ToString(), complexType);
         }
         else
         {
             complexType.SetBaseSchemaType(anySchemaType);
             complexType.SetDatatype(anySchemaType.Datatype);
         }
         redefined = anySchemaType as XmlSchemaComplexType;
     }
     if (redefined != null)
     {
         if ((redefined.FinalResolved & XmlSchemaDerivationMethod.Extension) != XmlSchemaDerivationMethod.Empty)
         {
             base.SendValidationEvent("Sch_BaseFinalExtension", complexType);
         }
         if (redefined.ContentType != XmlSchemaContentType.TextOnly)
         {
             base.SendValidationEvent("Sch_NotSimpleContent", complexType);
         }
     }
     complexType.SetDerivedBy(XmlSchemaDerivationMethod.Extension);
     this.CompileLocalAttributes(redefined, complexType, simpleExtension.Attributes, simpleExtension.AnyAttribute, XmlSchemaDerivationMethod.Extension);
 }
 private void CompileSimpleContentRestriction(XmlSchemaComplexType complexType, XmlSchemaSimpleContentRestriction simpleRestriction)
 {
     XmlSchemaComplexType redefined = null;
     XmlSchemaDatatype datatype = null;
     if ((complexType.Redefined != null) && (simpleRestriction.BaseTypeName == complexType.Redefined.QualifiedName))
     {
         redefined = (XmlSchemaComplexType) complexType.Redefined;
         this.CompileComplexType(redefined);
         datatype = redefined.Datatype;
     }
     else
     {
         redefined = this.GetComplexType(simpleRestriction.BaseTypeName);
         if (redefined == null)
         {
             base.SendValidationEvent("Sch_UndefBaseRestriction", simpleRestriction.BaseTypeName.ToString(), simpleRestriction);
             return;
         }
         if (redefined.ContentType == XmlSchemaContentType.TextOnly)
         {
             if (simpleRestriction.BaseType == null)
             {
                 datatype = redefined.Datatype;
             }
             else
             {
                 this.CompileSimpleType(simpleRestriction.BaseType);
                 if (!XmlSchemaType.IsDerivedFromDatatype(simpleRestriction.BaseType.Datatype, redefined.Datatype, XmlSchemaDerivationMethod.None))
                 {
                     base.SendValidationEvent("Sch_DerivedNotFromBase", simpleRestriction);
                 }
                 datatype = simpleRestriction.BaseType.Datatype;
             }
         }
         else if ((redefined.ContentType == XmlSchemaContentType.Mixed) && redefined.ElementDecl.ContentValidator.IsEmptiable)
         {
             if (simpleRestriction.BaseType != null)
             {
                 this.CompileSimpleType(simpleRestriction.BaseType);
                 complexType.SetBaseSchemaType(simpleRestriction.BaseType);
                 datatype = simpleRestriction.BaseType.Datatype;
             }
             else
             {
                 base.SendValidationEvent("Sch_NeedSimpleTypeChild", simpleRestriction);
             }
         }
         else
         {
             base.SendValidationEvent("Sch_NotSimpleContent", complexType);
         }
     }
     if (((redefined != null) && (redefined.ElementDecl != null)) && ((redefined.FinalResolved & XmlSchemaDerivationMethod.Restriction) != XmlSchemaDerivationMethod.Empty))
     {
         base.SendValidationEvent("Sch_BaseFinalRestriction", complexType);
     }
     if (redefined != null)
     {
         complexType.SetBaseSchemaType(redefined);
     }
     if (datatype != null)
     {
         try
         {
             complexType.SetDatatype(datatype.DeriveByRestriction(simpleRestriction.Facets, base.NameTable, complexType));
         }
         catch (XmlSchemaException exception)
         {
             if (exception.SourceSchemaObject == null)
             {
                 exception.SetSource(complexType);
             }
             base.SendValidationEvent(exception);
             complexType.SetDatatype(DatatypeImplementation.AnySimpleType.Datatype);
         }
     }
     complexType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction);
     this.CompileLocalAttributes(redefined, complexType, simpleRestriction.Attributes, simpleRestriction.AnyAttribute, XmlSchemaDerivationMethod.Restriction);
 }
 private void CompileComplexContentRestriction(XmlSchemaComplexType complexType, XmlSchemaComplexContent complexContent, XmlSchemaComplexContentRestriction complexRestriction)
 {
     XmlSchemaComplexType redefined = null;
     if ((complexType.Redefined != null) && (complexRestriction.BaseTypeName == complexType.Redefined.QualifiedName))
     {
         redefined = (XmlSchemaComplexType) complexType.Redefined;
         this.CompileComplexType(redefined);
     }
     else
     {
         redefined = this.GetComplexType(complexRestriction.BaseTypeName);
         if (redefined == null)
         {
             base.SendValidationEvent("Sch_UndefBaseRestriction", complexRestriction.BaseTypeName.ToString(), complexRestriction);
             return;
         }
     }
     if (((redefined != null) && (redefined.ElementDecl != null)) && (redefined.ContentType == XmlSchemaContentType.TextOnly))
     {
         base.SendValidationEvent("Sch_NotComplexContent", complexType);
     }
     else
     {
         complexType.SetBaseSchemaType(redefined);
         if ((redefined.FinalResolved & XmlSchemaDerivationMethod.Restriction) != XmlSchemaDerivationMethod.Empty)
         {
             base.SendValidationEvent("Sch_BaseFinalRestriction", complexType);
         }
         this.CompileLocalAttributes(redefined, complexType, complexRestriction.Attributes, complexRestriction.AnyAttribute, XmlSchemaDerivationMethod.Restriction);
         complexType.SetContentTypeParticle(this.CompileContentTypeParticle(complexRestriction.Particle, true));
         complexType.SetContentType(this.GetSchemaContentType(complexType, complexContent, complexType.ContentTypeParticle));
         if (complexType.ContentType == XmlSchemaContentType.Empty)
         {
             SchemaElementDecl elementDecl = redefined.ElementDecl;
             if ((redefined.ElementDecl != null) && !redefined.ElementDecl.ContentValidator.IsEmptiable)
             {
                 base.SendValidationEvent("Sch_InvalidContentRestriction", complexType);
             }
         }
         complexType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction);
     }
 }
 private void CompileComplexType(XmlSchemaComplexType complexType)
 {
     if (complexType.ElementDecl == null)
     {
         if (complexType.IsProcessing)
         {
             base.SendValidationEvent("Sch_TypeCircularRef", complexType);
         }
         else
         {
             complexType.IsProcessing = true;
             if (complexType.ContentModel != null)
             {
                 if (complexType.ContentModel is XmlSchemaSimpleContent)
                 {
                     XmlSchemaSimpleContent contentModel = (XmlSchemaSimpleContent) complexType.ContentModel;
                     complexType.SetContentType(XmlSchemaContentType.TextOnly);
                     if (contentModel.Content is XmlSchemaSimpleContentExtension)
                     {
                         this.CompileSimpleContentExtension(complexType, (XmlSchemaSimpleContentExtension) contentModel.Content);
                     }
                     else
                     {
                         this.CompileSimpleContentRestriction(complexType, (XmlSchemaSimpleContentRestriction) contentModel.Content);
                     }
                 }
                 else
                 {
                     XmlSchemaComplexContent complexContent = (XmlSchemaComplexContent) complexType.ContentModel;
                     if (complexContent.Content is XmlSchemaComplexContentExtension)
                     {
                         this.CompileComplexContentExtension(complexType, complexContent, (XmlSchemaComplexContentExtension) complexContent.Content);
                     }
                     else
                     {
                         this.CompileComplexContentRestriction(complexType, complexContent, (XmlSchemaComplexContentRestriction) complexContent.Content);
                     }
                 }
             }
             else
             {
                 complexType.SetBaseSchemaType(XmlSchemaComplexType.AnyType);
                 this.CompileLocalAttributes(XmlSchemaComplexType.AnyType, complexType, complexType.Attributes, complexType.AnyAttribute, XmlSchemaDerivationMethod.Restriction);
                 complexType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction);
                 complexType.SetContentTypeParticle(this.CompileContentTypeParticle(complexType.Particle, true));
                 complexType.SetContentType(this.GetSchemaContentType(complexType, null, complexType.ContentTypeParticle));
             }
             bool flag = false;
             foreach (XmlSchemaAttribute attribute in complexType.AttributeUses.Values)
             {
                 if (attribute.Use != XmlSchemaUse.Prohibited)
                 {
                     XmlSchemaDatatype datatype = attribute.Datatype;
                     if ((datatype != null) && (datatype.TokenizedType == XmlTokenizedType.ID))
                     {
                         if (flag)
                         {
                             base.SendValidationEvent("Sch_TwoIdAttrUses", complexType);
                         }
                         else
                         {
                             flag = true;
                         }
                     }
                 }
             }
             SchemaElementDecl decl = new SchemaElementDecl {
                 ContentValidator = this.CompileComplexContent(complexType),
                 SchemaType = complexType,
                 IsAbstract = complexType.IsAbstract,
                 Datatype = complexType.Datatype,
                 Block = complexType.BlockResolved,
                 AnyAttribute = complexType.AttributeWildcard
             };
             foreach (XmlSchemaAttribute attribute2 in complexType.AttributeUses.Values)
             {
                 if (attribute2.Use == XmlSchemaUse.Prohibited)
                 {
                     if (!decl.ProhibitedAttributes.ContainsKey(attribute2.QualifiedName))
                     {
                         decl.ProhibitedAttributes.Add(attribute2.QualifiedName, attribute2.QualifiedName);
                     }
                 }
                 else if ((!decl.AttDefs.ContainsKey(attribute2.QualifiedName) && (attribute2.AttDef != null)) && ((attribute2.AttDef.Name != XmlQualifiedName.Empty) && (attribute2.AttDef != SchemaAttDef.Empty)))
                 {
                     decl.AddAttDef(attribute2.AttDef);
                 }
             }
             complexType.ElementDecl = decl;
             complexType.IsProcessing = false;
         }
     }
 }
コード例 #5
0
        private void CompileComplexContentRestriction(XmlSchemaComplexType complexType, XmlSchemaComplexContent complexContent, XmlSchemaComplexContentRestriction complexRestriction) {
            XmlSchemaComplexType baseType = null;
            if (complexType.Redefined != null && complexRestriction.BaseTypeName == complexType.Redefined.QualifiedName) {
                baseType = (XmlSchemaComplexType)complexType.Redefined;
                CompileComplexType(baseType);
            }
            else {
                baseType = GetComplexType(complexRestriction.BaseTypeName);
                if (baseType == null) {
                    SendValidationEvent(Res.Sch_UndefBaseRestriction, complexRestriction.BaseTypeName.ToString(), complexRestriction);   
                    return;
                }
            } 
            complexType.SetBaseSchemaType(baseType);
            if ((baseType.FinalResolved & XmlSchemaDerivationMethod.Restriction) != 0) {
                SendValidationEvent(Res.Sch_BaseFinalRestriction, complexType);
            }
            CompileLocalAttributes(baseType, complexType, complexRestriction.Attributes, complexRestriction.AnyAttribute, XmlSchemaDerivationMethod.Restriction);
            
            complexType.SetContentTypeParticle(CompileContentTypeParticle(complexRestriction.Particle));
            XmlSchemaContentType derivedContentType = GetSchemaContentType(complexType, complexContent, complexType.ContentTypeParticle);
            complexType.SetContentType(derivedContentType);
            switch(derivedContentType) {
                case XmlSchemaContentType.Empty:
                    if (baseType.ElementDecl != null && !baseType.ElementDecl.ContentValidator.IsEmptiable) { //base is either TextOnly or its ElementOnly/Mixed and not emptiable 
                        SendValidationEvent(Res.Sch_InvalidContentRestrictionDetailed, Res.GetString(Res.Sch_InvalidBaseToEmpty), complexType);
                    }
                break;

                case XmlSchemaContentType.Mixed:
                    if (baseType.ContentType != XmlSchemaContentType.Mixed) {
                        SendValidationEvent(Res.Sch_InvalidContentRestrictionDetailed, Res.GetString(Res.Sch_InvalidBaseToMixed), complexType);
                    }
                break;
            }
            complexType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction);
        }
 private void CompileComplexContentExtension(XmlSchemaComplexType complexType, XmlSchemaComplexContent complexContent, XmlSchemaComplexContentExtension complexExtension)
 {
     XmlSchemaComplexType redefined = null;
     if ((complexType.Redefined != null) && (complexExtension.BaseTypeName == complexType.Redefined.QualifiedName))
     {
         redefined = (XmlSchemaComplexType) complexType.Redefined;
         this.CompileComplexType(redefined);
     }
     else
     {
         redefined = this.GetComplexType(complexExtension.BaseTypeName);
         if (redefined == null)
         {
             base.SendValidationEvent("Sch_UndefBaseExtension", complexExtension.BaseTypeName.ToString(), complexExtension);
             return;
         }
     }
     if (((redefined != null) && (redefined.ElementDecl != null)) && (redefined.ContentType == XmlSchemaContentType.TextOnly))
     {
         base.SendValidationEvent("Sch_NotComplexContent", complexType);
     }
     else
     {
         complexType.SetBaseSchemaType(redefined);
         if ((redefined.FinalResolved & XmlSchemaDerivationMethod.Extension) != XmlSchemaDerivationMethod.Empty)
         {
             base.SendValidationEvent("Sch_BaseFinalExtension", complexType);
         }
         this.CompileLocalAttributes(redefined, complexType, complexExtension.Attributes, complexExtension.AnyAttribute, XmlSchemaDerivationMethod.Extension);
         XmlSchemaParticle contentTypeParticle = redefined.ContentTypeParticle;
         XmlSchemaParticle item = this.CannonicalizeParticle(complexExtension.Particle, true, true);
         if (contentTypeParticle != XmlSchemaParticle.Empty)
         {
             if (item != XmlSchemaParticle.Empty)
             {
                 XmlSchemaSequence particle = new XmlSchemaSequence();
                 particle.Items.Add(contentTypeParticle);
                 particle.Items.Add(item);
                 complexType.SetContentTypeParticle(this.CompileContentTypeParticle(particle, false));
             }
             else
             {
                 complexType.SetContentTypeParticle(contentTypeParticle);
             }
             XmlSchemaContentType contentType = this.GetSchemaContentType(complexType, complexContent, item);
             if (contentType == XmlSchemaContentType.Empty)
             {
                 contentType = redefined.ContentType;
             }
             complexType.SetContentType(contentType);
             if (complexType.ContentType != redefined.ContentType)
             {
                 base.SendValidationEvent("Sch_DifContentType", complexType);
             }
         }
         else
         {
             complexType.SetContentTypeParticle(item);
             complexType.SetContentType(this.GetSchemaContentType(complexType, complexContent, complexType.ContentTypeParticle));
         }
         complexType.SetDerivedBy(XmlSchemaDerivationMethod.Extension);
     }
 }
コード例 #7
0
 private void CompileSimpleContentRestriction(XmlSchemaComplexType complexType, XmlSchemaSimpleContentRestriction simpleRestriction) {
     XmlSchemaComplexType baseType = null;
     XmlSchemaDatatype datatype = null;
     if (complexType.Redefined != null && simpleRestriction.BaseTypeName == complexType.Redefined.QualifiedName) {
         baseType = (XmlSchemaComplexType)complexType.Redefined;
         CompileComplexType(baseType);
         datatype = baseType.Datatype;
     }
     else {
         baseType = GetComplexType(simpleRestriction.BaseTypeName);
         if (baseType == null) {
             SendValidationEvent(Res.Sch_UndefBaseRestriction, simpleRestriction.BaseTypeName.ToString(), simpleRestriction);
             return;
         }
         if (baseType.ContentType == XmlSchemaContentType.TextOnly) {
             if (simpleRestriction.BaseType == null) { 
                 datatype = baseType.Datatype; 
                 //There is a bug here. Need to check if simpleRestriction has facets.
                 //If yes, Need tp apply these facets as well. 
             }
             else {
                 CompileSimpleType(simpleRestriction.BaseType);
                 if(!XmlSchemaType.IsDerivedFromDatatype(simpleRestriction.BaseType.Datatype, baseType.Datatype, XmlSchemaDerivationMethod.None)) {
                    SendValidationEvent(Res.Sch_DerivedNotFromBase, simpleRestriction);
                 }
                 datatype = simpleRestriction.BaseType.Datatype;
             }
         }
         else if (baseType.ContentType == XmlSchemaContentType.Mixed && baseType.ElementDecl.ContentValidator.IsEmptiable) {
             if (simpleRestriction.BaseType != null) {
                 CompileSimpleType(simpleRestriction.BaseType);
                 complexType.SetBaseSchemaType(simpleRestriction.BaseType);
                 datatype = simpleRestriction.BaseType.Datatype;
             }
             else {
                 SendValidationEvent(Res.Sch_NeedSimpleTypeChild, simpleRestriction);
             }
         }
         else {
             SendValidationEvent(Res.Sch_NotSimpleContent, complexType);
         }
     }
     if (baseType != null && baseType.ElementDecl != null) {
         if ((baseType.FinalResolved & XmlSchemaDerivationMethod.Restriction) != 0) {
             SendValidationEvent(Res.Sch_BaseFinalRestriction, complexType);
         }
     }
     if (baseType != null) {
         complexType.SetBaseSchemaType(baseType);
     }
     if (datatype != null) {
         try {
             complexType.SetDatatype(datatype.DeriveByRestriction(simpleRestriction.Facets, NameTable, complexType));
         }
         catch (XmlSchemaException e) {
             if (e.SourceSchemaObject == null) {
                 e.SetSource(complexType);
             }
             SendValidationEvent(e);
             complexType.SetDatatype(DatatypeImplementation.AnySimpleType.Datatype);
         } 
     }
     complexType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction);
     CompileLocalAttributes(baseType, complexType, simpleRestriction.Attributes, simpleRestriction.AnyAttribute, XmlSchemaDerivationMethod.Restriction);
 }
コード例 #8
0
        private void CompileComplexContentExtension(XmlSchemaComplexType complexType, XmlSchemaComplexContent complexContent, XmlSchemaComplexContentExtension complexExtension) {
            XmlSchemaComplexType baseType = null;
            if (complexType.Redefined != null && complexExtension.BaseTypeName == complexType.Redefined.QualifiedName) {
                baseType = (XmlSchemaComplexType)complexType.Redefined;
                CompileComplexType(baseType);
            }
            else {
                baseType = GetComplexType(complexExtension.BaseTypeName);
                if (baseType == null) {
                    SendValidationEvent(Res.Sch_UndefBaseExtension, complexExtension.BaseTypeName.ToString(), complexExtension);   
                    return;
                }
            }
            if ((baseType.FinalResolved & XmlSchemaDerivationMethod.Extension) != 0) {
                SendValidationEvent(Res.Sch_BaseFinalExtension, complexType);
            }
            CompileLocalAttributes(baseType, complexType, complexExtension.Attributes, complexExtension.AnyAttribute, XmlSchemaDerivationMethod.Extension);

            XmlSchemaParticle baseParticle = baseType.ContentTypeParticle;
            XmlSchemaParticle extendedParticle = CannonicalizeParticle(complexExtension.Particle, true);
            if (baseParticle != XmlSchemaParticle.Empty) {
                if (extendedParticle != XmlSchemaParticle.Empty) {
                    XmlSchemaSequence compiledParticle = new XmlSchemaSequence();
                    compiledParticle.Items.Add(baseParticle);
                    compiledParticle.Items.Add(extendedParticle);
                    complexType.SetContentTypeParticle(CompileContentTypeParticle(compiledParticle));
                }
                else {
                    complexType.SetContentTypeParticle(baseParticle);
                }
            }
            else {
                complexType.SetContentTypeParticle(extendedParticle);
            }
            XmlSchemaContentType contentType = GetSchemaContentType(complexType, complexContent, extendedParticle);
            if (contentType == XmlSchemaContentType.Empty) { //Derived content type is empty, Get ContentType from base
                contentType = baseType.ContentType;
                // In case of a simple base type (content type is TextOnly) the derived type
                //   will be the same as the base type. So set the same content type and then also
                //   set the same data type.
                if (contentType == XmlSchemaContentType.TextOnly) {
                    complexType.SetDatatype(baseType.Datatype);
                }
            }
            complexType.SetContentType(contentType);

            if (baseType.ContentType != XmlSchemaContentType.Empty && complexType.ContentType != baseType.ContentType) { //If base is empty, do not check
                SendValidationEvent(Res.Sch_DifContentType, complexType);
                return;
            }
            complexType.SetBaseSchemaType(baseType);
            complexType.SetDerivedBy(XmlSchemaDerivationMethod.Extension);
        }
コード例 #9
0
 private void CompileSimpleContentExtension(XmlSchemaComplexType complexType, XmlSchemaSimpleContentExtension simpleExtension) {
     XmlSchemaComplexType baseType = null;
     if (complexType.Redefined != null && simpleExtension.BaseTypeName == complexType.Redefined.QualifiedName) {
         baseType = (XmlSchemaComplexType)complexType.Redefined;
         CompileComplexType(baseType);
         complexType.SetBaseSchemaType(baseType);
         complexType.SetDatatype(baseType.Datatype);
     }
     else {
         XmlSchemaType bto = GetAnySchemaType(simpleExtension.BaseTypeName);
         if (bto == null) {
             SendValidationEvent(Res.Sch_UndeclaredType, simpleExtension.BaseTypeName.ToString(), simpleExtension);   
         } 
         else {
             complexType.SetBaseSchemaType(bto);
             complexType.SetDatatype(bto.Datatype);
         }
         baseType = bto as XmlSchemaComplexType;
     }
     if (baseType != null) {
         if ((baseType.FinalResolved & XmlSchemaDerivationMethod.Extension) != 0) {
             SendValidationEvent(Res.Sch_BaseFinalExtension, complexType);
         }
         if (baseType.ContentType != XmlSchemaContentType.TextOnly) {
             SendValidationEvent(Res.Sch_NotSimpleContent, complexType);
         }
     } 
     complexType.SetDerivedBy(XmlSchemaDerivationMethod.Extension);
     CompileLocalAttributes(baseType, complexType, simpleExtension.Attributes, simpleExtension.AnyAttribute, XmlSchemaDerivationMethod.Extension);
 }
コード例 #10
0
 private void CompileComplexType(XmlSchemaComplexType complexType) {
     if (complexType.ElementDecl != null) { //already compiled
         return;
     }
     if (complexType.IsProcessing) {
         SendValidationEvent(Res.Sch_TypeCircularRef, complexType);
         return;
     }
     complexType.IsProcessing = true;
     try {
         if (complexType.ContentModel != null) { //simpleContent or complexContent
             if (complexType.ContentModel is XmlSchemaSimpleContent) {
                 XmlSchemaSimpleContent simpleContent = (XmlSchemaSimpleContent)complexType.ContentModel;
                 complexType.SetContentType(XmlSchemaContentType.TextOnly);
                 if (simpleContent.Content is XmlSchemaSimpleContentExtension) {
                     CompileSimpleContentExtension(complexType, (XmlSchemaSimpleContentExtension)simpleContent.Content);
                 }
                 else { //simpleContent.Content is XmlSchemaSimpleContentRestriction
                     CompileSimpleContentRestriction(complexType, (XmlSchemaSimpleContentRestriction)simpleContent.Content);
                 }
             }
             else { // complexType.ContentModel is XmlSchemaComplexContent
                 XmlSchemaComplexContent complexContent = (XmlSchemaComplexContent)complexType.ContentModel;
                 if (complexContent.Content is XmlSchemaComplexContentExtension) {
                     CompileComplexContentExtension(complexType, complexContent, (XmlSchemaComplexContentExtension)complexContent.Content);
                 }
                 else { // complexContent.Content is XmlSchemaComplexContentRestriction
                     CompileComplexContentRestriction(complexType, complexContent, (XmlSchemaComplexContentRestriction)complexContent.Content);
                 }
             }
         }
         else { //equals XmlSchemaComplexContent with baseType is anyType
                 complexType.SetBaseSchemaType(XmlSchemaComplexType.AnyType);
                 CompileLocalAttributes(XmlSchemaComplexType.AnyType, complexType, complexType.Attributes, complexType.AnyAttribute, XmlSchemaDerivationMethod.Restriction);
                 complexType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction);
                 complexType.SetContentTypeParticle(CompileContentTypeParticle(complexType.Particle));
                 complexType.SetContentType(GetSchemaContentType(complexType, null, complexType.ContentTypeParticle));
         }
         if (complexType.ContainsIdAttribute(true)) {
             SendValidationEvent(Res.Sch_TwoIdAttrUses, complexType);
         }
         SchemaElementDecl decl = new SchemaElementDecl();
         decl.ContentValidator = CompileComplexContent(complexType);
         decl.SchemaType = complexType;
         decl.IsAbstract = complexType.IsAbstract;
         decl.Datatype = complexType.Datatype;
         decl.Block = complexType.BlockResolved;
         decl.AnyAttribute = complexType.AttributeWildcard;
         foreach(XmlSchemaAttribute attribute in complexType.AttributeUses.Values) {
             if (attribute.Use == XmlSchemaUse.Prohibited) {
                 if (!decl.ProhibitedAttributes.ContainsKey(attribute.QualifiedName)) {
                     decl.ProhibitedAttributes.Add(attribute.QualifiedName, attribute.QualifiedName);
                 }
             }
             else {
                 if (!decl.AttDefs.ContainsKey(attribute.QualifiedName) && attribute.AttDef != null && attribute.AttDef.Name != XmlQualifiedName.Empty && attribute.AttDef != SchemaAttDef.Empty) {
                     decl.AddAttDef(attribute.AttDef);
                 }
             }
         }
         complexType.ElementDecl = decl;
     }
     finally {
         complexType.IsProcessing = false;
     }
 }
コード例 #11
0
        private void CompileComplexContentRestriction(XmlSchemaComplexType complexType, XmlSchemaComplexContent complexContent, XmlSchemaComplexContentRestriction complexRestriction)
        {
            XmlSchemaComplexType redefined = null;
            if ((complexType.Redefined != null) && (complexRestriction.BaseTypeName == complexType.Redefined.QualifiedName))
            {
                redefined = (XmlSchemaComplexType) complexType.Redefined;
                this.CompileComplexType(redefined);
            }
            else
            {
                redefined = this.GetComplexType(complexRestriction.BaseTypeName);
                if (redefined == null)
                {
                    base.SendValidationEvent("Sch_UndefBaseRestriction", complexRestriction.BaseTypeName.ToString(), complexRestriction);
                    return;
                }
            }
            complexType.SetBaseSchemaType(redefined);
            if ((redefined.FinalResolved & XmlSchemaDerivationMethod.Restriction) != XmlSchemaDerivationMethod.Empty)
            {
                base.SendValidationEvent("Sch_BaseFinalRestriction", complexType);
            }
            this.CompileLocalAttributes(redefined, complexType, complexRestriction.Attributes, complexRestriction.AnyAttribute, XmlSchemaDerivationMethod.Restriction);
            complexType.SetContentTypeParticle(this.CompileContentTypeParticle(complexRestriction.Particle));
            XmlSchemaContentType type2 = this.GetSchemaContentType(complexType, complexContent, complexType.ContentTypeParticle);
            complexType.SetContentType(type2);
            switch (type2)
            {
                case XmlSchemaContentType.Empty:
                    if ((redefined.ElementDecl != null) && !redefined.ElementDecl.ContentValidator.IsEmptiable)
                    {
                        base.SendValidationEvent("Sch_InvalidContentRestrictionDetailed", Res.GetString("Sch_InvalidBaseToEmpty"), complexType);
                    }
                    break;

                case XmlSchemaContentType.Mixed:
                    if (redefined.ContentType != XmlSchemaContentType.Mixed)
                    {
                        base.SendValidationEvent("Sch_InvalidContentRestrictionDetailed", Res.GetString("Sch_InvalidBaseToMixed"), complexType);
                    }
                    break;
            }
            complexType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction);
        }
コード例 #12
0
 private void CompileComplexContentRestriction(XmlSchemaComplexType complexType, XmlSchemaComplexContent complexContent, XmlSchemaComplexContentRestriction complexRestriction) {
     XmlSchemaComplexType baseType = null;
     if (complexType.Redefined != null && complexRestriction.BaseTypeName == complexType.Redefined.QualifiedName) {
         baseType = (XmlSchemaComplexType)complexType.Redefined;
         CompileComplexType(baseType);
     }
     else {
         baseType = GetComplexType(complexRestriction.BaseTypeName);
         if (baseType == null) {
             SendValidationEvent(Res.Sch_UndefBaseRestriction, complexRestriction.BaseTypeName.ToString(), complexRestriction);   
             return;
         }
     } 
     if (baseType != null && baseType.ElementDecl != null) {
         if (baseType.ContentType == XmlSchemaContentType.TextOnly) {
             SendValidationEvent(Res.Sch_NotComplexContent, complexType);
             return;
         }
     }
     complexType.SetBaseSchemaType(baseType);
     if ((baseType.FinalResolved & XmlSchemaDerivationMethod.Restriction) != 0) {
         SendValidationEvent(Res.Sch_BaseFinalRestriction, complexType);
     }
     CompileLocalAttributes(baseType, complexType, complexRestriction.Attributes, complexRestriction.AnyAttribute, XmlSchemaDerivationMethod.Restriction);
     
     complexType.SetContentTypeParticle(CompileContentTypeParticle(complexRestriction.Particle, true));
     complexType.SetContentType(GetSchemaContentType(complexType, complexContent, complexType.ContentTypeParticle));
     if (complexType.ContentType == XmlSchemaContentType.Empty) {
         if (baseType.ElementDecl != null) {
             Debug.Assert(baseType.ElementDecl.ContentValidator != null);
         }
         if (baseType.ElementDecl != null && !baseType.ElementDecl.ContentValidator.IsEmptiable) {
             SendValidationEvent(Res.Sch_InvalidContentRestriction, complexType);
         }
     }
     complexType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction);
 }
コード例 #13
0
ファイル: compiler.cs プロジェクト: ArildF/masters
        private void CompileComplexContentExtension(XmlSchemaComplexType complexType, XmlSchemaComplexContent complexContent, XmlSchemaComplexContentExtension complexExtension) {
            XmlSchemaComplexType baseType = null;
            if (complexType.Redefined != null && complexExtension.BaseTypeName == complexType.Redefined.QualifiedName) {
                baseType = (XmlSchemaComplexType)complexType.Redefined;
                CompileComplexType(baseType);
            }
            else {
                baseType = GetComplexType(complexExtension.BaseTypeName);
                if (baseType == null) {
                    SendValidationEvent(Res.Sch_UndefBaseExtension, complexExtension.BaseTypeName.ToString(), complexExtension);   
                    return;
                }
            }
            if (baseType != null && baseType.ElementDecl != null) {
                if (baseType.ContentType == XmlSchemaContentType.TextOnly) {
                    SendValidationEvent(Res.Sch_NotComplexContent, complexType);
                }
            }
            complexType.SetBaseSchemaType(baseType);
            if ((baseType.FinalResolved & XmlSchemaDerivationMethod.Extension) != 0) {
                SendValidationEvent(Res.Sch_BaseFinalExtension, complexType);
            }
            CompileLocalAttributes(baseType, complexType, complexExtension.Attributes, complexExtension.AnyAttribute, XmlSchemaDerivationMethod.Extension);

            XmlSchemaParticle baseParticle = baseType.ContentTypeParticle;
            XmlSchemaParticle extendedParticle = CannonicalizeParticle(complexExtension.Particle, true, true);
            if (baseParticle != XmlSchemaParticle.Empty) {
                if (extendedParticle != XmlSchemaParticle.Empty) {
                    XmlSchemaSequence compiledParticle = new XmlSchemaSequence();
                    compiledParticle.Items.Add(baseParticle);
                    compiledParticle.Items.Add(extendedParticle);
                    complexType.SetContentTypeParticle(CompileContentTypeParticle(compiledParticle, false));
                }
                else {
                    complexType.SetContentTypeParticle(baseParticle);
                }
                complexType.SetContentType(GetSchemaContentType(complexType, complexContent, complexType.ContentTypeParticle));
                if (complexType.ContentType != baseType.ContentType) {
                    SendValidationEvent(Res.Sch_DifContentType, complexType);
                }
            }
            else {
                complexType.SetContentTypeParticle(extendedParticle);
                complexType.SetContentType(GetSchemaContentType(complexType, complexContent, complexType.ContentTypeParticle));
            }
            complexType.SetDerivedBy(XmlSchemaDerivationMethod.Extension);
        }