Question: Need help with a Java problem: XMLToken.java: package parseXML; public class XMLToken { private String token; public XMLToken(String token) { this.token=token; } public boolean isTag()

Need help with a Java problem:

Need help with a Java problem: XMLToken.java: package parseXML; public class XMLToken

{ private String token; public XMLToken(String token) { this.token=token; } public boolean

XMLToken.java:

package parseXML;

public class XMLToken { private String token; public XMLToken(String token) { this.token=token; } public boolean isTag() { if(token.length()>=3){ if(token.charAt(0)=='') return true;; } return false; } public boolean isOpeningTag() { if(isTag()) { if(token.charAt(1)!='/') return true; } return false; } public boolean isClosingTag() { if(isTag()) { if(token.charAt(1)=='/') return true; } return false; }

public String getTagName() { if(isTag()) { if(isClosingTag()) return token.substring(2,token.length()-1); else return token.substring(1,token.length()-1); } return ""; }

}

Exception classes:

ParseXMLImproperlyNestedTagsException.java:

package parseXML;

public class ParseXMLImproperlyNestedTagsException extends RuntimeException { public ParseXMLImproperlyNestedTagsException(String message) { super(message); } }

ParseXMLMissingClosingTagException.java:

package parseXML;

public class ParseXMLMissingClosingTagException extends RuntimeException { public ParseXMLMissingClosingTagException(String message) { super(message); } }

ParseXMLMissingOpeningTagException.java:

package parseXML;

public class ParseXMLMissingOpeningTagException extends RuntimeException {

public ParseXMLMissingOpeningTagException(String message) { super(message); }

}

ParseXMLTest.zip:

xmlerror1.txt:

John Doe

111 Elm Street Joliet Illinois 60435

xmlerror2.txt:

John Doe

111 Elm Street Joliet Illinois 60435

xmlerror3.txt:

John Doe

111 Elm Street Joliet Illinois 60435

xmltest1.txt:

This is the first paragraph. Not much is here. But even less is in this paragraph. Or is there? No, it appears to be longer.

xmltest2.txt:

John Doe

111 Elm Street Joliet Illinois 60435

Setting up Create a package called parsexML. Copy into it the reference class XMLToken you created in a past assignment. Create in it a program class called Parse XML. Specifications Syntactically correct XML A properly formed XML document is one where: Every token is either a tag or a word. The syntax of a tag is described in a previous assignment. Anything that is not a tag is a word. Every opening tag is followed at some point by a closing tag with the same tag name. Opening and closing tags are properly nested. For example, assume the following tags appear in the document: chapter

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!