Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Encoder/OptionalElementEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public function iso(Context $context): IsoInterface
return $elementIso;
}

$xsiNamespace = Xmlns::xsi()->value();

return new Iso(
/**
* @param T|null $raw
Expand All @@ -63,7 +65,7 @@ public function iso(Context $context): IsoInterface
/**
* @return T|null
*/
static function (ElementList|Element|string $xml) use ($elementIso, $isList) : mixed {
static function (ElementList|Element|string $xml) use ($elementIso, $isList, $xsiNamespace) : mixed {
if ($xml === '') {
return null;
}
Expand All @@ -79,7 +81,7 @@ static function (ElementList|Element|string $xml) use ($elementIso, $isList) : m
$parsedXml instanceof Element => $parsedXml->element(),
default => null
};
if ($documentElement && $documentElement->getAttributeNS(Xmlns::xsi()->value(), 'nil') === 'true') {
if ($documentElement && $documentElement->getAttributeNS($xsiNamespace, 'nil') === 'true') {
return null;
}

Expand Down
10 changes: 2 additions & 8 deletions src/Xml/Reader/ElementValueReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
use Soap\Encoding\Encoder\Context;
use Soap\Encoding\Encoder\XmlEncoder;
use VeeWee\Reflecta\Iso\IsoInterface;
use function Psl\Type\string;
use function VeeWee\Xml\Dom\Locator\Node\value as readValue;

final class ElementValueReader
{
Expand All @@ -30,9 +28,7 @@ public function __invoke(
*/
public static function forEncoder(Context $context, XmlEncoder $encoder, Element $element): mixed
{
return $encoder->iso($context)->from(
readValue($element, string())
);
return $encoder->iso($context)->from($element->substitutedNodeValue);
}

/**
Expand All @@ -41,8 +37,6 @@ public static function forEncoder(Context $context, XmlEncoder $encoder, Element
*/
public static function forIso(IsoInterface $iso, Element $element): mixed
{
return $iso->from(
readValue($element, string())
);
return $iso->from($element->substitutedNodeValue);
}
}
Loading