Closed mijgame closed 3 years ago
there is notthing indicating the Namespace for the $attribute
variable.
The @JMS\XmlNamespace
annotations are used only for the root object, after that the namespace declaration on the specific property is used.
Hi goetas,
The XML namespace declarations on the Node class are applicable to all elements right? If I don't inherit from the Node
class, the whole thing doesn't work anyway.
class Extensions extends Node
{
/**
* @JMS\XmlNamespace("https://fluend.nl/ns", prefix="fluend")
* @JMS\Type("Fluend\Core\Bpmn\Deserialization\Attributes")
* @var Attributes
*/
public $attributes;
}
The above also produces null, unfortunately.
Hi @goetas
I had already tried that:
/**
* @JMS\XmlAttribute(namespace="http://fluend.nl/ns")
* @JMS\Type("Fluend\Core\Bpmn\Deserialization\Attributes")
* @var Attributes
*/
public $attributes;
and
/**
* @JMS\XmlAttribute
* @JMS\Type("Fluend\Core\Bpmn\Deserialization\Attributes")
* @var Attributes
*/
public $attributes;
Both result in a null
.
as you can see in the link ive posted, i mention @XmlElement(namespace="http://fluend.nl/ns")
, not @JMS\XmlAttribute
I'm sorry. The following does also produce a null:
/**
* @JMS\XmlElement(namespace="http://fluend.nl/ns")
* @JMS\Type("Fluend\Core\Bpmn\Deserialization\Attributes")
* @var Attributes
*/
public $attributes;
and
/**
* @JMS\XmlElement(namespace="http://fluend.nl/ns", cdata=false)
* @JMS\Type("Fluend\Core\Bpmn\Deserialization\Attributes")
* @var Attributes
*/
public $attributes;
Empty @XmlElement
doesn't work either.
you should put @JMS\XmlElement(namespace="http://www.omg.org/spec/BPMN/20100524/MODEL")
on the extensions node too.
I'm re-opening this issue so someone else can help you here, but I'm convinced that is not a bug, just a mis-configuration.
Thank you for your help, I have figured it out. I ended up with the following:
In Task
:
/**
* @JMS\SerializedName("extensionElements")
* @JMS\XmlElement(namespace="http://www.omg.org/spec/BPMN/20100524/MODEL")
* @JMS\Type("Fluend\Core\Bpmn\Deserialization\Extensions")
* @var Extensions
*/
public $extensions;
In Extensions
:
/**
* @JMS\XmlElement(namespace="http://fluend.nl/ns")
* @JMS\Type("Fluend\Core\Bpmn\Deserialization\Attributes")
* @var Attributes
*/
public $attributes;
In Attributes
(note the Namespace
on the XmlList
):
/**
* @JMS\Type("array<Fluend\Core\Bpmn\Deserialization\Mapping>")
* @JMS\XmlList(inline=true,entry="mapping",skipWhenEmpty=false,namespace="http://fluend.nl/ns")
* @var Mapping[]
*/
public $mappings;
Hi.
I'm currently running into an issue deserializing a part of an XML file. Arrays and scalars seem to work just fine (based on
XmlList
,XmlValue
orXmlAttribute
). I run into an issue however when I try to deserialize a class (not directly a scalar value). The result is always deserialized tonull
. I have notices that when I annotate theextensionElement
with@XmlValue
or@Inline
, they seem to be instantiated. Their contents are alwaysnull
however (and I suppose that makes sense, as we want the child to have it's own context).It's unclear to me whether I am actually missing an attribute, or that there is something wrong with the way I am handling the namespaces.
The XML I'm trying to deserialize:
This is the part of the XML I'm having trouble with:
This is the class definition for
Task
:The parent class,
Node
, is used to specify the namespace for every type of element:The
Extensions
class (which should contain the values inextensionElements
) is defined as follows:The serializer is configured as follows:
In the above configuration,
$extensions
is alwaysnull
. Do you have any suggestions about what I could be doing wrong? Please let me know if you need anything else.Thanks in advance.