How to reorder xml elements in the invalid XML according to the definition of DTD?

Roseanne Zhang

XSLT will not work, since xsl does not read DTD. I search the web, and not found anyway to enforce DTD on invalid XMLs. The reason probably very similar to this one

Q. Can I used a arbitrary defined DTD to generate all possible XML templates?

I'm not saying it is impossible, but it might be extremely difficult.

  • By hand is one way that will always work, if only once.
  • Use a validating editor will greatly speed up your hand process.
  • If the amount is large, but somewhat repeatable, and also you have sufficient knowledage about your XML and DTD, then
    1. use a Java or Perl program read the know DTD, get the order
    2. Read the xml, do text processing (recommended) or use DOM or JDOM to process your XML document.
Good luck!