The DTD, whether or not it will be declared internally (embedded within the XML document) or externally (linked to the XML document), the attribute and value of standalone="no" will be stated within the <?xml> declaration.
This attribute and its value state that the XML document will be validated against a DTD.
<?xml version="1.0" standalone="no"?>
If a DTD will NOT be declared for validity, the default is the attribute and value of standalone="yes" within the <?xml> declaration. This does not need to be stated.
<?xml version="1.0" standalone="yes"?>
The <!DOCTYPE> element is known as the "Document Type Declaration."
The <!DOCTYPE> element is stated within the XML document when the XML document will be validated against either an external or internal DTD.
The <!DOCTYPE> declaration is not an XML element and therefore does not require a closing tag or the forward slash before the closing bracket.
White space placed within an embedded (internal) or linked (external) DTD is not processed by the validator. This white space is usually added for readability.
Both an internal and external DTD may be used to validate a document. The internal DTD takes precedence over the external DTD if the processor comes across any conflicts between the two DTDs.
To call an internal DTD:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE RootElement
[
DTD Content here
]>
The RootElement is the beginning top element of the XML document that will contain all the other elements within the XML document.
|
Call an External SYSTEM DTD |
To call an external SYSTEM DTD:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE RootElement SYSTEM "http://www.domain.com/filename.dtd">
Here we use the attribute of SYSTEM. This defines that the DTD called for is a personal DTD for your own use. Most DTD's will be of this type.
"http://www.domain.com/filename.dtd" tells the validator the location of the .dtd file. A local relative file path may also be stated such as "filename.dtd."
|
Call an External PUBLIC DTD |
To call an external PUBLIC DTD:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE RootElement PUBLIC
"-//CompanyName//DTD Description//Language//"
"http://www.domain.com/filename.dtd">
Here we use the attribute of PUBLIC. This defines that the DTD will be used by others.(For a DTD to be widely accepted, specific industries would need to agree upon one.)
"-//CompanyName//DTD Description//Language//" is called the Formal Public Identifier (FPI).
The minus sign indicates that the DTD is NOT a recognized standard. The plus sign indicates that the DTD has been approved by a standards body such as the ISO (International Organization for Standardization.)
The name of the company is self-explanatory. It may also be the name of the author of the DTD.
The DTD description would be the name of the DTD plus any other pertinent information such as version number, for example.
Finally the language that the DTD is written in is declared. A list of language codes.
"http://www.domain.com/filename.dtd" tells the validator the location of the .dtd file. Usually this will be an absolute path name.
The ISO is an international organization composed of national standards bodies from over 75 countries. The ISO has defined a number of important computer standards such as the Open Systems Interconnection, a standardized architecture for designing networks.
|
Call both an Internal and External DTD |
To call both an internal and external DTD:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE RootElement SYSTEM
"http://www.domain.com/filename.dtd"
[
DTD content here
]>
OR
<!DOCTYPE RootElement PUBLIC
"-//CompanyName//DTD Description//Language//"
"http://www.domain.com/filename.dtd">
[
DTD content here
]> |