Skip to content

Commit f4ebc7b

Browse files
authored
Merge pull request #48 from veewee/always-use-element-namespace-as-target
Always use element namespace as target namespace
2 parents 7243e65 + 4e456c6 commit f4ebc7b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +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() ?? '';
30-
$typeNamespace = $type?->getSchema()->getTargetNamespace() ?: $targetNamespace;
33+
$typeNamespace = match (true) {
34+
$itemIsSchemaRootElement => $targetNamespace,
35+
default => $type?->getSchema()->getTargetNamespace() ?: $targetNamespace,
36+
};
3137

32-
$parentContext = $context->parent()->unwrapOr(null);
3338
$xmlTypeName = match(true) {
39+
$itemIsSchemaRootElement && $item => $item->getName(),
3440
$parentContext && $item instanceof ElementItem => (new ElementTypeNameDetector())($item, $parentContext),
3541
$parentContext && $item instanceof AttributeItem => (new AttributeTypeNameDetector())($item, $parentContext),
3642
default => $typeName,

0 commit comments

Comments
 (0)