1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| import com.wutka.dtd.*;
import java.io.*;
import java.util.*;
public class ParseDTD {
public static void main(String[] args) {
int nbElements = 0;
System.out.println("Parsing de la DTD...");
File dtdFile = new File("K:\\Docbook\\cpamvodcbk.dtd");
PrintWriter pw = null;
try {
pw = new PrintWriter(new FileOutputStream("K:\\Docbook\\export.dtd"), true);
} catch (FileNotFoundException e) {
System.out.println("Impossible d'ouvrir le fichier de sortie");
System.exit(0);
}
try {
DTDParser parser = new DTDParser(dtdFile);
DTD docbookDTD = parser.parse();
Hashtable elemDTD = docbookDTD.elements;
nbElements = elemDTD.size();
Enumeration enum = elemDTD.elements();
while(enum.hasMoreElements()) {
DTDElement el = (DTDElement)enum.nextElement();
el.write(pw);
}
} catch (IOException e) {
System.out.println("Erreur " + e);
}
System.out.println("Parsing terminé:\n" + nbElements + " éléments parsés.");
}
} |
Partager