(definitions?: DefinitionsElement, xmlns?: IXmlNs)
| 386 | public $base: string; |
| 387 | |
| 388 | public description(definitions?: DefinitionsElement, xmlns?: IXmlNs) { |
| 389 | const children = this.children; |
| 390 | let desc; |
| 391 | let isFirstChild = false; |
| 392 | const $attributes = {}; |
| 393 | |
| 394 | for (const child of children) { |
| 395 | if (child instanceof AttributeElement) { |
| 396 | $attributes[child.$name] = child.description(definitions); |
| 397 | continue; |
| 398 | } |
| 399 | if (!isFirstChild && (child instanceof SequenceElement || child instanceof ChoiceElement)) { |
| 400 | isFirstChild = true; |
| 401 | desc = child.description(definitions, xmlns); |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | if (Object.keys($attributes).length > 0) { |
| 406 | desc = desc ?? {}; |
| 407 | desc[AttributeElement.Symbol] = $attributes; |
| 408 | } |
| 409 | |
| 410 | if (desc && this.$base) { |
| 411 | const type = splitQName(this.$base); |
| 412 | const typeName = type.name; |
| 413 | const ns = findNs(type.prefix, xmlns, this.definitionsXmlns, definitions.xmlns); |
| 414 | const schema = definitions.schemas[ns]; |
| 415 | const typeElement = schema && (schema.complexTypes[typeName] || schema.types[typeName] || schema.elements[typeName]); |
| 416 | |
| 417 | desc.getBase = () => { |
| 418 | return typeElement.description(definitions, schema.xmlns); |
| 419 | }; |
| 420 | if (typeElement) { |
| 421 | const baseDescription = typeElement.description(definitions, schema.xmlns); |
| 422 | if (baseDescription[AttributeElement.Symbol]) { |
| 423 | defaults($attributes, baseDescription[AttributeElement.Symbol]); |
| 424 | } |
| 425 | desc = defaults(desc, baseDescription); |
| 426 | } |
| 427 | return desc; |
| 428 | } |
| 429 | |
| 430 | const restrictions = this.children |
| 431 | .map((child) => { |
| 432 | return child.description(); |
| 433 | }) |
| 434 | .join(','); |
| 435 | |
| 436 | return [this.$base, restrictions].filter(Boolean).join('|'); |
| 437 | } |
| 438 | } |
| 439 | |
| 440 | export class ExtensionElement extends Element { |
nothing calls this directly
no test coverage detected