Question: Hello. tutors. I need to make a file reader that reads in the xml files and reports any errors. And we also need to use
Hello. tutors. I need to make a file reader that reads in the xml files and reports any errors. And we also need to use the stack and queue.
Can you help me out to make the code? I will add all the information that we need to make it below.
This is the instruction.

And this is my stack and queue class.
package implementation;
import java.util.EmptyStackException;
import java.util.NoSuchElementException;
import utilities.Iterator;
import utilities.StackADT;
public class MyStack
private static final long serialVersionUID = 1L;
private int size=0;
private MyArrayList
public MyStack(){
arrayList = new MyArrayList
}
@Override
public void push(Object toAdd) throws NullPointerException {
if(toAdd==null) {
throw new NullPointerException();
}
arrayList.add(0,toAdd);
size++;
}
@Override
public E pop() throws EmptyStackException {
if(size==0) {
throw new EmptyStackException();
}
E removed = arrayList.remove(0);
size--;
return removed;
}
@Override
public E peek() throws EmptyStackException {
if(size==0) {
throw new EmptyStackException();
}
return arrayList.get(0);
}
@Override
public void clear() {
arrayList.clear();
size=0;
}
@Override
public boolean isEmpty() {
return size==0;
}
@Override
public Object[] toArray() {
return arrayList.toArray();
}
@Override
public E[] toArray(E[] holder) throws NullPointerException {
return arrayList.toArray(holder);
}
@Override
public boolean contains(Object toFind) throws NullPointerException {
return arrayList.contains(toFind);
}
@Override
public int search(Object toFind) {
if(!arrayList.contains(toFind)) {
return -1;
}
for(int i=0;i
return i;
}
}
return -1;
}
@Override
public boolean equals(StackADT
if(this.size()!=that.size()) {
return false;
}
Iterator
Iterator
while(thisIterator.hasNext()) {
E thisElement=thisIterator.next();
E thatElement=thatIterator.next();
if(!thisElement.equals(thatElement)) {
return false;
}
}
return true;
}
@Override
public int size() {
return size;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Iterator
return new MyStackIterator();
}
public void printAll() {
Object[] array = toArray();
System.out.print("[");
for(int i=0;i
System.out.print(array[i]);
continue;
}
System.out.print(array[i]+", ");
}
System.out.print("]");
}
@SuppressWarnings("hiding")
public class MyStackIterator
private int cursor;
public MyStackIterator(){
this.cursor=0;
}
@Override
public boolean hasNext() {
return cursor!=size;
}
@Override
public E next() throws NoSuchElementException {
if(cursor>=size) {
throw new NoSuchElementException();
}
@SuppressWarnings("unchecked")
E element = (E) arrayList.get(cursor);
cursor++;
return element;
}
}
}
package implementation;
import java.util.NoSuchElementException;
import exceptions.EmptyQueueException;
import exceptions.FullQueueException;
import utilities.Iterator;
import utilities.QueueADT;
public class MyQueue
/**
*
*/
private static final long serialVersionUID = 1L;
private int size;
private boolean hasMaxSize=false;
private int maxSize;
MyDLL
public MyQueue() {
dll = new MyDLL
size=0;
}
public MyQueue(int maxSize) {
this.maxSize=maxSize;
hasMaxSize=true;
dll = new MyDLL
size=0;
}
@Override
public void enqueue(E toAdd) throws NullPointerException {
if(toAdd==null) {
throw new NullPointerException();
}
dll.add(toAdd);
size++;
}
@Override
public E dequeue() throws EmptyQueueException {
if(size==0) {
throw new EmptyQueueException();
}
E removed = dll.remove(0);
size--;
return removed;
}
@Override
public E peek() throws EmptyQueueException {
if(size==0) {
throw new EmptyQueueException();
}
return dll.get(0);
}
@Override
public void dequeueAll() {
size=0;
dll.clear();
}
@Override
public boolean isEmpty() {
return size==0;
}
@Override
public boolean equals(QueueADT
if(this.size()!=that.size()) {
return false;
}
Iterator
Iterator
while(thisIterator.hasNext()) {
E thisElement=thisIterator.next();
E thatElement=thatIterator.next();
if(!thisElement.equals(thatElement)) {
return false;
}
}
return true;
}
@Override
public Object[] toArray() {
return dll.toArray();
}
@Override
public E[] toArray(E[] holder) throws NullPointerException {
return dll.toArray(holder);
}
@Override
public boolean isFull() {
if(hasMaxSize) {
return size>=maxSize;
}
return false;
}
@Override
public int size() {
return size;
}
@Override
public Iterator
return new MyQueueIterator
}
public void printAll() {
Object[] array = toArray();
System.out.print("[");
for(int i=0;i
System.out.print(array[i]);
continue;
}
System.out.print(array[i]+", ");
}
System.out.print("]");
}
@SuppressWarnings("hiding")
public class MyQueueIterator
private int cursor;
public MyQueueIterator(){
cursor=0;
}
@Override
public boolean hasNext() {
return cursor!=size;
}
@Override
public E next() throws NoSuchElementException {
if(cursor>=size) {
throw new NoSuchElementException();
}
@SuppressWarnings("unchecked")
E element = (E) dll.get(cursor);
cursor++;
return element;
}
}
}
And this is my sample xml files.
Sample1.xml
Sample2. xml
This is for the Spanish Language that is long ago lost.
This is for the tranditionally minded Asian person
This is my instructors suggestion.

Write an XML parser that will accomplish the following: a. Read supplied XML documents. b. Parse for errors in the XML construction. c. At completion of parsing, print all lines that are not properly constructed in the order in which the errors occur. NO EXTRA files may be created. An XML document is syntactically correct if: i. An opening tag has the format , a closing tag has the format . ii. III. iv. XML tags may contain attributes in the format of name="value" pairs, these attributes are to be ignored for this assignment. For every closing tag, there is an earlier matching opening tag. An exception to the above is a self-closing tag, a self-closing tag has the format . Self- closing tags require no closing tag. The sub phrase between a pair of matching tags is itself well-constructed. All tags are case-sensitive. V. vi. vii. Every XML document must have one and only one root tag. VIII. Tags that are in the following format are processing instructions and can be ignored for this assignment. ix. If nested, the tag pairs cannot intercross. For example, the following not syntactically correct: (ill-constructed) This is to be bold and italic
Step by Step Solution
There are 3 Steps involved in it
python import re def parsexmlxmlstring lines xmlstringsplit stack errors for i line in enumerat... View full answer
Get step-by-step solutions from verified subject matter experts
