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

CDATA sections not being disabled in XML despite setting xml_cdata to false in goetas-webservices/xsd2php #155

Open
NathanaelSantos opened this issue Feb 10, 2023 · 2 comments

Comments

@NathanaelSantos
Copy link

NathanaelSantos commented Feb 10, 2023

"require": {
    "goetas-webservices/xsd2php-runtime": "^0.2.16"
  },
"require-dev": {
    "goetas-webservices/xsd2php": "^0.4.7"
  }
idEscola:
            expose: true
            access_type: public_method
            serialized_name: idEscola
            xml_element:
                cdata: false
                namespace: 'http://www.tce.se.gov.br/sagres2023/xml/sagresEdu'
            accessor:
                getter: getIdEscola
                setter: setIdEscola
            type: int

In my config.yml:

  configs_jms:  #optional
    xml_cdata: false # Disables CDATA

The generated XML:

<entry>
      <id_escola><![CDATA[28022386]]></id_escola>
      <turma/>
      <diretor>
        <cpf_diretor><![CDATA[39353893534]]></cpf_diretor>
        <nr_ato><![CDATA[]]></nr_ato>
      </diretor>
      <cardapio/>
</entry>

It appears that despite setting xml_cdata to false, the XML still contains CDATA sections. This could be a bug in the library "goetas-webservices/xsd2php" ?

@fklee
Copy link

fklee commented Jul 27, 2023

I found another solution :
in goetas-webservices/xsd2php/src/DependencyInjection/Configuration.php

replace this code segment :

                ->arrayNode('configs_jms')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->booleanNode('xml_cdata')
                            ->defaultTrue()
                        ->end()
                    ->end()
                ->end()

to :

                ->arrayNode('configs_jms')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->booleanNode('xml_cdata')
                            ->defaultFalse()
                        ->end()
                    ->end()
                ->end()

As change default from true to false.

@nathanipti
Copy link

Vlw 👍 fklee

I found a solution here: https://jmsyst.com/libs/serializer/master/reference/annotations

use JMS\Serializer\Annotation\Type;
use JMS\Serializer\Annotation\SerializedName;
use JMS\Serializer\Annotation\XmlElement;

class MyClass
{
      /**
       * @var \DateTime $data
       * @Type("DateTime<'Y-m-d'>")
       * @XmlElement(cdata=false)
       */
      private $data = null;
}

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

3 participants