DTD
| Definition: |
| Microsoft's XDR schema is based on DTD. (used int their *.net
programming) to convert DTD to XDR, add all elements with model="closed" (this means that you cannot add elements to the end of already declared sequences. (In XDR you can -- the default is "open") XDR allows namespaces and typecasting |
| Describe and validate data |
| communicate structure to applications and people |
| constrain element content |
| provide default attribute values |
| not extensible |
| only one DTD may be associated with each document |
| don't support NAMESPACES |
| weak datatyping |
| no OO-type object inheritance |
| data can ignore the external DTD by using the internal subset |
| no DOM support |
| To verify your data: | ||
| Comments |
<!-- --> can be included on any dtd page |
|
| Elements | dtd rules | |
| Attributes | dtd rules | |
| Escaping some characters and/or using replaceable content | Entity | Replaceable content (internal and external entities) the attribute has a set value (like our return address) String Literals--Entity References -- CDATA section -- for escaping characters |
| Notation -- with DTDs | non XML data (like applications and binary image
data) Works with Entities |
Unicode specs --Character References | used to substitute characters that violate the syntax rules (like the & character) |
| MNTOKEN, MNTOKENS | The value is a valid XML name | |
| External subset | linked to your xml data | |
| (how it links) | <?xml version="1.0" encoding="ISO8859-1"
?> <!DOCTYPE DOCUMENT SYSTEM "data.dtd"> |
the top line identifies your xml document as an xml document, must be first |
| SYSTEM is appropriate to an individual website PUBLIC is appropriate to a DTD that is for multiple websites |
||
| Follow your declaration with the path to your dtd
Notice that the path FOLLOWS the xml type declaration |
||
| * this is ON the *.xml page | ||
| Internal subset <!DOCTYPE DOCUMENT SYSTEM "data.dtd" [ xxx]> |
[xxx] -- This is the portion that is internal Overrides the external DTD |
|
Validating with the XML Parser
If you try to open an XML document, the XML Parser might generate an error.
By accessing the parseError object, the exact error code, the error text, and
even the line that caused the error can be retrieved:
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.validateOnParse="true"
xmlDoc.load("note_dtd_error.xml")
document.write("<br>Error Code: ")
document.write(xmlDoc.parseError.errorCode)
document.write("<br>Error Reason: ")
document.write(xmlDoc.parseError.reason)
document.write("<br>Error Line: ")
document.write(xmlDoc.parseError.line)
Turning Validation off
Validation can be turned off by setting the XML parser's validateOnParse="false