/
XmlDtdUsage.shtml
102 lines (85 loc) · 4.13 KB
/
XmlDtdUsage.shtml
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta name="generator" content=
"HTML Tidy for Mac OS X (vers 31 October 2006 - Apple Inc. build 15.17), see www.w3.org">
<title>JMRI: XML DTD Usage</title>
<meta name="author" content="Bob Jacobsen">
<meta name="keywords" content="JMRI technical code xml usage">
<!-- The combination of "Define" and {Header,Style, Logo and Footer} comments -->
<!-- are an arbitrary design pattern used by the update.pl script to -->
<!-- easily replace the common header/footer code for all the web pages -->
<!-- delete the following 2 Defines if you want to use the default JMRI logo -->
<!-- or change them to reflect your alternative logo -->
<!--#include virtual="/Style.shtml" -->
</head>
<body>
<!--#include virtual="/Header.shtml" -->
<div id="mBody">
<!--#include virtual="Sidebar.shtml" -->
<div id="mainContent">
<h1>JMRI: XML DTD Usage</h1>
<p class="important">This page describes the former usage
of XML DTDs in JMRI before version 2.9.4. The use of these
DTDs in JMRI was replaced with
<a href="XmlSchema.shtml">XML schema</a> in JMRI 2.9.4.</p>
<p>In the JMRI distributions, the DTDs are stored in the
<a href="/xml/DTD">xml/DTD</a> directory. Note that they are
not stored in each directory alongside the XML files. There
are just too many locations to keep such a set of DTD files
up to date. JMRI itself, via the jmri.jmrit.XmlFile class,
provides support for locating those files when the XML parser
needs them.</p>Each file contains a DOCTYPE line that
specifies a DTD name. There are three different methods used
to locate the actual DTD file:
<ul>
<li>Web browsers look exactly where the DOCTYPE line
specifies, and must find the DTD there to function.</li>
<li>JMRI 1.8 and earlier assumes that the name is relative
to the program's xml/DTD directory, and looks for it using
that. In practice, this allows two forms for the DOCTYPE
line:
<ul>
<li>name.dtd</li>
<li>../DTD/name.dtd</li>
</ul>Early XML files used both; the program itself could
generate either depending on the circumstances.
</li>
<li>JMRI 1.9.2 and later provide a more powerful DTD search
procedure using the <a href=
"https://jmri.org/JavaDoc/doc/jmri/util/JmriLocalEntityResolver.html">
jmri.util.JmriLocalEntityResolver</a> class. It parses
the reference in the DOCTYPE and handles it in several
ways:
<ul>
<li>If it's an HTTP URL, JMRI first attempts to find
the corresponding file in the local distribution. If
so, it uses the local copy, otherwise it attempts to
load a copy from the Internet using the URL.</li>
<li>If it's a file path that starts with "../DTD/",
JMRI looks in it's local xml/DTD directory for the DTD
file.</li>
<li>If the path is just a filename, JMRI looks in it's
local xml/DTD directory for the DTD file.</li>
<li>In any other case, e.g. a local or absolute
pathname, JMRI looks there for the DTD file. Relative
pathnames are interpreted as starting from the JMRI
install directory.</li>
</ul>If the file can't be found, the XML file isn't
opened. These JMRI versions write just the DTD filename
in the DOCTYPE line when writing XML files. This provides
complete backward compatibility with existing files and
older versions of JMRI back to 1.7.1. At the same time,
since it can handle HTTP URLs even without an Internet
connection, it allows us to eventually move forward.
</li>
</ul>
<b>Starting with JMRI 2.9.4, JMRI uses <a href=
"XmlSchema.shtml">XML schema</a> instead of DTDs, and this
process is different.</b>
<!--#include virtual="/Footer.shtml" -->
</div><!-- closes #mainContent-->
</div><!-- closes #mBody-->
</body>
</html>