Converting from DTD 'ANY'
Right. But DTDs don't have real wildcards, so if a DTD author wants a real wildcard, the best they can do is approximate it with ANY. Most of the uses of ANY I've come across are cases of this, rather than people actually wanting the DTD semantics.
In any case, if you want exactly the DTD semantics, trang can give it to you. See the -i strict-any option: thaiopensource.com
It is indeed invalid. Trang is not guaranteed to catch errors in input, and when the output is xsd, it may generate erroneous output as well. It's a best-effort program.
Trang and comments
On input, trang associates comments with the next following object (i.e. pattern, name-class, grammar component, annotation). On output, it reverses this. The next object following the "case b" comment is the empty pattern. So on output, the comment will end up before <empty/> element.
This means that the style of commenting in the compact syntax where you put the comment on the same line after the thing it applies doesn't translate well. Perhaps trang could notice when there's no newline between an object and a comment and then associate the comment with the preceding object and flag that in its internal representation, but I think it would be hard to make it always do what a human who actually understood the comment would do.