Does anyone know of a method, or library, to convert SGML into XML?
EDIT: For clarification, I have to do the conversion in Java, and I cannot use the SP parser or the related SX tool.
It seems that the general consensus is that there are no existing libraries for doing SGML work in Java. Certainly after several days of fruitlessly searching Google, and asking this question here, I have found no resources on this subject.
The answer is not always that simple, as it depends on the sgml DTD. I haven't actually found a general SGML parser in Java at all, but this article uses SP which includes a converter.
See http://jclark.com/sp/sx.htm for the SX converter from SGML to XML in the SP package.
There is the mlParser, but I'm having a hard time trying to locate it: http://www.balisage.net/Proceedings/vol1/html/Smith01/BalisageVol1-Smith01.html
There is no api for parsing SGML using Java at this time. There also isn't any api or library for converting SGML to XML and then parsing it using Java. With the status of SGML being supplanted by XML for all the projects I've worked on until now, I don't think there will every be any work done in this area, but that is only a guess.
Here is some open source code code from a University that does it, however I haven't tried it and you would have to search to find the other dependent classes. I believe the only viable solution in Java would require Regular Expressions.
Also, here is a link for public SGML/XML software.
来源:https://stackoverflow.com/questions/1504202/java-sgml-to-xml-conversion