3030{
3131 public const DOC_TYPE_VERSION = '1.2.063 ' ;
3232
33- private function __construct (private SerializerInterface $ jmsSerializer )
34- {
33+ private function __construct (
34+ private SerializerInterface $ jmsSerializer ,
35+ private string $ dtdUri ,
36+ ) {
3537 }
3638
37- public static function create (): self
39+ public static function create (string $ dtdUri = ' http://xml.cxml.org/schemas/cXML/ ' . self :: DOC_TYPE_VERSION . ' /cXML.dtd ' ): self
3840 {
3941 $ jmsSerializer = SerializerBuilder::create ()
4042 ->configureListeners (static function (EventDispatcherInterface $ dispatcher ): void {
@@ -55,7 +57,7 @@ public static function create(): self
5557 )
5658 ->build ();
5759
58- return new self ($ jmsSerializer );
60+ return new self ($ jmsSerializer, $ dtdUri );
5961 }
6062
6163 public function deserialize (string $ xml ): CXml
@@ -71,11 +73,11 @@ public function deserialize(string $xml): CXml
7173 return $ this ->jmsSerializer ->deserialize ($ xml , CXml::class, 'xml ' );
7274 }
7375
74- public function serialize (CXml $ cxml, string $ docTypeVersion = self :: DOC_TYPE_VERSION ): string
76+ public function serialize (CXml $ cxml ): string
7577 {
7678 $ xml = $ this ->jmsSerializer ->serialize ($ cxml , 'xml ' );
7779
78- $ docType = '<!DOCTYPE cXML SYSTEM "http://xml.cxml.org/schemas/cXML/ ' . $ docTypeVersion . '/cXML.dtd "> ' ;
80+ $ docType = '<!DOCTYPE cXML SYSTEM " ' . $ this -> dtdUri . '"> ' . "\n" ;
7981 $ xmlPrefix = '<?xml version="1.0" encoding="UTF-8"?> ' ;
8082
8183 // add doctype, as it is mandatory in cXML
0 commit comments