1 26 27 package com.bull.eclipse.jonas.utils.xml.desc; 28 29 import java.net.URL ; 30 import java.util.HashMap ; 31 import java.util.Map ; 32 33 34 35 39 public abstract class CommonsDTDs implements DTDs { 40 41 44 private static final String [] DEFAULT_DTDS = new String [] { 45 "XMLSchema.dtd", 46 "datatypes.dtd" 47 }; 48 49 52 private static final String [] DEFAULT_DTDS_PUBLIC_ID = new String [] { 53 "-//W3C//DTD XMLSCHEMA 200102//EN", 54 "datatypes" 55 }; 56 57 58 61 private static HashMap dtdsMapping = null; 62 63 66 public CommonsDTDs() { 67 dtdsMapping = new HashMap (); 68 addMapping(DEFAULT_DTDS, DEFAULT_DTDS_PUBLIC_ID); 69 } 70 71 75 public Map getMapping() { 76 return dtdsMapping; 77 } 78 79 80 81 86 protected void addMapping(String [] dtds, String [] publicIds) { 87 if (dtds.length != publicIds.length) { 88 throw new IllegalStateException ("SEVERE ERROR !!! Number of dtds is different of the number of PublicId !!! check the source code"); 89 } 90 91 URL url = null; 92 for (int i = 0; i < dtds.length; i++) { 93 url = CommonsDTDs.class.getResource("/" + dtds[i]); 94 if (!(url == null)) { 95 dtdsMapping.put(publicIds[i], url.toString()); } 98 } 100 } 101 102 } 103 | Popular Tags |