|
To access the contents, click the chapter and section titles.
Platinum Edition Using HTML 4, XML, and Java 1.2
The problem has to do with this line: <!ATTLIST title keyword CDATA> This declares the attributes for the title elementin this case, title just has the attribute keyword. Recall that when you specify an attribute, you need to provide the following information:
These are all separated by a space. In this case, you have defined:
This default needs to be one of the following:
This needs to be preceded by a space. If you choose #IMPLIED, for example, the line becomes <!ATTLIST title keyword CDATA #IMPLIED> Parsing the document again, you get the following: FATAL ERROR: encountered +. Was expecting: * Location: file:///c:/xmlex/dtdv.dtd:21:34 Found errors/warnings: 1 fatal error(s), 0 error(s) and 0 warning(s) Now the problem lies with the following line: <!ELEMENT menu (#PCDATA|shortcut)+> When you have mixed contentcharacter data interspersed with child elementsthe content model needs to have the * occurrence indicator. Thus, the line needs to become <!ELEMENT menu (#PCDATA|shortcut)*> Reparsing the document, you now get FATAL ERROR: encountered idref. Was expecting one of: ID , IDREF , IDREFS , ENTITY , ENTITIES , NMTOKEN , NMTOKENS , NOTATION , CDATA , % , ( Location: file:///c:/xmlex/dtdv.dtd:24:24 Found errors/warnings: 1 fatal error(s), 0 error(s) and 0 warning(s) All keywords (including idref) need to be in uppercase in XML. Making the necessary correction and running the parser again produces ERROR: element declared twice tip Location: file:///c:/xmlex/dtdv.dtd:27:11 ERROR: notation not declared bmp Location: file:///c:/xmlex/dtdv.dtd:31:41 ERROR: notation not declared gif Location: file:///c:/xmlex/dtdv.dtd:31:44 FATAL ERROR: encountered end of file Location: :3:4 Found errors/warnings: 1 fatal error(s), 3 error(s) and 0 warning(s) Before encountering the fatal error, the parser found three errors that were not fatal. Note that non-fatal errors do not stop the parser from continuing its work. The first non-fatal error occurs because the element tip is declared twice. The XML specification states that no element type may be declared more than once. This is a validity constraint, and violations against validity constraints are considered non-fatal errors. Fortunately, this error is simple to correctyou just need to delete the second declaration of the tip element. The next two non-fatal errors have to do with the bmp and gif notations. This is understandable because, according to the specification, all notation names in the declaration must be explicitly declared. You can compensate for this by adding the following code: <!NOTATION bmp SYSTEM paint.exe> <!NOTATION gif SYSTEM > After this, there is just one error left: FATAL ERROR: encountered end of file Location: :3:4 Found errors/warnings: 1 fatal error(s), 0 error(s) and 0 warning(s) This is actually a little tricky to diagnose. The problem is no longer with the DTD, but with the XML file itself. The XML file passed to the parser has a prologue with an xml declaration and a doctype declaration, but nothing morenot even a root element! Every XML document must have a root element, and this is what led to the fatal error. The good news is that there are no longer any errors in your DTD. The final corrected DTD is shown in Listing 16.2. Listing 16.2 Corrected DTD for DXP Example <!NOTATION bmp SYSTEM paint.exe> <!NOTATION gif SYSTEM > <!ENTITY % admonitions (tip | warning | note) > <!ENTITY % paracontent (#PCDATA | icon | menu | xref | iconbmp)* > <!ELEMENT helptopic (title, rule, procedure, rule?, %admonitions;) > <!ATTLIST helptopic id ID #IMPLIED> <!ELEMENT title (#PCDATA) > <!ATTLIST title keyword CDATA #IMPLIED> <!ELEMENT procedure (step+)> <!ELEMENT step (action, (%admonitions;)*) > <!ELEMENT action %paracontent; > <!ELEMENT tip %paracontent; > <!ATTLIST tip targetgroup (beginners | specialists) beginners > <!ELEMENT warning %paracontent; > <!ELEMENT note %paracontent; > <!ELEMENT icon (#PCDATA) > <!ELEMENT menu (#PCDATA|shortcut)*> <!ELEMENT xref (#PCDATA) > <!ATTLIST xref linkend IDREF #REQUIRED> <!ELEMENT shortcut (#PCDATA)> <!ELEMENT iconbmp EMPTY> <!ATTLIST iconbmp src ENTITY #REQUIRED type NOTATION (bmp | gif) gif>
Declarations in the Internal SubsetThe declarations in the internal subset are those you find between [ and ] in the document type declaration: <!DOCTYPE helptopic [ <!ELEMENT helptopic (title, procedure)> <!ATTLIST helptopic id ID #REQUIRED> … ] <helptopic>….
Suppose for the moment that all your declarations are in the external subset of your document type declaration. What will happen if you copy the content of your file inside your internal subset and dont refer to the external file with the declarations (as in Listing 16.3)?
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |