-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Hi,
I am trying to parse the following response cXml, which is valid according to this dtd.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cXML SYSTEM "http://xml.cxml.org/schemas/cXML/1.2.051/cXML.dtd">
<cXML payloadID="1628239652567.37776.32900@proactis.com" timestamp="2025-08-13T07:32:32-10:47" xml:lang="en">
<Response>
<Status code="403" text="Forbidden"/>
</Response>
</cXML>I do this with the following method:
// ...
new Endpoint(
\CXml\Serializer::create(),
\CXml\Validation\DtdValidator::fromDtdDirectory(...),
\CXml\Processor\Processor(...),
)->parseAndProcessStringAsCXml(...);Note that there is no payload in the cxml response, but the parser expects one. I get the error:
Error: Typed property CXml\Model\Response\Response::$payload must not be accessed before initialization
/var/www/html/vendor/friendsofcxml/cxml-php/src/CXml/Processor/Processor.php:106
After inspection, I found out that the processor checks if the xml is a response and if so, the result is processed as a response. In this response, the payload is nullable
cxml-php/src/CXml/Model/Response/Response.php
Lines 16 to 17 in e793887
| #[Serializer\Exclude] | |
| public ?ResponsePayloadInterface $payload = null, |
but it instructs the serialiser to exclude that property. This results apparently in the property not being initialised, not even with the default value
nullAnd even if it would be initialised with the given value, it would still not work because the only valid value for the payload is a
ResponsePayloadInterface, resulting in the parsed response to be nullhttps://github.com/FriendsOfCXML/cxml-php/blob/main/src/CXml/Processor/Processor.php#L106-L110
Am I using the wrong method for parsing the response, or is there some other issue?
ynnoig