Click here for ObjectSpace: Business- to- Business Integration Company
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Platinum Edition Using HTML 4, XML, and Java 1.2
(Publisher: Macmillan Computer Publishing)
Author(s): Eric Ladd
ISBN: 078971759x
Publication Date: 11/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


Listing 16.3 DTD Declarations in the Internal Subset


<?xml version=“1.0” ?>
<!DOCTYPE helptopic [
<!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”>

]>

Parsing this file with DXP produces the following:

FATAL ERROR: parameter entity reference in entity value in internal subset
for “admonitions”

Location: file:/c:/xmlex/dtdv.xml:9:65

In the internal DTD subset, parameter-entity references (%admonitions; and %paracontent;) can occur only where markup declarations can occur, and not within markup declarations such as the declaration of the element tip.

What does this mean? It means that code like the following is allowed:

<!DOCTYPE helptopic [
<!ATTLIST helptopic a CDATA “A11”>
<!ENTITY % buttons SYSTEM “button.ent”>
%buttons;
]>

You can include the parameter entity reference %buttons; at that place because markup declarations could be entered also.

Conversely, it means that code like the following is not allowed:

<!DOCTYPE helptopic [
<!ENTITY % paracontent “(#PCDATA | emphasis)*”>
<!ELEMENT tip %paracontent; >
]>

This is because the parameter entity reference appears in a markup declaration.

The best way to resolve this situation is not to get into it in the first place. You can accomplish this in one of two ways:

  Bring everything back to the external subset.
  Replace the parameter references with their declared content.

Listing 16.4 shows what the internal subset looks like with parameter references replaced by declared content.

Listing 16.4 Replacing Parameter References with Declared Content


<?xml version=“1.0” ?>
<!DOCTYPE helptopic [
<!NOTATION bmp SYSTEM “paint.exe”>
<!NOTATION gif SYSTEM “”>
<!ELEMENT helptopic (title, rule, procedure, rule?, (tip | warning | note)) >
<!ATTLIST helptopic id ID #IMPLIED>

<!ELEMENT title (#PCDATA) >
<!ATTLIST title keyword CDATA #IMPLIED>

<!ELEMENT procedure (step+)>
<!ELEMENT step (action, ((tip | warning | note))*) >

<!ELEMENT action (#PCDATA | icon | menu | xref | iconbmp)* >
<!ELEMENT tip (#PCDATA | icon | menu | xref | iconbmp)* >
<!ATTLIST tip targetgroup (beginners | specialists) “beginners” >

<!ELEMENT warning (#PCDATA | icon | menu | xref | iconbmp)* >
<!ELEMENT note (#PCDATA | icon | menu | xref | iconbmp)* >

<!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”>

]>

Checking Your DTD Using XML for Java

XML for Java is a validating XML parser written in Java. The package (com.ibm.xml.parser) contains Java classes and methods for parsing, generating, manipulating, and validating XML documents. XML for Java is a robust XML processor and is very complete.

To download and install XML for Java, follow these steps:

1.  Download XML for Java from http://www.alphaworks.ibm.com/formula/xml/. The file xml4j.1.0.0.zip is 1.039KB in size.
2.  Unzip xml4j.1.0.0.zip into a new directory on your system’s hard drive.


NOTE:  This is another Java implementation, so make sure you have a Java Virtual Machine version 1.x running.

With the class and method files unzipped, you are ready to run XML for Java. Type the following from a DOS prompt:

jre -cp c:\xml4j\xml4j.jar trlx c:\xmlex\dtdv.xml

Here’s a breakdown of what you just typed:

  jre invokes the Java Runtime Engine.
  -cp sets the classpath. In this case, you refer to the jar (Java archive file) as xml4j.jar.
  trlx is the Java class that does the parsing.
  c:\xmlex\dtdv.xml is the file to be checked.

Note that the preceding command is telling XML for Java to parse and validate the file dtdv.xml, which is the same file used in the discussion of DXP. When you hand this file to XML for Java, you get the following set of error messages:

dtdv.dtd: 8, 30: Spaces are expected.
dtdv.dtd: 8, 30: ‘#REQUIRED’ or ‘#IMPLIED’ or ‘#FIXED’ or attribute value
is expected.
dtdv.dtd: 21, 35: This content model is not matched with the mixed model
‘(#PCDATA|FOO|BAR|...|BAZ)*’: ‘(#PCDATA|shortcut)+’
dtdv.dtd: 24, 29: ‘CDATA’ or ‘ID’ or ‘IDREF’ or ‘IDREFS’or ‘ENTITY’ or
‘ENTITIES’ or ‘NMTOKEN’ or ‘NMTOKENS’ or ‘NOTATION’ or ‘(‘ is expected.
dtdv.dtd: 27, 24: Element ‘tip’ is already declared.
dtdv.dtd: 31, 27: NOTATION ‘bmp’ is not declared.
dtdv.dtd: 31, 33: NOTATION ‘gif’ is not declared.
c:\xmlex\dtdv.xml: 3, 3: The document has no element.


Previous Table of Contents Next


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.