Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem to follow schema: xsd:sequence with maxOccurs="unbounded" #1424

Open
Hanmac opened this issue Aug 18, 2022 · 0 comments
Open

Problem to follow schema: xsd:sequence with maxOccurs="unbounded" #1424

Hanmac opened this issue Aug 18, 2022 · 0 comments

Comments

@Hanmac
Copy link

Hanmac commented Aug 18, 2022

Q A
Bug report? no
Feature request? yes
BC Break report? maybe
RFC? no

Steps required to reproduce the problem

i got this xsd part:

<xsd:element name="EMAILS">
	<xsd:complexType>
		<xsd:sequence maxOccurs="unbounded">
			<xsd:element ref="EMAIL"/>
			<xsd:element ref="PUBLIC_KEY" minOccurs="0" maxOccurs="unbounded"/>
		</xsd:sequence>
	</xsd:complexType>
</xsd:element>

my Problem is now that the sequence has maxOccurs="unbounded",
so my first try was to put the sequence into its own class, and try to make it inline

/**
 * @Serializer\XmlRoot("EMAILS")
 */
class Emails
{
    /**
     * @Serializer\Expose
     * @Serializer\XmlList(inline = "true")
     * @Serializer\Inline
     *
     * @var EmailsInner[]
     */
    protected array $inners = [];
}

Expected Result

<?xml version="1.0" encoding="UTF-8"?>
<EMAILS>
  <EMAIL><![CDATA[A]]></EMAIL>
  <EMAIL><![CDATA[B]]></EMAIL>
</EMAILS>

Actual Result

<?xml version="1.0" encoding="UTF-8"?>
<EMAILS>
  <entry>
    <EMAIL><![CDATA[A]]></EMAIL>
  </entry>
  <entry>
    <EMAIL><![CDATA[B]]></EMAIL>
  </entry>
</EMAILS>

i assume it isn't just serializing but de-serializing too which should be affected by this?

and no i can't change the schema.

With PreSerialize

With PreSerialize i could add it to a list attribute to serialize it,
but that causes it to be this:

Actual Result

<?xml version="1.0" encoding="UTF-8"?>
<EMAILS>
  <entry><![CDATA[A]]></entry>
  <entry><![CDATA[KeyA]]></entry>
  <entry><![CDATA[B]]></entry>
  <entry><![CDATA[KeyB]]></entry>
</EMAILS>

instead of this:

Expected Result

<?xml version="1.0" encoding="UTF-8"?>
<EMAILS>
  <EMAIL><![CDATA[A]]></EMAIL>
  <PUBLIC_KEY><![CDATA[KeyA]]></PUBLIC_KEY>
  <EMAIL><![CDATA[B]]></EMAIL>
  <PUBLIC_KEY><![CDATA[KeyB]]></PUBLIC_KEY>
</EMAILS>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant