Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Lab Assignment: Data Structures in Java

In this lab you will you will write a program to validate html files.

In html, tags are element names enclosed in angle brackets <>. Most tags have start and end tags which 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, thename of the array is a reference

.

Start tags can contain attributes which provide additional information about the element, such as

Some tags do not surround any content. These "empty elements" have start tags but no end tags.

Restrictions for This 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:

• tags are case insensitive

• the following tags are empty, and so have no corresponding close tag: , ,
, , , ,


, ,, , , , , , ,

• all other tags must have a close tag

• tags must be nested correctly, so

. . .

is valid but

. . .

is not.

Input

The input is an html file which may or may not follow the restrictions described above.

Output

• each time a pair of tags is matched, print a message such as: "matched:

and

"
• each time a tag with no end tag is processed, print a message such as "no match needed:
"
• each time a start tag has no matching end tag, print a message such as: "missing end tag:
  • "
    • each time there is no start tag to match an end tag, print a message such as "missing start tag:
    • if there are no errors in the file, print a message saying that the file is valid; if there are any errors in the file, print a message saying that the file is invalid

    Requirements

    1. Prompt for the name of the file to be validated. Create a Scanner for the file and pass it to your validator.

    2. Your validator should use a stack to check for correct nesting of tags. The algorithm is similar to the algorithm for checking for balanced parentheses in our textbook. Open tags are pushed onto the stack. Each close tag is compared with the top of the stack to check for a match.

    3. Don't forget that some tags have no close tag.

    4. Create class for tags. This class should not have set or get methods. The Tag class should contain the list of tags with no end tag and a method to test whether a tag has no end tag. Your tag class should also have a method to test whether a pair of tags are matching start and end tags. You will probably need some additional methods in the Tag class.

    5. You need to extract the tags from the input file. Attributes are not stacked. My advice is to write your own "split" method that will take a line of the input file and return an array or ArrayList of the tags (modified to remove attributes) in a line of input. A good place for this method is to make it a static method in the Tag class.

  • Computer Engineering, Engineering

    • Category:- Computer Engineering
    • Reference No.:- M92717829

    Have any Question?


    Related Questions in Computer Engineering

    Analyze the time complexity of the following ternary search

    Analyze the time complexity of the following ternary search algorithm: identify two points that subdivide a sorted array into three parts. If the given number is equal to one of these two points, we are done. Otherwise, ...

    You are required to design a circuit that takes as input a

    You are required to design a circuit that takes as input a serial bit and outputs a '1' whenever there are three successive '1's, i.e., whenever the sequences 111 or 000 occur. Overlaps must be considered Also, assume th ...

    Let x denote the body temperature measured in degrees

    Let x denote the body temperature (measured in degrees Fahrenheit) of a human being. Suppose that across all humans, x follows some unknown distribution with mean u and standard deviation o. You want to know u. You colle ...

    Suppose that a data warehouse consists of the four

    Suppose that a data warehouse consists of the four dimensions date, spectator, location, and game, and the two measures count and charge, where charge is the fare that a spectator pays when watching a game on a given dat ...

    Tell us about the starbucks corp what it does and makes

    Tell us about the Starbucks Corp. what it does, and makes; publically traded or privately owned; how big, etc. 'what' is; it is exposition. Although who is the founders and history of the company; and its sense of social ...

    Calculate the present worth of all costs for a newly

    Calculate the present worth of all costs for a newly acquired machine with an initial cost of $30,000, no trade-in value, a life of 15 years, and an annual operating cost of $13,000 for the first 4 years, increasing by 1 ...

    I suppose alice wants to send a long message m to bob if

    (i) Suppose Alice wants to send a long message m to Bob. If Alice and Bob already share a secret key k, and they use HMAC to protect the integrity of the message m, what should the message format be (or what components s ...

    Explain the difference between penetration tests and

    Explain the difference between penetration tests and security tests. Emphasize that this book will explain things from a security testing perspective.

    Assignmenta in the slides and textbook one of the examples

    Assignment (a) In the slides and textbook, one of the examples features a class for counting up. An interface which defines this functionality is given below: public interface IncrementCounter { //Increments the counter ...

    Suppose a lawn care company can install either mulch or

    Suppose a lawn care company can install either mulch or pine straw for flowerbeds of their residential customers. A workday typically runs 12.5 hours (or 750 minutes) and the company can install mulch in 30 minutes and p ...

    • 4,153,160 Questions Asked
    • 13,132 Experts
    • 2,558,936 Questions Answered

    Ask Experts for help!!

    Looking for Assignment Help?

    Start excelling in your Courses, Get help with Assignment

    Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

    Ask Now Help with Problems, Get a Best Answer

    Why might a bank avoid the use of interest rate swaps even

    Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

    Describe the difference between zero coupon bonds and

    Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

    Compute the present value of an annuity of 880 per year

    Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

    Compute the present value of an 1150 payment made in ten

    Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

    Compute the present value of an annuity of 699 per year

    Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As