Does anyone know of a tool that would allow me to take an XML string in Java, check it against a schema, and fix it if it is malformed?
For example, given the following schema and xml code
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="tag">
<xs:element name="subtag" type="xs:token" />
</xs:element>
</xs:schema>
<tag>
<subtag>content
</tag>
I am looking for a tool that can read the schema, parse the XML, notice the missing tag, and add it. For purposes of this particular program, I don't need any correction other than missing tags. (btw, a tool that can locate and add missing tags without using the schema is fine also).
Any suggestions?
Try JTidy, it will fix up malformed XML as well as HTML.