1 |
14
|
jones
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
2 |
|
|
<!--NewPage-->
|
3 |
|
|
<html>
|
4 |
|
|
<head>
|
5 |
|
|
<!-- Generated by javadoc on Fri Sep 24 03:23:03 CEST 1999 -->
|
6 |
|
|
<title>
|
7 |
|
|
Class de.tudarmstadt.ito.xmldbms.mapfactories.MapFactory_DTD
|
8 |
|
|
</title>
|
9 |
|
|
</head>
|
10 |
|
|
<body>
|
11 |
|
|
<a name="_top_"></a>
|
12 |
|
|
<pre>
|
13 |
|
|
<a href="packages.html">All Packages</a> <a href="tree.html">Class Hierarchy</a> <a href="Package-de.tudarmstadt.ito.xmldbms.mapfactories.html">This Package</a> <a href="Package-de.tudarmstadt.ito.xmldbms.mapfactories.html">Previous</a> <a href="de.tudarmstadt.ito.xmldbms.mapfactories.MapFactory_MapDocument.html#_top_">Next</a> <a href="AllNames.html">Index</a></pre>
|
14 |
|
|
<hr>
|
15 |
|
|
<h1>
|
16 |
|
|
Class de.tudarmstadt.ito.xmldbms.mapfactories.MapFactory_DTD
|
17 |
|
|
</h1>
|
18 |
|
|
<pre>
|
19 |
|
|
java.lang.Object
|
20 |
|
|
|
|
21 |
|
|
+----de.tudarmstadt.ito.xmldbms.mapfactories.MapFactory_DTD
|
22 |
|
|
</pre>
|
23 |
|
|
<hr>
|
24 |
|
|
<dl>
|
25 |
|
|
<dt> public class <b>MapFactory_DTD</b>
|
26 |
|
|
<dt> extends Object
|
27 |
|
|
</dl>
|
28 |
|
|
Create a Map from a DTD object.
|
29 |
|
|
<p>MapFactory_DTD constructs tables and columns in which the element types
|
30 |
|
|
and attributes described in the DTD object can be stored, then creates
|
31 |
|
|
a Map that maps the element types and attributes to these tables and
|
32 |
|
|
columns. The resulting Map cannot be used immediately with DBMSToDOM or
|
33 |
|
|
DOMToDBMS because no connection has been set on it. Furthermore, it is
|
34 |
|
|
possible that the tables referred to by the map don't yet exist. However,
|
35 |
|
|
it can be serialized as a mapping document or used to generate CREATE
|
36 |
|
|
TABLE statements.</p>
|
37 |
|
|
<P>For example, the following code creates a map from the DTD document.dtd,
|
38 |
|
|
creates the tables, sets the connection, and then transfers data to the
|
39 |
|
|
database:</P>
|
40 |
|
|
<pre>
|
41 |
|
|
// Instantiate a new map factory and create a map.
|
42 |
|
|
factory = new MapFactory_DTD();
|
43 |
|
|
map = factory.createMapFromDTD(src, MapFactory_DTD.DTD_EXTERNAL, true, null);<br />
|
44 |
|
|
// Create the tables used by the map. Note that this function calls
|
45 |
|
|
// Map.getCreateTableStrings(), then executes each string in a
|
46 |
|
|
// JDBC Statement.
|
47 |
|
|
createTables(map);<br />
|
48 |
|
|
// Set the database connection, then transfer the data to the database.
|
49 |
|
|
map.setConnection(conn);
|
50 |
|
|
domToDBMS = new DOMToDBMS(map);
|
51 |
|
|
domToDBMS.storeDocument(doc);
|
52 |
|
|
</pre>
|
53 |
|
|
<p>MapFactory_DTD constructs tables and columns roughly as follows. Note
|
54 |
|
|
that these tables and columns are not actually created in the database;
|
55 |
|
|
to do this, the application must retrieve CREATE TABLE strings from
|
56 |
|
|
the resulting Map and execute these in JDBC statements. The reason for
|
57 |
|
|
this is that applications will commonly want to change the table structure
|
58 |
|
|
predicted by MapFactory_DTD before actually creating tables or simply
|
59 |
|
|
use this factory as a tool for creating Maps, which can be serialized
|
60 |
|
|
with the Map.serialize() method.</p>
|
61 |
|
|
<ul>
|
62 |
|
|
<li>For each element type that has attributes or child elements, a table
|
63 |
|
|
is generated. In this table are an ID column, one column for each
|
64 |
|
|
single-valued attribute, one column for each singly-occurring child
|
65 |
|
|
element type that contains only PCDATA and has no attributes, an (optional)
|
66 |
|
|
order column for each child element type column, and one ID column for each
|
67 |
|
|
parent element type. If the element type has attributes and PCDATA but
|
68 |
|
|
no child element types, then there is also a column for its PCDATA. Note
|
69 |
|
|
that the ID column appears only if needed to link to a child table.</li>
|
70 |
|
|
<li>If an attribute is multi-valued (IDREFS, NMTOKENS, or ENTITIES), it
|
71 |
|
|
is stored in a separate table, with an element type ID column, a value
|
72 |
|
|
column, and an (optional) order column.</li>
|
73 |
|
|
<li>If a child element type that contains only PCDATA and has no attributes
|
74 |
|
|
can occur multiple times in its parent, it is stored in a separate table,
|
75 |
|
|
with a parent element type ID column, a value column, and an
|
76 |
|
|
(optional) order column.</li>
|
77 |
|
|
<li>Except as noted above, PCDATA is stored in a separate table with an
|
78 |
|
|
element type ID column, a value column, and an (optional) order column.</li>
|
79 |
|
|
<li>The code also guesses at what the legal root element types are. An
|
80 |
|
|
element type is considered to be a root if it has no parents. If all
|
81 |
|
|
element types have parents, then all element types are made legal roots.</li>
|
82 |
|
|
</ul>
|
83 |
|
|
<p><b>WARNING!</b> This code does not check for name collisions. A number
|
84 |
|
|
of name collisions are possible. The possible table and column names are
|
85 |
|
|
listed below. If these clash with each other, the result is missing tables
|
86 |
|
|
and/or columns. If these clash with existing table names, the result is
|
87 |
|
|
the inability to correctly transfer data to the database. You should also
|
88 |
|
|
remember that table and column names in many databases are case insensitive,
|
89 |
|
|
so collisions due to case folding are possible.</p>
|
90 |
|
|
<pre>
|
91 |
|
|
Table name: element type name
|
92 |
|
|
Column names:
|
93 |
|
|
element type name + "ID"
|
94 |
|
|
element type name + "PCDATA"
|
95 |
|
|
element type name + "PCDATA" + "Order"
|
96 |
|
|
parent element type name + "ID"
|
97 |
|
|
child element type name + "ID"
|
98 |
|
|
child element type name + "Order"
|
99 |
|
|
attribute name
|
100 |
|
|
Table name: attribute name
|
101 |
|
|
Column names:
|
102 |
|
|
element type name + "ID"
|
103 |
|
|
attribute name
|
104 |
|
|
attribute name + "Order"
|
105 |
|
|
Table name: element type name + "PCDATA"
|
106 |
|
|
Column names:
|
107 |
|
|
element type name + "ID"
|
108 |
|
|
element type name + "PCDATA"
|
109 |
|
|
element type name + "PCDATA" + "Order"
|
110 |
|
|
</pre>
|
111 |
|
|
<p>
|
112 |
|
|
<hr>
|
113 |
|
|
<a name="index"></a>
|
114 |
|
|
<h2>
|
115 |
|
|
<img src="images/variable-index.gif" width=207 height=38 alt="Variable Index">
|
116 |
|
|
</h2>
|
117 |
|
|
<dl>
|
118 |
|
|
<dt> <img src="images/blue-ball-small.gif" width=6 height=6 alt=" o ">
|
119 |
|
|
<a href="#DTD_EXTERNAL"><b>DTD_EXTERNAL</b></a>
|
120 |
|
|
<dd> DTD is an external subset.
|
121 |
|
|
<dt> <img src="images/blue-ball-small.gif" width=6 height=6 alt=" o ">
|
122 |
|
|
<a href="#DTD_XMLDOCUMENT"><b>DTD_XMLDOCUMENT</b></a>
|
123 |
|
|
<dd> The DTD is in an XML document, as an internal subset, reference
|
124 |
|
|
to an external subset, or both.
|
125 |
|
|
<dt> <img src="images/blue-ball-small.gif" width=6 height=6 alt=" o ">
|
126 |
|
|
<a href="#SCHEMA_DCD"><b>SCHEMA_DCD</b></a>
|
127 |
|
|
<dd> Schema document uses DCD (not supported).
|
128 |
|
|
<dt> <img src="images/blue-ball-small.gif" width=6 height=6 alt=" o ">
|
129 |
|
|
<a href="#SCHEMA_DDML"><b>SCHEMA_DDML</b></a>
|
130 |
|
|
<dd> Schema document uses DDML.
|
131 |
|
|
<dt> <img src="images/blue-ball-small.gif" width=6 height=6 alt=" o ">
|
132 |
|
|
<a href="#SCHEMA_SOX"><b>SCHEMA_SOX</b></a>
|
133 |
|
|
<dd> Schema document uses SOX (not supported).
|
134 |
|
|
<dt> <img src="images/blue-ball-small.gif" width=6 height=6 alt=" o ">
|
135 |
|
|
<a href="#SCHEMA_W3C"><b>SCHEMA_W3C</b></a>
|
136 |
|
|
<dd> Schema document uses W3C XML Schemas (not supported).
|
137 |
|
|
<dt> <img src="images/blue-ball-small.gif" width=6 height=6 alt=" o ">
|
138 |
|
|
<a href="#SCHEMA_XMLDATA"><b>SCHEMA_XMLDATA</b></a>
|
139 |
|
|
<dd> Schema document uses XML-Data (not supported).
|
140 |
|
|
</dl>
|
141 |
|
|
<h2>
|
142 |
|
|
<img src="images/constructor-index.gif" width=275 height=38 alt="Constructor Index">
|
143 |
|
|
</h2>
|
144 |
|
|
<dl>
|
145 |
|
|
<dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
|
146 |
|
|
<a href="#MapFactory_DTD()"><b>MapFactory_DTD</b></a>()
|
147 |
|
|
<dd> Construct a new MapFactory_DTD.
|
148 |
|
|
</dl>
|
149 |
|
|
<h2>
|
150 |
|
|
<img src="images/method-index.gif" width=207 height=38 alt="Method Index">
|
151 |
|
|
</h2>
|
152 |
|
|
<dl>
|
153 |
|
|
<dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
|
154 |
|
|
<a href="#createMap(de.tudarmstadt.ito.schemas.dtd.DTD, boolean)"><b>createMap</b></a>(DTD, boolean)
|
155 |
|
|
<dd> Create a map from a DTD object.
|
156 |
|
|
<dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
|
157 |
|
|
<a href="#createMapFromDTD(org.xml.sax.InputSource, int, boolean, java.util.Hashtable)"><b>createMapFromDTD</b></a>(InputSource, int, boolean, Hashtable)
|
158 |
|
|
<dd> Create a map from an InputSource representing an external DTD subset or
|
159 |
|
|
an XML document containing a DTD.
|
160 |
|
|
<dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
|
161 |
|
|
<a href="#createMapFromSchema(org.xml.sax.InputSource, int, boolean, org.xml.sax.Parser)"><b>createMapFromSchema</b></a>(InputSource, int, boolean, Parser)
|
162 |
|
|
<dd> Create a map from an InputSource representing a schema.
|
163 |
|
|
</dl>
|
164 |
|
|
<a name="variables"></a>
|
165 |
|
|
<h2>
|
166 |
|
|
<img src="images/variables.gif" width=153 height=38 alt="Variables">
|
167 |
|
|
</h2>
|
168 |
|
|
<a name="SCHEMA_DCD"><img src="images/blue-ball.gif" width=12 height=12 alt=" o "></a>
|
169 |
|
|
<b>SCHEMA_DCD</b>
|
170 |
|
|
<pre>
|
171 |
|
|
public static final int SCHEMA_DCD
|
172 |
|
|
</pre>
|
173 |
|
|
<dl>
|
174 |
|
|
<dd> Schema document uses DCD (not supported).<p>
|
175 |
|
|
</dl>
|
176 |
|
|
<a name="SCHEMA_DDML"><img src="images/blue-ball.gif" width=12 height=12 alt=" o "></a>
|
177 |
|
|
<b>SCHEMA_DDML</b>
|
178 |
|
|
<pre>
|
179 |
|
|
public static final int SCHEMA_DDML
|
180 |
|
|
</pre>
|
181 |
|
|
<dl>
|
182 |
|
|
<dd> Schema document uses DDML.<p>
|
183 |
|
|
</dl>
|
184 |
|
|
<a name="SCHEMA_SOX"><img src="images/blue-ball.gif" width=12 height=12 alt=" o "></a>
|
185 |
|
|
<b>SCHEMA_SOX</b>
|
186 |
|
|
<pre>
|
187 |
|
|
public static final int SCHEMA_SOX
|
188 |
|
|
</pre>
|
189 |
|
|
<dl>
|
190 |
|
|
<dd> Schema document uses SOX (not supported).<p>
|
191 |
|
|
</dl>
|
192 |
|
|
<a name="SCHEMA_W3C"><img src="images/blue-ball.gif" width=12 height=12 alt=" o "></a>
|
193 |
|
|
<b>SCHEMA_W3C</b>
|
194 |
|
|
<pre>
|
195 |
|
|
public static final int SCHEMA_W3C
|
196 |
|
|
</pre>
|
197 |
|
|
<dl>
|
198 |
|
|
<dd> Schema document uses W3C XML Schemas (not supported).<p>
|
199 |
|
|
</dl>
|
200 |
|
|
<a name="SCHEMA_XMLDATA"><img src="images/blue-ball.gif" width=12 height=12 alt=" o "></a>
|
201 |
|
|
<b>SCHEMA_XMLDATA</b>
|
202 |
|
|
<pre>
|
203 |
|
|
public static final int SCHEMA_XMLDATA
|
204 |
|
|
</pre>
|
205 |
|
|
<dl>
|
206 |
|
|
<dd> Schema document uses XML-Data (not supported).<p>
|
207 |
|
|
</dl>
|
208 |
|
|
<a name="DTD_EXTERNAL"><img src="images/blue-ball.gif" width=12 height=12 alt=" o "></a>
|
209 |
|
|
<b>DTD_EXTERNAL</b>
|
210 |
|
|
<pre>
|
211 |
|
|
public static final int DTD_EXTERNAL
|
212 |
|
|
</pre>
|
213 |
|
|
<dl>
|
214 |
|
|
<dd> DTD is an external subset.<p>
|
215 |
|
|
</dl>
|
216 |
|
|
<a name="DTD_XMLDOCUMENT"><img src="images/blue-ball.gif" width=12 height=12 alt=" o "></a>
|
217 |
|
|
<b>DTD_XMLDOCUMENT</b>
|
218 |
|
|
<pre>
|
219 |
|
|
public static final int DTD_XMLDOCUMENT
|
220 |
|
|
</pre>
|
221 |
|
|
<dl>
|
222 |
|
|
<dd> The DTD is in an XML document, as an internal subset, reference
|
223 |
|
|
to an external subset, or both.<p>
|
224 |
|
|
</dl>
|
225 |
|
|
<a name="constructors"></a>
|
226 |
|
|
<h2>
|
227 |
|
|
<img src="images/constructors.gif" width=231 height=38 alt="Constructors">
|
228 |
|
|
</h2>
|
229 |
|
|
<a name="MapFactory_DTD"></a>
|
230 |
|
|
<a name="MapFactory_DTD()"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
|
231 |
|
|
<b>MapFactory_DTD</b>
|
232 |
|
|
<pre>
|
233 |
|
|
public MapFactory_DTD()
|
234 |
|
|
</pre>
|
235 |
|
|
<dl>
|
236 |
|
|
<dd> Construct a new MapFactory_DTD.
|
237 |
|
|
<p>
|
238 |
|
|
</dl>
|
239 |
|
|
<a name="methods"></a>
|
240 |
|
|
<h2>
|
241 |
|
|
<img src="images/methods.gif" width=151 height=38 alt="Methods">
|
242 |
|
|
</h2>
|
243 |
|
|
<a name="createMapFromDTD(org.xml.sax.InputSource, int, boolean, java.util.Hashtable)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
|
244 |
|
|
<a name="createMapFromDTD"><b>createMapFromDTD</b></a>
|
245 |
|
|
<pre>
|
246 |
|
|
public <a href="de.tudarmstadt.ito.xmldbms.Map.html#_top_">Map</a> createMapFromDTD(InputSource src,
|
247 |
|
|
int type,
|
248 |
|
|
boolean storeOrder,
|
249 |
|
|
Hashtable namespaceURIs) throws <a href="de.tudarmstadt.ito.xmldbms.InvalidMapException.html#_top_">InvalidMapException</a>, <a href="de.tudarmstadt.ito.schemas.dtd.DTDException.html#_top_">DTDException</a>, EOFException, MalformedURLException, IOException
|
250 |
|
|
</pre>
|
251 |
|
|
<dl>
|
252 |
|
|
<dd> Create a map from an InputSource representing an external DTD subset or
|
253 |
|
|
an XML document containing a DTD.
|
254 |
|
|
<p>
|
255 |
|
|
<dd><dl>
|
256 |
|
|
<dt> <b>Parameters:</b>
|
257 |
|
|
<dd> filename - The name of the schema file.
|
258 |
|
|
<dd> type - DTD_EXTERNAL or DTD_XMLDOCUMENT.
|
259 |
|
|
<dd> storeOrder - Whether the map should store order information in
|
260 |
|
|
the database.
|
261 |
|
|
<dd> namespaceURIs - A Hashtable using prefixes as keys and namespace
|
262 |
|
|
URIs as values. May be null.
|
263 |
|
|
<dt> <b>Returns:</b>
|
264 |
|
|
<dd> The Map object.
|
265 |
|
|
<dt> <b>Throws:</b> <a href="de.tudarmstadt.ito.xmldbms.InvalidMapException.html#_top_">InvalidMapException</a>
|
266 |
|
|
<dd> Thrown if a mapping error occurs.
|
267 |
|
|
<dt> <b>Throws:</b> <a href="de.tudarmstadt.ito.schemas.dtd.DTDException.html#_top_">DTDException</a>
|
268 |
|
|
<dd> Thrown if a DTD error is found.
|
269 |
|
|
<dt> <b>Throws:</b> EOFException
|
270 |
|
|
<dd> Thrown if EOF is reached prematurely.
|
271 |
|
|
<dt> <b>Throws:</b> MalformedURLException
|
272 |
|
|
<dd> Thrown if a system ID is malformed.
|
273 |
|
|
<dt> <b>Throws:</b> IOException
|
274 |
|
|
<dd> Thrown if an I/O error occurs.
|
275 |
|
|
</dl></dd>
|
276 |
|
|
</dl>
|
277 |
|
|
<a name="createMapFromSchema(org.xml.sax.InputSource, int, boolean, org.xml.sax.Parser)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
|
278 |
|
|
<a name="createMapFromSchema"><b>createMapFromSchema</b></a>
|
279 |
|
|
<pre>
|
280 |
|
|
public <a href="de.tudarmstadt.ito.xmldbms.Map.html#_top_">Map</a> createMapFromSchema(InputSource src,
|
281 |
|
|
int type,
|
282 |
|
|
boolean storeOrder,
|
283 |
|
|
Parser parser) throws <a href="de.tudarmstadt.ito.xmldbms.InvalidMapException.html#_top_">InvalidMapException</a>, SAXException, IOException
|
284 |
|
|
</pre>
|
285 |
|
|
<dl>
|
286 |
|
|
<dd> Create a map from an InputSource representing a schema.
|
287 |
|
|
<p>Currently, only DDML files are supported.</p>
|
288 |
|
|
<p>
|
289 |
|
|
<dd><dl>
|
290 |
|
|
<dt> <b>Parameters:</b>
|
291 |
|
|
<dd> filename - The name of the schema file.
|
292 |
|
|
<dd> type - The schema type: SCHEMA_DCD, SCHEMA_DDML, SCHEMA_SOX,
|
293 |
|
|
SCHEMA_XMLDATA, SCHEMA_W3C.
|
294 |
|
|
<dd> storeOrder - Whether the map should store order information in
|
295 |
|
|
the database.
|
296 |
|
|
<dd> parser - A SAX Parser to parse the InputSource.
|
297 |
|
|
<dt> <b>Returns:</b>
|
298 |
|
|
<dd> The Map object.
|
299 |
|
|
<dt> <b>Throws:</b> <a href="de.tudarmstadt.ito.xmldbms.InvalidMapException.html#_top_">InvalidMapException</a>
|
300 |
|
|
<dd> Thrown if a mapping error occurs.
|
301 |
|
|
<dt> <b>Throws:</b> SAXException
|
302 |
|
|
<dd> Thrown if a SAX error occurs.
|
303 |
|
|
<dt> <b>Throws:</b> IOException
|
304 |
|
|
<dd> Thrown if an I/O error occurs.
|
305 |
|
|
</dl></dd>
|
306 |
|
|
</dl>
|
307 |
|
|
<a name="createMap(de.tudarmstadt.ito.schemas.dtd.DTD, boolean)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
|
308 |
|
|
<a name="createMap"><b>createMap</b></a>
|
309 |
|
|
<pre>
|
310 |
|
|
public <a href="de.tudarmstadt.ito.xmldbms.Map.html#_top_">Map</a> createMap(<a href="de.tudarmstadt.ito.schemas.dtd.DTD.html#_top_">DTD</a> dtd,
|
311 |
|
|
boolean storeOrder) throws <a href="de.tudarmstadt.ito.xmldbms.InvalidMapException.html#_top_">InvalidMapException</a>
|
312 |
|
|
</pre>
|
313 |
|
|
<dl>
|
314 |
|
|
<dd> Create a map from a DTD object.
|
315 |
|
|
<p>
|
316 |
|
|
<dd><dl>
|
317 |
|
|
<dt> <b>Parameters:</b>
|
318 |
|
|
<dd> dtd - A DTD object from which to create the Map.
|
319 |
|
|
<dd> storeOrder - Whether the map should store order information in
|
320 |
|
|
the database.
|
321 |
|
|
<dt> <b>Returns:</b>
|
322 |
|
|
<dd> The Map object.
|
323 |
|
|
<dt> <b>Throws:</b> <a href="de.tudarmstadt.ito.xmldbms.InvalidMapException.html#_top_">InvalidMapException</a>
|
324 |
|
|
<dd> Thrown if a map error occurs.
|
325 |
|
|
</dl></dd>
|
326 |
|
|
</dl>
|
327 |
|
|
<hr>
|
328 |
|
|
<pre>
|
329 |
|
|
<a href="packages.html">All Packages</a> <a href="tree.html">Class Hierarchy</a> <a href="Package-de.tudarmstadt.ito.xmldbms.mapfactories.html">This Package</a> <a href="Package-de.tudarmstadt.ito.xmldbms.mapfactories.html">Previous</a> <a href="de.tudarmstadt.ito.xmldbms.mapfactories.MapFactory_MapDocument.html#_top_">Next</a> <a href="AllNames.html">Index</a></pre>
|
330 |
|
|
</body>
|
331 |
|
|
</html>
|