Revision 109
Added by bojilova about 24 years ago
DBEntityResolver.java | ||
---|---|---|
65 | 65 |
// register publicId in db and use the provided systemId |
66 | 66 |
if (systemId != "") { |
67 | 67 |
new URL(systemId); |
68 |
registerDTDPublicID (conn, doctype, publicId, systemId);
|
|
68 |
registerDTDSystemID (conn, doctype, publicId, systemId);
|
|
69 | 69 |
return null; |
70 | 70 |
} |
71 | 71 |
new URL(dbSystemId); |
... | ... | |
89 | 89 |
if ( systemId != null) { |
90 | 90 |
if (currentElementNo == 0) { |
91 | 91 |
doctype = DBSAXHandler.docname; |
92 |
registerDTDPublicID (conn, doctype, "", systemId); |
|
92 |
dbSystemId = getDTDSystemID (conn, doctype); |
|
93 |
if (dbSystemId == "") { |
|
94 |
new URL(systemId); |
|
95 |
registerDTDSystemID (conn, doctype, doctype, systemId); |
|
96 |
return null; |
|
97 |
} |
|
98 |
new URL(dbSystemId); |
|
99 |
return new InputSource(dbSystemId); |
|
93 | 100 |
} |
94 |
new URL(systemId); |
|
95 | 101 |
} |
96 | 102 |
|
97 | 103 |
// use the default behaviour |
98 | 104 |
return null; |
99 | 105 |
} |
100 |
|
|
101 |
/** Look at db XML Catalog to get System ID (if any) for that Public ID.
|
|
106 |
|
|
107 |
/** Look at db XML Catalog to get System ID (if any) for that doctype.
|
|
102 | 108 |
* Return empty string if there are not */ |
103 |
private String getDTDSystemID (Connection conn, String publicId) |
|
104 |
{ |
|
109 |
private String getDTDSystemID (Connection conn, String doctype) { |
|
105 | 110 |
String system_id = ""; |
106 | 111 |
Statement stmt; |
107 | 112 |
try { |
108 | 113 |
stmt = conn.createStatement(); |
114 |
System.out.println("DOCTYPE:" + doctype); |
|
109 | 115 |
stmt.execute("SELECT system_id FROM xml_catalog " + |
110 |
"WHERE entity_type = 'DTD' AND source_doctype = '" + publicId + "'");
|
|
116 |
"WHERE entity_type = 'DTD' AND public_id = '" + doctype + "'");
|
|
111 | 117 |
try { |
112 | 118 |
ResultSet rs = stmt.getResultSet(); |
113 | 119 |
try { |
... | ... | |
135 | 141 |
return system_id; |
136 | 142 |
} |
137 | 143 |
|
138 |
/** Register Public ID in db XML Catalog */
|
|
139 |
private void registerDTDPublicID (Connection conn, String doctype, String publicId, String systemId)
|
|
144 |
/** Register DTD System ID in db XML Catalog */
|
|
145 |
private void registerDTDSystemID (Connection conn, String doctype, String publicId, String systemId)
|
|
140 | 146 |
{ |
141 | 147 |
try { |
148 |
java.net.URLConnection urlConn = (new URL(systemId)).openConnection(); |
|
149 |
urlConn.connect(); |
|
150 |
} catch (java.io.IOException e) { |
|
151 |
System.out.println("IOException: " + e.getMessage()); |
|
152 |
return; |
|
153 |
} |
|
154 |
try { |
|
142 | 155 |
conn.setAutoCommit(false); |
143 | 156 |
PreparedStatement pstmt; |
144 | 157 |
pstmt = conn.prepareStatement( |
Also available in: Unified diff
document root node, doctype changes