本文整理汇总了C#中System.Xml.Schema.XmlSchemaComplexType.SetDatatype方法的典型用法代码示例。如果您正苦于以下问题:C# XmlSchemaComplexType.SetDatatype方法的具体用法?C# XmlSchemaComplexType.SetDatatype怎么用?C# XmlSchemaComplexType.SetDatatype使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Schema.XmlSchemaComplexType
的用法示例。
在下文中一共展示了XmlSchemaComplexType.SetDatatype方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
示例3: 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);
}
示例4: 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);
}
示例5: 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);
}
示例6: 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.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);
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));
}
else
{
complexType.SetContentTypeParticle(contentTypeParticle);
}
}
else
{
complexType.SetContentTypeParticle(item);
}
XmlSchemaContentType contentType = this.GetSchemaContentType(complexType, complexContent, item);
if (contentType == XmlSchemaContentType.Empty)
{
contentType = redefined.ContentType;
if (contentType == XmlSchemaContentType.TextOnly)
{
complexType.SetDatatype(redefined.Datatype);
}
}
complexType.SetContentType(contentType);
if ((redefined.ContentType != XmlSchemaContentType.Empty) && (complexType.ContentType != redefined.ContentType))
{
base.SendValidationEvent("Sch_DifContentType", complexType);
}
else
{
complexType.SetBaseSchemaType(redefined);
complexType.SetDerivedBy(XmlSchemaDerivationMethod.Extension);
}
}