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:
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:
xmlerror2.txt:
xmlerror3.txt:
xmltest1.txt:
xmltest2.txt:
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started