本文整理汇总了C#中System.Xml.Schema.XmlSchemaComplexType.SetDerivedBy方法的典型用法代码示例。如果您正苦于以下问题:C# XmlSchemaComplexType.SetDerivedBy方法的具体用法?C# XmlSchemaComplexType.SetDerivedBy怎么用?C# XmlSchemaComplexType.SetDerivedBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Schema.XmlSchemaComplexType
的用法示例。
在下文中一共展示了XmlSchemaComplexType.SetDerivedBy方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompileSimpleContentRestriction
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);
}
示例2: CompileComplexType
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;
}
}
}
示例3: CompileSimpleContentExtension
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);
}
示例4: CompileComplexContentExtension
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);
}
}
示例5: CompileComplexContentRestriction
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);
}
}
示例6: CompileComplexContentExtension
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);
}
示例7: CompileComplexContentRestriction
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);
}
示例8: CompileSimpleContentExtension
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);
}
示例9: CompileSimpleContentRestriction
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);
}
示例10: CompileComplexType
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: CompileComplexContentRestriction
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: CompileComplexContentRestriction
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: CompileComplexContentExtension
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);
}
示例14: CompileComplexType
private void CompileComplexType(XmlSchemaComplexType complexType) {
if (complexType.ElementDecl != null) { //already compiled
return;
}
if (complexType.Validating) {
SendValidationEvent(Res.Sch_TypeCircularRef, complexType);
return;
}
complexType.Validating = true;
CompiledContentModel compiledContentModel = new CompiledContentModel(this.schemaNames);
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);
}
CompileComplexContent(complexType, compiledContentModel);
}
}
else { //equals XmlSchemaComplexContent with baseType is anyType
CompileLocalAttributes(XmlSchemaComplexType.AnyType, complexType, complexType.Attributes, complexType.AnyAttribute, XmlSchemaDerivationMethod.Restriction);
complexType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction);
complexType.SetContentTypeParticle(CompileContentTypeParticle(complexType.Particle, true));
complexType.SetContentType(GetSchemaContentType(complexType, null, complexType.ContentTypeParticle));
CompileComplexContent(complexType, compiledContentModel);
}
bool hasID = 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 (hasID) {
SendValidationEvent(Res.Sch_TwoIdAttrUses, complexType);
}
else {
hasID = true;
}
}
}
}
SchemaElementDecl decl = new SchemaElementDecl();
decl.Content = compiledContentModel;
decl.Content = compiledContentModel;
decl.SchemaType = complexType;
decl.Datatype = complexType.Datatype;
decl.Block = complexType.BlockResolved;
switch (complexType.ContentType) {
case XmlSchemaContentType.TextOnly : decl.Content.ContentType = CompiledContentModel.Type.Text; break;
case XmlSchemaContentType.Empty : decl.Content.ContentType = CompiledContentModel.Type.Empty; break;
case XmlSchemaContentType.ElementOnly : decl.Content.ContentType = CompiledContentModel.Type.ElementOnly; break;
default: decl.Content.ContentType = CompiledContentModel.Type.Mixed; break;
}
decl.AnyAttribute = complexType.AttributeWildcard;
foreach(XmlSchemaAttribute attribute in complexType.AttributeUses.Values) {
if (attribute.Use == XmlSchemaUse.Prohibited) {
if (decl.ProhibitedAttributes[attribute.QualifiedName] == null) {
decl.ProhibitedAttributes.Add(attribute.QualifiedName, attribute.QualifiedName);
}
}
else {
if (decl.AttDefs[attribute.QualifiedName] == null && attribute.AttDef != null && attribute.AttDef != SchemaAttDef.Empty) {
decl.AddAttDef(attribute.AttDef);
}
}
}
complexType.ElementDecl = decl;
complexType.Validating = false;
}