XML DTD Validaiton with sax\Writer.java
How to perform XML DTD validation with sax\Writer.java provided in the Apache Xerces package?
You can perform XML DTD validation with the sax\Writer.java program provided in the Apache Xerces package as shown below.
Run the sax\Writer.java program with "-v" option to turn on validation. If the input XML file does not meet the requirements of its DTD, you will see validation errors:
\fyicenter\xerces-2_11_0\samples>\fyicenter\jdk-1.8.0\bin\java -cp .;..\xercesImpl.jar sax.Writer -v UserError.xml <?xml version="1.0" encoding="UTF-8"?> <User> <ID>101</ID> <Name>Frank Y. Ivy</Name> [Error] UserError.xml:14:8: The content of element type "User" must match "(ID+, BirthDate+,Name+,Sex+)". </User>
The XML file with DTD used in the above test is:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!-- Copyright (c) 2017 FYIcenter.com --> <!DOCTYPE User [ <!ELEMENT User (ID+, BirthDate+, Name+, Sex+)> <!ELEMENT ID (#PCDATA)> <!ELEMENT BirthDate (#PCDATA)> <!ELEMENT Name (#PCDATA)> <!ELEMENT Sex (#PCDATA)> ]> <User> <ID>101</ID> <Name>Frank Y. Ivy</Name> </User>
2017-10-08, 1652👍, 0💬
commons-codec-1.11.jar is the JAR file for Apache Commons Codec 1.11, which provides implementations...
How to read XML document with DTD validation from socket connections with the socket\DelayedInput.ja.. .
What Is jaxb-impl-2.1.12.jar? Java Architecture for XML Binding (JAXB) is a Java API that allows Jav...
How to download and install javamail1_1_3.zip? The JavaMail API is a set of abstract APIs that model...
Apache Ant is a Java-based build tool. In theory, it is kind of like make, without make's wrinkles. ...