Skip to content

Commit 4e456c6

Browse files
committed
use element name + namespace for schema root element definitions
1 parent a201d82 commit 4e456c6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Metadata/Converter/Types/Configurator/XmlTypeInfoConfigurator.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,19 @@ public function __invoke(EngineType $engineType, mixed $xsdType, TypesConverterC
2424
$item = $xsdType instanceof Item ? $xsdType : null;
2525
$type = $xsdType instanceof Type ? $xsdType : $item?->getType();
2626

27+
$parentContext = $context->parent()->unwrapOr(null);
28+
$itemIsSchemaRootElement = $item instanceof ElementItem && $parentContext?->currentParent() === $xsdType;
29+
2730
$itemName = $item?->getName() ?: $type?->getName();
2831
$typeName = $type?->getName() ?? '';
2932
$targetNamespace = $xsdType->getSchema()->getTargetNamespace() ?? '';
3033
$typeNamespace = match (true) {
31-
$item instanceof ElementItem => $targetNamespace,
34+
$itemIsSchemaRootElement => $targetNamespace,
3235
default => $type?->getSchema()->getTargetNamespace() ?: $targetNamespace,
3336
};
3437

35-
$parentContext = $context->parent()->unwrapOr(null);
3638
$xmlTypeName = match(true) {
39+
$itemIsSchemaRootElement && $item => $item->getName(),
3740
$parentContext && $item instanceof ElementItem => (new ElementTypeNameDetector())($item, $parentContext),
3841
$parentContext && $item instanceof AttributeItem => (new AttributeTypeNameDetector())($item, $parentContext),
3942
default => $typeName,

0 commit comments

Comments
 (0)