CS106 - XML Nesting Validation
CS106 - XML Nesting Validation
VALIDATOR
PROGRAM
DESCRIPTION
Create a program that
validates the nesting of
elements in an XML
document. The nesting
rule simply states that
while elements may be
nested, they cannot
overlap. This is one of the
rules that must be
satisfied for an XML
document to be
considered well-formed.
For more information on
XML documents, see this
page and this page.
TASKS &
REQUIREMENTS
1. NOTE: Naming is critical in the tasks and requirements described below. If the names
don't match those described below exactly, your project will not compile and can't be
graded.
5. BasicStringStack class:
1. Download the StringStack.java interface and put it in the xmlvalidator package.
Read the comments above each method to understand what they are supposed to
do.
2. Create a new class named BasicStringStack in the xmlvalidator package. In the
class creation wizard, click the Add (interface) button, and search for
StringStack. Check the "Inherited abstract methods" box. Click Finish. Eclipse
will create the class and automatically add method stubs that meet the
StringStack interface.
3. You do not modify the StringStack interface. You add your code in the
BasicStringStack class.
4. You must write your own stack code - i.e. you can't use java.util.Stack or
any other existing implementation. You are welcome to use the guidebook's code as
a guide if you like.
6. BasicXmlValidator class:
1. Download the XmlValidator.java interface and put it in the xmlvalidator
package. Read the comments above each method to understand what they are
supposed to do.
2. Create a new class named BasicXmlValidator in the xmlvalidator package.
In the class creation wizard, click the Add (interface) button, and search for
XmlValidator. Check the "Inherited abstract methods" box. Click Finish.
Eclipse will create the class and automatically add method stubs that meet the
XmlValidator interface.
3. You do not modify the XmlValidator interface. You add your code in the
BasicXmlValidator class.
7. Validation notes:
1. Ignore any tag that doesn't start with '/' or a letter character. This includes xml
version/encoding elements like <?xml version="1.0" encoding="UTF-8"?>,
and comments like <!-- diblah -->.
2. Ignore self-closing tags like <sometag />.
3. Ignore comments like <!-- This is a comment -->.
4. Line numbers start at 1. '\n' marks the end of a line.
5. You can assume that the XML document won't have any CDATA sections.
6. Note that XML start tags can span multiple lines. E.g. :
<sometag
attr1="blah"
attr2="diblah">
8. Add the unit testing classes. These classes will be used to test the code that you write.
1. Create a new package in the src folder called sbccunittest. To be clear:
sbccunittest should be a child of the src folder, not of the xmlvalidator package.
2. Download XmlValidatorTester.java into sbccunittest.
12. There is no user interface requirement (i.e. no Main class) for this assignment.
SCORING
2 pts - testPush
3 pts - testPop
5 pts - testExercise
10 pts - testValidFile
5 pts - testBigValidFile
5 pts - testOrphanClosingTag
10 pts - testUnclosedTag
10 pts - testUnclosedTagAtEnd
5 pts - testPmd