RA-Consulting-GmbH / openscenario.api.test

Apache License 2.0
39 stars 12 forks source link

OpenScenarioXMLExporter does not add xml declaration #201

Closed shankarpatali-stla closed 3 weeks ago

shankarpatali-stla commented 1 year ago

Describe the bug OpenScenarioXmlExporter::CreateXmlDocument does not add XML declaration. XML declaration is typically the first line in the file. For example, <?xml version="1.0" encoding="utf-8"?>.

To Reproduce Steps to reproduce the behavior:

  1. Create pointer to a valid scenario object of type std::shared_ptr<IOpenScenarioWriter>
  2. Call OpenScenarioXmlExporter::CreateXmlDocument. Pass the pointer created in step 1 as input parameter.
  3. Store the return value in std::shared_ptr
  4. Print the xml document.

Sample code:

// Get valid scenario
std::shared_ptr<IOpenScenarioWriter> scenario_ptr = GetValidScenario();
// Create xml document
OpenScenarioXmlExporter scenario_xml_exporter;
std::shared_ptr<tinyxml2::XMLDocument> xml_document = scenario_xml_exporter.CreateXmlDocument(scenario_ptr);
// Print xml document
tinyxml2::XMLPrinter printer;
xml_document->RootElement()->Accept(&printer);
std::cout << printer.CStr() << std::endl;

Expected behavior XML Declaration is present the XML document returned by CreateXmlDocument function.

Screenshots None

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

NoahSchickIntech commented 1 year ago

I wouldn't classify this as a bug. Yes, "XML documents SHOULD begin with a declaration" but only "XML 1.1 documents MUST begin with a declaration"

ahege commented 1 year ago

OK, I think we should fiy this. Start an export with xml declaration.

kmfrank commented 3 weeks ago

fixed