Question: Work so far can be found at the very bottom. Cannot use and private(). Problem 2: XML XML, the Extensible Markup Language, is a ubiquitous

Work so far can be found at the very bottom. Cannot use and private().

Work so far can be found at the very bottom. Cannot useand private(). Problem 2: XML XML, the "Extensible Markup Language", is a

Problem 2: XML XML, the "Extensible Markup Language", is a ubiquitous format for exchanging data on the internet. It is also used extensively in modern office-productively software produced by Microsoft, Apple, and the open-source community. XML is fairly simple: it consists of content that is "marked up" with tags. Here are some simple examples of XML: I am XML! The above is just plain content with no tags. We can tag certain parts of the content with a pair of open and close tags to delimit the tagged region: I am XML! Here the content XML is tagged with the yell tag. The tags can nest, as in: I am XML! Here the content XML is again tagged with yell, but the X is also tagged with the italic tag. Tags can also carry attributes that associate data with a tag. For example, we may want to yell at a certain volume: I am XML! Here the yell tag carries a volume attribute with the value 30db. Moreover, you can add an arbitrary number of attributes to a tag, so we can specific both the volume and the duration of a yell: I am XML! If we step back and think about how to represent XML, we arrive at the following sketch: XML is either just plain content (no tags), or it is tagged XML, i.e. it is some tag, some list of attributes and values, and some XML. The following DrRacket data definition describes XML: ; ; An XML is one of : (make-plaintext String) ( make-untagged [Listof XML]) ( make-tagged Tag [Listof XML]) ; ; A Tag is a (make-tag String [Listof Att]) ; ; An Att is a (make-att String String) (define-struct plaintext (txt) ) (define-struct untagged (content) ) (define-struct tagged (tag content) ) (define-struct tag (name atts) ) (define-struct att (name value) )Define Java classes that represent XML as defined above. Translate all of the above examples using your representation. Name your examples class ExamplesXML. Name your examples ml 1, xm12, etc. Note that the Untagged constructor should only be called when absolutely necessary. Design a content Length method which computes the length (number of characters) of the content in an XML document. The tags and attributes should not contribute to the length. Design a hasTag method that determines if a piece of XML contains a Tag with the given name. Design a hasAttribute method that determines if a piece of XML contains an attribute with the given name. Design a renderAsStrin g method that converts XML to a String without tags and attributes. HINT: We asked you to implement renderAsString but you might want to also implement renderAsXmlStrin g which includes the tag names and attribute names. That way you can check if your data matches our examples! This is more coding work that will save you debugging work

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!