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


Every error message consists of the following:

  The file in which the error appears
  The line number
  The character position where the problem was detected
  A description of the error

Note that XML for Java gives you all of the errors at once. This is very different from DXP, which presents errors up until a fatal error is encountered.

With XML for Java, it is possible to check the DTD directly by adding the parameter –dtd to the command line, and to read the file with the external subset directly:

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

This is a much cleaner approach that will generate the same set of error messages (except for the last error, which points out that “the document has no element”).


NOTE:  XML for Java handles declarations in the internal subset in much the same way DXP does.

Checking the Validity of XML Files with DXP

You have seen how to use two different tools to parse and validate your XML DTDs. As noted earlier in the chapter, you can use both tools to validate an XML file as well. This section examines how to validate an XML document using DXP.

To use DXP as a document validator, enter a command like the following at the DOS prompt:

jre –cp .;c:\datachannel\dxp\classes dxpcl –s –v c:\xmlex\wfq.xml

Here’s a breakdown of what you just typed:

  jre invokes the Java Runtime Engine.
  -cp sets the classpath (where to find the classes used). In this case you specified two paths: the first (.) refers to the current working directory, and the second is c:\datachannel\dxp\classes). They’re separated by ;.
  dxpcl is the name of the Java program (class).
  -s stands for “silent mode.”
  -v stands for “validation on.”
  c:\xmlex\wfq.xml is the file to be checked.

The file wfq.xml that is being submitted to DXP is shown in Listing 16.5.

Listing 16.5 XML Document to Check for Validity


<?xml version=“1.0” ?>
<?protext objid=“I5678” ?>
<!DOCTYPE helptopic [
<!ENTITY doubleclick “Double-click”>
]>
<helptopic>
<title keyword=“printing,network;printing,shared printer”>How to use a
shared network printer?</title>
<procedure>
<step><action>In <icon>Network Neighborhood</icon>, locate and
double-click the computer where the printer you want to use is located.
</action>
<tip targetgroup=“beginners”>To see which computers have shared printers
attached, click the <menu>View</menu> menu,
click <menu>Details</menu>, &amp; look for printer names or descriptions
in the Comment column of the Network Neighborhood window.</tip>
</step>
<step>
<action>&doubleclick; the printer icon in the window that appears.
</action>
</step>
<step>
<action>
To set up the printer, <xref linkend=“id45”>follow the instructions</xref>
 on the screen.
</action></step>
</procedure>
<rule form=“double”/>
<tip>
<p>After you have set up a network printer, you can use it as if it were
attached to your computer. For related topics, look up
&quot;printing&quot; in the Help Index.
</p>
</tip>
</helptopic>

Earlier in the chapter, you validated the DTD shown in Listing 16.6 for helptopic documents.

Listing 16.6 Validated DTD for helptopic Documents


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

DXP will use this DTD to check wfq.xml for validity. DXP will know to use this DTD once the filename dtdv.dtd is included in the doctype declaration of wfq.xml:

<!DOCTYPE helptopic SYSTEM “dtdv.dtd” []>

Thus, the file becomes the following:

<?xml version=“1.0” ?>
<?protext objid=“I5678” ?>
<!DOCTYPE helptopic SYSTEM “dtdv.dtd” [
<!ENTITY doubleclick “Double-click”>
]>
<helptopic>
...
<tip>
<p>After you have set up a network printer, you can use it as if it were
attached to your computer. For related topics, look up &quot;printing&quot;
in the Help Index.
</p>
</tip>
</helptopic>


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.