Question: In this lab, you will write a program to validate HTML files using JAVA : You can use StackInterface and ArrayBoundedStack class for this program.
In this lab, you will write a program to validate HTML files using JAVA:
You can use StackInterface and ArrayBoundedStack class for this program. You will read from HTML file and output the complete and missing tags. For instance, a tag begins and ends like this: ...... In HTML, tags are element names enclosed in angle brackets . Most tags have start and end tags that enclose some document element(s) and possibly other tags. End tags have the same name as the corresponding start tag, preceded by a '/':
Arrays are objects, which means that when we declare an array, the name of the array is a reference
Start tags can contain attributes which provide additional information about the element, such as or Restrictions for the Validator: there are multiple versions of html with different rules. We are going to simplify a bit for the purposes of this lab. We are going to use the following rules for valid html: . . . . . . REQUIREMENTS: The output could be like this: and Classes you can use: public class ArrayBoundedStack public ArrayBoundedStack() { elements = (T[]) new Object[DEFCAP]; } public ArrayBoundedStack(int maxSize) { elements = (T[]) new Object[maxSize]; } public void push(T element) { if (isFull()) throw new StackOverflowException("Push attempted on a full stack."); else { topIndex++; elements[topIndex] = element; } } public void pop() { if (isEmpty()) throw new StackUnderflowException("Pop attempted on an empty stack."); else { elements[topIndex] = null; topIndex--; } } public T top() { T topOfStack = null; if (isEmpty()) throw new StackUnderflowException("Top attempted on an empty stack."); else topOfStack = elements[topIndex]; return topOfStack; } public boolean isEmpty() { return (topIndex == -1); } public boolean isFull() { return (topIndex == (elements.length - 1)); } } public interface StackInterface void pop() throws StackUnderflowException; T top() throws StackUnderflowException; boolean isEmpty(); boolean isFull(); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
