Skip to content

Serializing complexType generates <result> tags #186

@rauanmayemir

Description

@rauanmayemir

When trying to serialize a document into XML and using a Generated\DocumentType it will result in having a <result>{structure}</result> form.

Is there a way to specify how I want the root to be?

For external schemas, it is not always possible to adjust the schema and add something like <xs:element name="concrete" type="DocumentType"/>. Those types are meant to be serialized and wrapped into an anyType container like:

<data xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SerializedDocumentTypeWithoutRootElement>...</SerializedDocumentTypeWithoutRootElement>
</data>

My goal is avoiding manual string replacing and manipulating output after serializing into XML.

I tried to play with SerializerInterface->serialize and look into SerializationContext, but without any examples it's hard to understand if it's what I need.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions