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

◆ CompileElement()

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

Definition at line 2349 of file Compiler.cs.

2350 {
2351 if (xe.IsProcessing)
2352 {
2354 }
2355 else
2356 {
2357 if (xe.ElementDecl != null)
2358 {
2359 return;
2360 }
2361 xe.IsProcessing = true;
2362 SchemaElementDecl schemaElementDecl = null;
2363 try
2364 {
2365 if (!xe.RefName.IsEmpty)
2366 {
2367 XmlSchemaElement xmlSchemaElement = (XmlSchemaElement)_elements[xe.RefName];
2368 if (xmlSchemaElement == null)
2369 {
2370 throw new XmlSchemaException(System.SR.Sch_UndeclaredElement, xe.RefName.ToString(), xe);
2371 }
2373 if (xmlSchemaElement.ElementDecl == null)
2374 {
2375 throw new XmlSchemaException(System.SR.Sch_RefInvalidElement, xe.RefName.ToString(), xe);
2376 }
2377 xe.SetElementType(xmlSchemaElement.ElementSchemaType);
2378 schemaElementDecl = xmlSchemaElement.ElementDecl.Clone();
2379 }
2380 else
2381 {
2382 if (xe.SchemaType != null)
2383 {
2384 xe.SetElementType(xe.SchemaType);
2385 }
2386 else if (!xe.SchemaTypeName.IsEmpty)
2387 {
2388 xe.SetElementType(GetAnySchemaType(xe.SchemaTypeName));
2389 if (xe.ElementSchemaType == null)
2390 {
2391 throw new XmlSchemaException(System.SR.Sch_UndeclaredType, xe.SchemaTypeName.ToString(), xe);
2392 }
2393 }
2394 else if (!xe.SubstitutionGroup.IsEmpty)
2395 {
2396 XmlSchemaElement xmlSchemaElement2 = (XmlSchemaElement)_elements[xe.SubstitutionGroup];
2397 if (xmlSchemaElement2 == null)
2398 {
2399 throw new XmlSchemaException(System.SR.Sch_UndeclaredEquivClass, xe.SubstitutionGroup.Name, xe);
2400 }
2401 if (xmlSchemaElement2.IsProcessing)
2402 {
2403 return;
2404 }
2406 if (xmlSchemaElement2.ElementDecl == null)
2407 {
2408 xe.SetElementType(XmlSchemaComplexType.AnyType);
2409 schemaElementDecl = XmlSchemaComplexType.AnyType.ElementDecl.Clone();
2410 }
2411 else
2412 {
2413 xe.SetElementType(xmlSchemaElement2.ElementSchemaType);
2414 schemaElementDecl = xmlSchemaElement2.ElementDecl.Clone();
2415 }
2416 }
2417 else
2418 {
2419 xe.SetElementType(XmlSchemaComplexType.AnyType);
2420 schemaElementDecl = XmlSchemaComplexType.AnyType.ElementDecl.Clone();
2421 }
2422 if (schemaElementDecl == null)
2423 {
2424 if (xe.ElementSchemaType is XmlSchemaComplexType)
2425 {
2426 XmlSchemaComplexType xmlSchemaComplexType = (XmlSchemaComplexType)xe.ElementSchemaType;
2428 if (xmlSchemaComplexType.ElementDecl != null)
2429 {
2430 schemaElementDecl = xmlSchemaComplexType.ElementDecl.Clone();
2431 }
2432 }
2433 else if (xe.ElementSchemaType is XmlSchemaSimpleType)
2434 {
2435 XmlSchemaSimpleType xmlSchemaSimpleType = (XmlSchemaSimpleType)xe.ElementSchemaType;
2437 if (xmlSchemaSimpleType.ElementDecl != null)
2438 {
2439 schemaElementDecl = xmlSchemaSimpleType.ElementDecl.Clone();
2440 }
2441 }
2442 }
2443 schemaElementDecl.Name = xe.QualifiedName;
2444 schemaElementDecl.IsAbstract = xe.IsAbstract;
2445 if (xe.ElementSchemaType is XmlSchemaComplexType xmlSchemaComplexType2)
2446 {
2448 }
2449 schemaElementDecl.IsNillable = xe.IsNillable;
2450 schemaElementDecl.Block |= xe.BlockResolved;
2451 }
2452 if (schemaElementDecl.Datatype != null)
2453 {
2454 schemaElementDecl.Datatype.VerifySchemaValid(_notations, xe);
2455 }
2456 if ((xe.DefaultValue != null || xe.FixedValue != null) && schemaElementDecl.ContentValidator != null)
2457 {
2458 if (schemaElementDecl.ContentValidator.ContentType != 0 && (schemaElementDecl.ContentValidator.ContentType != XmlSchemaContentType.Mixed || !schemaElementDecl.ContentValidator.IsEmptiable))
2459 {
2460 throw new XmlSchemaException(System.SR.Sch_ElementCannotHaveValue, xe);
2461 }
2462 if (xe.DefaultValue != null)
2463 {
2464 schemaElementDecl.Presence = SchemaDeclBase.Use.Default;
2466 }
2467 else
2468 {
2469 schemaElementDecl.Presence = SchemaDeclBase.Use.Fixed;
2471 }
2472 if (schemaElementDecl.Datatype != null)
2473 {
2474 if (schemaElementDecl.Datatype.TypeCode == XmlTypeCode.Id)
2475 {
2477 }
2478 else
2479 {
2480 schemaElementDecl.DefaultValueTyped = schemaElementDecl.Datatype.ParseValue(schemaElementDecl.DefaultValueRaw, base.NameTable, new SchemaNamespaceManager(xe), createAtomicValue: true);
2481 }
2482 }
2483 else
2484 {
2485 schemaElementDecl.DefaultValueTyped = DatatypeImplementation.AnySimpleType.Datatype.ParseValue(schemaElementDecl.DefaultValueRaw, base.NameTable, new SchemaNamespaceManager(xe));
2486 }
2487 }
2488 if (xe.HasConstraints)
2489 {
2490 XmlSchemaObjectCollection constraints = xe.Constraints;
2491 CompiledIdentityConstraint[] array = new CompiledIdentityConstraint[constraints.Count];
2492 int num = 0;
2493 for (int i = 0; i < constraints.Count; i++)
2494 {
2495 XmlSchemaIdentityConstraint xmlSchemaIdentityConstraint = (XmlSchemaIdentityConstraint)constraints[i];
2497 array[num++] = xmlSchemaIdentityConstraint.CompiledConstraint;
2498 }
2500 }
2503 }
2504 catch (XmlSchemaException ex)
2505 {
2506 if (ex.SourceSchemaObject == null)
2507 {
2508 ex.SetSource(xe);
2509 }
2511 xe.ElementDecl = SchemaElementDecl.Empty;
2512 }
2513 finally
2514 {
2515 xe.IsProcessing = false;
2516 }
2517 }
2518 }
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_DefaultIdValue
Definition SR.cs:458
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)
readonly XmlSchemaObjectTable _elements
Definition Compiler.cs:16
void CompileIdentityConstraint(XmlSchemaIdentityConstraint xi)
Definition Compiler.cs:2291
XmlSchemaType GetAnySchemaType(XmlQualifiedName name)
Definition Compiler.cs:2740
void CompileElement(XmlSchemaElement xe)
Definition Compiler.cs:2349
void CompileComplexType(XmlSchemaComplexType complexType)
Definition Compiler.cs:730
void CompileSimpleType(XmlSchemaSimpleType simpleType)
Definition Compiler.cs:558
readonly XmlSchemaObjectTable _notations
Definition Compiler.cs:22

References System.Xml.Schema.Compiler._elements, System.Xml.Schema.Compiler._notations, System.Xml.Schema.DatatypeImplementation.AnySimpleType, System.Xml.Schema.XmlSchemaComplexType.AnyType, System.array, System.Xml.Schema.Compiler.CompileComplexType(), System.Xml.Schema.Compiler.CompileElement(), System.Xml.Schema.Compiler.CompileIdentityConstraint(), System.Xml.Schema.Compiler.CompileSimpleType(), System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Xml.Dictionary, System.Xml.Schema.SchemaElementDecl.Empty, System.Xml.Schema.Compiler.GetAnySchemaType(), System.SR.Sch_DefaultIdValue, 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.Compiler.Compile(), System.Xml.Schema.Compiler.CompileElement(), System.Xml.Schema.Compiler.CompileParticleElements(), and System.Xml.Schema.Compiler.CompileParticleElements().