Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions

Question

Understand why customers are loyal to a particular service firm.

Answered: 1 week ago