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

◆ Preprocess()

void System.Xml.Schema.SchemaCollectionPreprocessor.Preprocess ( XmlSchema schema,
string targetNamespace,
Compositor compositor )
inlineprivate

Definition at line 257 of file SchemaCollectionPreprocessor.cs.

258 {
259 if (schema.IsProcessing)
260 {
261 return;
262 }
263 schema.IsProcessing = true;
264 string targetNamespace2 = schema.TargetNamespace;
265 if (targetNamespace2 != null)
266 {
268 if (targetNamespace2.Length == 0)
269 {
271 }
272 else
273 {
274 try
275 {
276 XmlConvert.ToUri(targetNamespace2);
277 }
278 catch
279 {
281 }
282 }
283 }
284 if (schema.Version != null)
285 {
286 try
287 {
288 XmlConvert.VerifyTOKEN(schema.Version);
289 }
290 catch (Exception)
291 {
293 }
294 }
295 switch (compositor)
296 {
297 case Compositor.Root:
298 if (targetNamespace == null && schema.TargetNamespace != null)
299 {
300 targetNamespace = schema.TargetNamespace;
301 }
302 else if (schema.TargetNamespace == null && targetNamespace != null && targetNamespace.Length == 0)
303 {
304 targetNamespace = null;
305 }
306 if (targetNamespace != schema.TargetNamespace)
307 {
309 }
310 break;
311 case Compositor.Import:
312 if (targetNamespace != schema.TargetNamespace)
313 {
315 }
316 break;
317 case Compositor.Include:
318 if (schema.TargetNamespace != null && targetNamespace != schema.TargetNamespace)
319 {
321 }
322 break;
323 }
324 for (int i = 0; i < schema.Includes.Count; i++)
325 {
326 XmlSchemaExternal xmlSchemaExternal = (XmlSchemaExternal)schema.Includes[i];
329 string schemaLocation = xmlSchemaExternal.SchemaLocation;
330 if (schemaLocation != null)
331 {
332 try
333 {
334 XmlConvert.ToUri(schemaLocation);
335 }
336 catch
337 {
339 }
340 }
341 else if ((xmlSchemaExternal is XmlSchemaRedefine || xmlSchemaExternal is XmlSchemaInclude) && xmlSchemaExternal.Schema == null)
342 {
344 }
345 if (xmlSchemaExternal.Schema != null)
346 {
347 if (xmlSchemaExternal is XmlSchemaRedefine)
348 {
349 Preprocess(xmlSchemaExternal.Schema, schema.TargetNamespace, Compositor.Include);
350 }
351 else if (xmlSchemaExternal is XmlSchemaImport)
352 {
353 if (((XmlSchemaImport)xmlSchemaExternal).Namespace == null && schema.TargetNamespace == null)
354 {
356 }
357 else if (((XmlSchemaImport)xmlSchemaExternal).Namespace == schema.TargetNamespace)
358 {
360 }
361 Preprocess(xmlSchemaExternal.Schema, ((XmlSchemaImport)xmlSchemaExternal).Namespace, Compositor.Import);
362 }
363 else
364 {
365 Preprocess(xmlSchemaExternal.Schema, schema.TargetNamespace, Compositor.Include);
366 }
367 }
368 else
369 {
370 if (!(xmlSchemaExternal is XmlSchemaImport))
371 {
372 continue;
373 }
374 string @namespace = ((XmlSchemaImport)xmlSchemaExternal).Namespace;
375 if (@namespace == null)
376 {
377 continue;
378 }
379 if (@namespace.Length == 0)
380 {
381 SendValidationEvent(System.SR.Sch_InvalidNamespaceAttribute, @namespace, xmlSchemaExternal);
382 continue;
383 }
384 try
385 {
386 XmlConvert.ToUri(@namespace);
387 }
388 catch (FormatException)
389 {
390 SendValidationEvent(System.SR.Sch_InvalidNamespace, @namespace, xmlSchemaExternal);
391 }
392 }
393 }
395 _targetNamespace = ((targetNamespace == null) ? string.Empty : targetNamespace);
396 if (schema.BlockDefault == XmlSchemaDerivationMethod.All)
397 {
398 _blockDefault = XmlSchemaDerivationMethod.All;
399 }
400 else if (schema.BlockDefault == XmlSchemaDerivationMethod.None)
401 {
402 _blockDefault = XmlSchemaDerivationMethod.Empty;
403 }
404 else
405 {
406 if (((uint)schema.BlockDefault & 0xFFFFFFF8u) != 0)
407 {
409 }
411 }
412 if (schema.FinalDefault == XmlSchemaDerivationMethod.All)
413 {
414 _finalDefault = XmlSchemaDerivationMethod.All;
415 }
416 else if (schema.FinalDefault == XmlSchemaDerivationMethod.None)
417 {
418 _finalDefault = XmlSchemaDerivationMethod.Empty;
419 }
420 else
421 {
422 if (((uint)schema.FinalDefault & 0xFFFFFFE1u) != 0)
423 {
425 }
427 }
428 _elementFormDefault = schema.ElementFormDefault;
429 if (_elementFormDefault == XmlSchemaForm.None)
430 {
431 _elementFormDefault = XmlSchemaForm.Unqualified;
432 }
433 _attributeFormDefault = schema.AttributeFormDefault;
434 if (_attributeFormDefault == XmlSchemaForm.None)
435 {
436 _attributeFormDefault = XmlSchemaForm.Unqualified;
437 }
438 for (int j = 0; j < schema.Includes.Count; j++)
439 {
440 XmlSchemaExternal xmlSchemaExternal2 = (XmlSchemaExternal)schema.Includes[j];
441 if (xmlSchemaExternal2 is XmlSchemaRedefine)
442 {
443 XmlSchemaRedefine xmlSchemaRedefine = (XmlSchemaRedefine)xmlSchemaExternal2;
444 if (xmlSchemaExternal2.Schema != null)
445 {
447 }
448 else
449 {
450 for (int k = 0; k < xmlSchemaRedefine.Items.Count; k++)
451 {
452 if (!(xmlSchemaRedefine.Items[k] is XmlSchemaAnnotation))
453 {
455 break;
456 }
457 }
458 }
459 }
460 XmlSchema schema2 = xmlSchemaExternal2.Schema;
461 if (schema2 != null)
462 {
463 foreach (XmlSchemaElement value in schema2.Elements.Values)
464 {
465 AddToTable(schema.Elements, value.QualifiedName, value);
466 }
467 foreach (XmlSchemaAttribute value2 in schema2.Attributes.Values)
468 {
469 AddToTable(schema.Attributes, value2.QualifiedName, value2);
470 }
471 foreach (XmlSchemaGroup value3 in schema2.Groups.Values)
472 {
473 AddToTable(schema.Groups, value3.QualifiedName, value3);
474 }
475 foreach (XmlSchemaAttributeGroup value4 in schema2.AttributeGroups.Values)
476 {
477 AddToTable(schema.AttributeGroups, value4.QualifiedName, value4);
478 }
479 foreach (XmlSchemaType value5 in schema2.SchemaTypes.Values)
480 {
481 AddToTable(schema.SchemaTypes, value5.QualifiedName, value5);
482 }
483 foreach (XmlSchemaNotation value6 in schema2.Notations.Values)
484 {
485 AddToTable(schema.Notations, value6.QualifiedName, value6);
486 }
487 }
489 }
491 for (int l = 0; l < schema.Items.Count; l++)
492 {
493 SetParent(schema.Items[l], schema);
494 if (schema.Items[l] is XmlSchemaAttribute xmlSchemaAttribute2)
495 {
497 AddToTable(schema.Attributes, xmlSchemaAttribute2.QualifiedName, xmlSchemaAttribute2);
498 }
499 else if (schema.Items[l] is XmlSchemaAttributeGroup)
500 {
501 XmlSchemaAttributeGroup xmlSchemaAttributeGroup2 = (XmlSchemaAttributeGroup)schema.Items[l];
504 }
505 else if (schema.Items[l] is XmlSchemaComplexType)
506 {
507 XmlSchemaComplexType xmlSchemaComplexType = (XmlSchemaComplexType)schema.Items[l];
509 AddToTable(schema.SchemaTypes, xmlSchemaComplexType.QualifiedName, xmlSchemaComplexType);
510 }
511 else if (schema.Items[l] is XmlSchemaSimpleType)
512 {
513 XmlSchemaSimpleType xmlSchemaSimpleType = (XmlSchemaSimpleType)schema.Items[l];
515 AddToTable(schema.SchemaTypes, xmlSchemaSimpleType.QualifiedName, xmlSchemaSimpleType);
516 }
517 else if (schema.Items[l] is XmlSchemaElement)
518 {
519 XmlSchemaElement xmlSchemaElement2 = (XmlSchemaElement)schema.Items[l];
521 AddToTable(schema.Elements, xmlSchemaElement2.QualifiedName, xmlSchemaElement2);
522 }
523 else if (schema.Items[l] is XmlSchemaGroup)
524 {
525 XmlSchemaGroup xmlSchemaGroup2 = (XmlSchemaGroup)schema.Items[l];
527 AddToTable(schema.Groups, xmlSchemaGroup2.QualifiedName, xmlSchemaGroup2);
528 }
529 else if (schema.Items[l] is XmlSchemaNotation)
530 {
531 XmlSchemaNotation xmlSchemaNotation2 = (XmlSchemaNotation)schema.Items[l];
533 AddToTable(schema.Notations, xmlSchemaNotation2.QualifiedName, xmlSchemaNotation2);
534 }
535 else if (!(schema.Items[l] is XmlSchemaAnnotation))
536 {
538 list.Add(schema.Items[l]);
539 }
540 }
541 for (int m = 0; m < list.Count; m++)
542 {
543 schema.Items.Remove(list[m]);
544 }
545 schema.IsProcessing = false;
546 }
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
void Add(TKey key, TValue value)
static string Sch_AttributeValueDataType
Definition SR.cs:1808
static string Sch_ImportTargetNamespaceNull
Definition SR.cs:800
static string Sch_RedefineNoSchema
Definition SR.cs:948
static string Sch_InvalidNamespace
Definition SR.cs:790
static string Sch_MismatchTargetNamespaceImport
Definition SR.cs:598
static string Sch_MismatchTargetNamespaceInclude
Definition SR.cs:596
static string Sch_InvalidTargetNamespaceAttribute
Definition SR.cs:792
static string Sch_InvalidFinalDefaultValue
Definition SR.cs:508
static string Sch_ImportTargetNamespace
Definition SR.cs:798
static string Sch_MismatchTargetNamespaceEx
Definition SR.cs:600
static string Sch_InvalidBlockDefaultValue
Definition SR.cs:506
static string Sch_InvalidNamespaceAttribute
Definition SR.cs:794
static string Sch_InvalidCollection
Definition SR.cs:1148
static string Sch_InvalidSchemaLocation
Definition SR.cs:796
static string Sch_MissRequiredAttribute
Definition SR.cs:490
Definition SR.cs:7
void SendValidationEvent(string code, XmlSchemaObject source)
void AddToTable(XmlSchemaObjectTable table, XmlQualifiedName qname, XmlSchemaObject item)
void PreprocessAttributeGroup(XmlSchemaAttributeGroup attributeGroup)
void SetParent(XmlSchemaObject child, XmlSchemaObject parent)
void PreprocessSimpleType(XmlSchemaSimpleType simpleType, bool local)
void PreprocessComplexType(XmlSchemaComplexType complexType, bool local)
void Preprocess(XmlSchema schema, string targetNamespace, Compositor compositor)

References System.Xml.Schema.SchemaCollectionPreprocessor._attributeFormDefault, System.Xml.Schema.SchemaCollectionPreprocessor._blockDefault, System.Xml.Schema.SchemaCollectionPreprocessor._elementFormDefault, System.Xml.Schema.SchemaCollectionPreprocessor._finalDefault, System.Xml.Schema.SchemaCollectionPreprocessor._targetNamespace, System.Collections.Generic.Dictionary< TKey, TValue >.Add(), System.Xml.Schema.BaseProcessor.AddToTable(), System.Xml.Schema.SchemaCollectionPreprocessor.BuildRefNamespaces(), System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Xml.Dictionary, System.Xml.Schema.Length, System.list, System.Xml.Schema.Namespace, System.Xml.Schema.SchemaCollectionPreprocessor.Preprocess(), System.Xml.Schema.SchemaCollectionPreprocessor.PreprocessAnnotation(), System.Xml.Schema.SchemaCollectionPreprocessor.PreprocessAttribute(), System.Xml.Schema.SchemaCollectionPreprocessor.PreprocessAttributeGroup(), System.Xml.Schema.SchemaCollectionPreprocessor.PreprocessComplexType(), System.Xml.Schema.SchemaCollectionPreprocessor.PreprocessElement(), System.Xml.Schema.SchemaCollectionPreprocessor.PreprocessGroup(), System.Xml.Schema.SchemaCollectionPreprocessor.PreprocessNotation(), System.Xml.Schema.SchemaCollectionPreprocessor.PreprocessRedefine(), System.Xml.Schema.SchemaCollectionPreprocessor.PreprocessSimpleType(), System.Collections.Generic.Dictionary< TKey, TValue >.Remove(), System.SR.Sch_AttributeValueDataType, System.SR.Sch_ImportTargetNamespace, System.SR.Sch_ImportTargetNamespaceNull, System.SR.Sch_InvalidBlockDefaultValue, System.SR.Sch_InvalidCollection, System.SR.Sch_InvalidFinalDefaultValue, System.SR.Sch_InvalidNamespace, System.SR.Sch_InvalidNamespaceAttribute, System.SR.Sch_InvalidSchemaLocation, System.SR.Sch_InvalidTargetNamespaceAttribute, System.SR.Sch_MismatchTargetNamespaceEx, System.SR.Sch_MismatchTargetNamespaceImport, System.SR.Sch_MismatchTargetNamespaceInclude, System.SR.Sch_MissRequiredAttribute, System.SR.Sch_RedefineNoSchema, System.Xml.Schema.BaseProcessor.SendValidationEvent(), System.Xml.Schema.SchemaCollectionPreprocessor.SetParent(), System.Xml.XmlConvert.ToUri(), System.Xml.Schema.SchemaCollectionPreprocessor.ValidateIdAttribute(), System.value, System.Collections.Generic.Dictionary< TKey, TValue >.Values, and System.Xml.XmlConvert.VerifyTOKEN().

Referenced by System.Xml.Schema.SchemaCollectionPreprocessor.Execute(), and System.Xml.Schema.SchemaCollectionPreprocessor.Preprocess().