Today, the programming problem is encountered using the DOM4J to parse the XML file. Since the XML file is required to be validate, but because the XML resource does not have an ASSIGN DTD constraint, an additional DTD is provided for verification. This causes the use of SAXReader.SetValidation (TRUE) to rely on DTD to check, and have not found a good solution for a long time.
There is no way, I have to use ASSIGN operations that add DTD before parsing XML.
There are two implementation methods for this method.
1. First parse an XML file without DTD, resolve to Document, use doc.setDOCTYPE () to add DTD constraint, then turn this DOC object to an InputStream, the second parsing operation, you can directly Use the added DTD to verify XML. However, this method needs to analyze two XML, some problems in efficiency.
2. Use the XML file to replace it with a string to replace its starting part to increase the DTD constraint. I have not tried this method. Since I only need to resolve the XML process, it should be more efficient than the first multi-stronger, but if I use the XML file is not standardized, it may bring a problem to the character replacement.
I don't know if there is any way to attach a constraint for an XML file ...
Depressed...