Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CompileElement()

void System.Xml.Schema.SchemaCollectionCompiler.CompileElement ( XmlSchemaElement xe)
inlineprivate

Definition at line 2021 of file SchemaCollectionCompiler.cs.

2022 {
2023 if (xe.IsProcessing)
2024 {
2026 }
2027 else
2028 {
2029 if (xe.ElementDecl != null)
2030 {
2031 return;
2032 }
2033 xe.IsProcessing = true;
2034 SchemaElementDecl schemaElementDecl = null;
2035 try
2036 {
2037 if (!xe.RefName.IsEmpty)
2038 {
2039 XmlSchemaElement xmlSchemaElement = (XmlSchemaElement)_schema.Elements[xe.RefName];
2040 if (xmlSchemaElement == null)
2041 {
2042 throw new XmlSchemaException(System.SR.Sch_UndeclaredElement, xe.RefName.ToString(), xe);
2043 }
2045 if (xmlSchemaElement.ElementDecl == null)
2046 {
2047 throw new XmlSchemaException(System.SR.Sch_RefInvalidElement, xe.RefName.ToString(), xe);
2048 }
2049 xe.SetElementType(xmlSchemaElement.ElementSchemaType);
2050 schemaElementDecl = xmlSchemaElement.ElementDecl.Clone();
2051 }
2052 else
2053 {
2054 if (xe.SchemaType != null)
2055 {
2056 xe.SetElementType(xe.SchemaType);
2057 }
2058 else if (!xe.SchemaTypeName.IsEmpty)
2059 {
2060 xe.SetElementType(GetAnySchemaType(xe.SchemaTypeName));
2061 if (xe.ElementSchemaType == null)
2062 {
2063 throw new XmlSchemaException(System.SR.Sch_UndeclaredType, xe.SchemaTypeName.ToString(), xe);
2064 }
2065 }
2066 else if (!xe.SubstitutionGroup.IsEmpty)
2067 {
2068 XmlSchemaElement xmlSchemaElement2 = (XmlSchemaElement)_schema.Elements[xe.SubstitutionGroup];
2069 if (xmlSchemaElement2 == null)
2070 {
2071 throw new XmlSchemaException(System.SR.Sch_UndeclaredEquivClass, xe.SubstitutionGroup.Name, xe);
2072 }
2073 if (xmlSchemaElement2.IsProcessing)
2074 {
2075 return;
2076 }
2078 if (xmlSchemaElement2.ElementDecl == null)
2079 {
2080 xe.SetElementType(XmlSchemaComplexType.AnyType);
2081 schemaElementDecl = XmlSchemaComplexType.AnyType.ElementDecl.Clone();
2082 }
2083 else
2084 {
2085 xe.SetElementType(xmlSchemaElement2.ElementSchemaType);
2086 schemaElementDecl = xmlSchemaElement2.ElementDecl.Clone();
2087 }
2088 }
2089 else
2090 {
2091 xe.SetElementType(XmlSchemaComplexType.AnyType);
2092 schemaElementDecl = XmlSchemaComplexType.AnyType.ElementDecl.Clone();
2093 }
2094 if (schemaElementDecl == null)
2095 {
2096 if (xe.ElementSchemaType is XmlSchemaComplexType)
2097 {
2098 XmlSchemaComplexType xmlSchemaComplexType = (XmlSchemaComplexType)xe.ElementSchemaType;
2100 if (xmlSchemaComplexType.ElementDecl != null)
2101 {
2102 schemaElementDecl = xmlSchemaComplexType.ElementDecl.Clone();
2103 }
2104 }
2105 else if (xe.ElementSchemaType is XmlSchemaSimpleType)
2106 {
2107 XmlSchemaSimpleType xmlSchemaSimpleType = (XmlSchemaSimpleType)xe.ElementSchemaType;
2109 if (xmlSchemaSimpleType.ElementDecl != null)
2110 {
2111 schemaElementDecl = xmlSchemaSimpleType.ElementDecl.Clone();
2112 }
2113 }
2114 }
2115 schemaElementDecl.Name = xe.QualifiedName;
2116 schemaElementDecl.IsAbstract = xe.IsAbstract;
2117 if (xe.ElementSchemaType is XmlSchemaComplexType xmlSchemaComplexType2)
2118 {
2120 }
2121 schemaElementDecl.IsNillable = xe.IsNillable;
2122 schemaElementDecl.Block |= xe.BlockResolved;
2123 }
2124 if (schemaElementDecl.Datatype != null)
2125 {
2126 schemaElementDecl.Datatype.VerifySchemaValid(_schema.Notations, xe);
2127 }
2128 if ((xe.DefaultValue != null || xe.FixedValue != null) && schemaElementDecl.ContentValidator != null)
2129 {
2130 if (schemaElementDecl.ContentValidator.ContentType == XmlSchemaContentType.TextOnly)
2131 {
2132 if (xe.DefaultValue != null)
2133 {
2134 schemaElementDecl.Presence = SchemaDeclBase.Use.Default;
2136 }
2137 else
2138 {
2139 schemaElementDecl.Presence = SchemaDeclBase.Use.Fixed;
2141 }
2142 if (schemaElementDecl.Datatype != null)
2143 {
2144 schemaElementDecl.DefaultValueTyped = schemaElementDecl.Datatype.ParseValue(schemaElementDecl.DefaultValueRaw, base.NameTable, new SchemaNamespaceManager(xe), createAtomicValue: true);
2145 }
2146 }
2147 else if (schemaElementDecl.ContentValidator.ContentType != XmlSchemaContentType.Mixed || !schemaElementDecl.ContentValidator.IsEmptiable)
2148 {
2149 throw new XmlSchemaException(System.SR.Sch_ElementCannotHaveValue, xe);
2150 }
2151 }
2152 if (xe.HasConstraints)
2153 {
2154 XmlSchemaObjectCollection constraints = xe.Constraints;
2155 CompiledIdentityConstraint[] array = new CompiledIdentityConstraint[constraints.Count];
2156 int num = 0;
2157 for (int i = 0; i < constraints.Count; i++)
2158 {
2159 XmlSchemaIdentityConstraint xmlSchemaIdentityConstraint = (XmlSchemaIdentityConstraint)constraints[i];
2161 array[num++] = xmlSchemaIdentityConstraint.CompiledConstraint;
2162 }
2164 }
2167 }
2168 catch (XmlSchemaException ex)
2169 {
2170 if (ex.SourceSchemaObject == null)
2171 {
2172 ex.SetSource(xe);
2173 }
2175 xe.ElementDecl = SchemaElementDecl.Empty;
2176 }
2177 finally
2178 {
2179 xe.IsProcessing = false;
2180 }
2181 }
2182 }
static string Sch_ElementCircularRef
Definition SR.cs:1066
static string Sch_ElementCannotHaveValue
Definition SR.cs:1070
static string Sch_UndeclaredEquivClass
Definition SR.cs:562
static string Sch_RefInvalidElement
Definition SR.cs:1068
static string Sch_UndeclaredType
Definition SR.cs:558
static string Sch_UndeclaredElement
Definition SR.cs:412
Definition SR.cs:7
void SendValidationEvent(string code, XmlSchemaObject source)
XmlSchemaType GetAnySchemaType(XmlQualifiedName name)
void CompileIdentityConstraint(XmlSchemaIdentityConstraint xi)
void CompileComplexType(XmlSchemaComplexType complexType)
void CompileSimpleType(XmlSchemaSimpleType simpleType)
XmlSchemaObjectTable Notations
Definition XmlSchema.cs:310
XmlSchemaObjectTable Elements
Definition XmlSchema.cs:269

References System.Xml.Schema.SchemaCollectionCompiler._schema, System.Xml.Schema.XmlSchemaComplexType.AnyType, System.array, System.Xml.Schema.SchemaCollectionCompiler.CompileComplexType(), System.Xml.Schema.SchemaCollectionCompiler.CompileElement(), System.Xml.Schema.SchemaCollectionCompiler.CompileIdentityConstraint(), System.Xml.Schema.SchemaCollectionCompiler.CompileSimpleType(), System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Xml.Dictionary, System.Xml.Schema.XmlSchema.Elements, System.Xml.Schema.SchemaElementDecl.Empty, System.Xml.Schema.SchemaCollectionCompiler.GetAnySchemaType(), System.Xml.Schema.XmlSchema.Notations, System.SR.Sch_ElementCannotHaveValue, System.SR.Sch_ElementCircularRef, System.SR.Sch_RefInvalidElement, System.SR.Sch_UndeclaredElement, System.SR.Sch_UndeclaredEquivClass, System.SR.Sch_UndeclaredType, and System.Xml.Schema.BaseProcessor.SendValidationEvent().

Referenced by System.Xml.Schema.SchemaCollectionCompiler.Compile(), System.Xml.Schema.SchemaCollectionCompiler.CompileElement(), and System.Xml.Schema.SchemaCollectionCompiler.CompileParticleElements().