Xml Exercise Step 1 Create Dtd Peoplexml Add Top New File Peoplewithdtdxml Older Content U Q37054776

This is an XML exercise.

Step 1:

Create a DTD for People.xml and add it to the top of a new file,PeopleWithDTD.xml, with the older contentunderneath:  

<!DOCTYPE People [

<!ELEMENT People (Person*)>

<!ELEMENT Person (Name, Description)>

<!ATTLIST Person bornDate CDATA #REQUIRED>

<!ATTLIST Person diedDate CDATA #REQUIRED>

<!ELEMENT Name (#PCDATA)>

<!ELEMENT Description (#PCDATA)>

]>

<People>

<!– rest of people.xml –>

</People>

Step 2:

Modify SaxParser4.java so that the class is now SaxParser5 andchange the main() method to set the ErrorHandler as shownpreviously:   

public static void main( String[] argv ){

String inputFile = argv[0];

System.out.println(“Processing ‘” + inputFile + “’.”);

System.out.println( “SAX Events:” );

try {

XMLReader reader = XMLReaderFactory.createXMLReader();

SaxParser5 parser = new SaxParser5();

reader.setContentHandler(parser);

reader.setErrorHandler(parser);

reader.parse( new InputSource(

new FileReader( inputFile )));

}catch ( Exception e

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.