gazebosim/sdformat

RFC: Convert xmlschema.rb to c++

Open

#118 opened on Apr 3, 2016

View on GitHub
 (4 comments) (0 reactions) (0 assignees)C++ (122 forks)auto 404
good first issuehelp wantedminorproposal

Repository metrics

Stars
 (216 stars)
PR merge metrics
 (PR metrics pending)

Description

Original report (archived issue) by Rich Mattes (Bitbucket: richmattes).


I had some spare time a few months ago and managed to convert xmlschema.rb to c++ using tinyxml. I was wondering if there's any interest from you guys in supporting such a switch.

The tinyxml-based C++ xmlschema is basically a line-for-line port of the existing ruby script to C++. It provides the following:

Benefits:

  • No build-time dependency on ruby (might be nice for Windows)
  • Runs faster than the ruby schema generator

Drawbacks:

  • Lose dynamic features ruby provides
  • Whitespace in CDATA (descriptions) isn't preserved when converting from .sdf files

The lossy treatment of whitespace seems to be a well-known attribute of tinyxml, and they recommend that tinyxml2 should be used instead (in general, and also because of the whitespace handling.)

I ended up making a second version of xmlschema using tinyxml2, and was able to get identical output to the ruby scripts. It wasn't terribly difficult to go from tinyxml->tinyxml2, but using a different version of tinyxml than sdformat uses seemed to be kind of silly, and I didn't have enough time to try to port sdformat to tinyxml2.

If there's interest in either or both versions of the code I'll clean it up and create PRs, otherwise you can go ahead and close this bug.

Contributor guide