Question

In: Computer Science

While HTML is a markup language with a fixed set of tags that allows users to...

While HTML is a markup language with a fixed set of tags that allows users to specify the appearance of a document, XML (extensible markup language) allows the user to create new tags to provide a document structure appropriate to the task at hand. A document has three aspects: structure, appearance, and content. In the case of XML, theseaspectsareseparated,withdifferent meansemployedfordefiningthestructure, the appearance, and the content. Usually, the document type definition (DTD) file describes the structure of a document; the appearance is specified by an extensible style sheet (XSL); and the content is provided in the XML document. In the case of XML, the Web server does not send an HTML document but rather sends the XML and the XSL documents, and the client must have XML/XSL processors to display the document. In this assignment, you will learn to create a simple XML documentfirst.Youwillthenlearnto specifythestructureoftheXMLfileandformat your XML document using XSL. A. Creating a Simple XML Document (20 points) As a programmer, you are asked to provide a cafe comparison table for web surfers. In ordertodo that,youfirstneedtocreatealltherelatedcafeinformationusingasimple XML document. Open Notepad or any XML Editor on your computer system, create a file and name it CAFE.xml. First define the XML version by writing “ ” in the first line. The next line, “”, refers to the type of style sheet used and the name of the file. The structure of the XML file is simple. At the root is a structure called CAFES. This structure at the next level has a repeated number of child structures called CAFE.Inturn, thestructureCAFEhasoneattribute,CAFE_TYPE,andithas five elements:  CAFE_NAME  FOOD_QUALITY ENVIRON  COST_RATING COMMENTS The code for the entire file CAFE.xml is in the following image: B. Formatting XML Using XSL (20 points) 6. Now consider the XSL file, CAFE.xsl. The file accomplishes several tasks: (1) the XSL filegeneratestheHTMLcodethateventuallyrunsonthebrowser.The XSL file has to create the necessary HTML tags for that purpose. (2) As part of the above, the XSL code creates a table that has the tabular headings in the first row.(3)Loopingconstructs allowedinXSLareusedtoreadindividualelements of CAFE in the associated XML file and then to output the values in the HTML table. Preamble. The file begins with a preamble that defines the location of the XSL specification by the following line: “”. If it is not working, please try this line: “”. And, remember to add “” as the first line. Template Match. The line: instructs the system to match the XSL template right from the root stage of the structure described in the XML file (i.e., the entire structure of CAFES/CAFE is to be processed as per the XSL file). 9. The HTML tags for the file and for defining the table are achieved by the following code: 10. The header row of the table is defined by the code: 11. The XML file defines the overall structure of CAFES, which consists of multiple repeated child structure elements CAFE. The file CAFE.xml has five CAFE child structures. XSL provides the necessary language constructs to extractthesevaluesand putstheminanHTMLformatwiththeappropriate formatting.The“for-eachselect” loopingconstructofXSLisusedtoloop through the CAFES structure, and the XSL construct “value-of select” is used to fetch the values of the individual CAFE elements, such as CAFE_NAME and FOOD_QUALITY, and includes them in the table. This “for-each-select” looping constructofXSLactsthesameasaWHILEloopinacomputer program.The looping construct, such as a WHILE loop, is fixed in length, irrespective of how many CAFE child structures are involved. The looping code is as follows: Now you should have keyed in the necessary code to display the comparison table. The last thing is to close up all the open tags: Please remember that XML code is case sensitive. An upper cased letter is never the same as the lower cased same letter. And the select element name should be exactly the same as mentioned in your xml document. Please check both documents carefully. 14. Double-click on your xml document, and you shall see the following image on your computer screen:

Solutions

Expert Solution

XML CODE:

<?xml version="1.0">
<?xml-stylesheet type="text/xsl" href="CAFE.xsl"?>
<CAFES>
   <CAFE CAFE_TYPE="Primarily Take-Out">
       <CAFE_NAME>New Mexico</CAFE_NAME>
       <FOOD_QUALITY>Average</FOOD_QUALITY>
       <ENVIRON>Great!</ENVIRON>
       <COST_RATING>$3.50 per meal</COST_RATING>
       <COMMENTS>Should order well in time.</COMMENTS>
   </CAFE>
   <CAFE CAFE_TYPE="Brunch">
       <CAFE_NAME>Moscow</CAFE_NAME>
       <FOOD_QUALITY>Outstanding</FOOD_QUALITY>
       <ENVIRON>Average</ENVIRON>
       <COST_RATING>$8 per person</COST_RATING>
       <COMMENTS>A good place for weekend brunch.</COMMENTS>
   </CAFE>
   <CAFE CAFE_TYPE="Formal Dinner">
       <CAFE_NAME>Spring in Paris</CAFE_NAME>
       <FOOD_QUALITY>Excellent</FOOD_QUALITY>
       <ENVIRON>Fantastic</ENVIRON>
       <COST_RATING>$19 per plate</COST_RATING>
       <COMMENTS>Got to be rich to go there.</COMMENTS>
   </CAFE>
   <CAFE CAFE_TYPE="Asian Grill">
       <CAFE_NAME>Big Saigon</CAFE_NAME>
       <FOOD_QUALITY>Good</FOOD_QUALITY>
       <ENVIRON>OK</ENVIRON>
       <COST_RATING>$7 per plate</COST_RATING>
       <COMMENTS>Good for Quick Lunch</COMMENTS>
   </CAFE>
   <CAFE CAFE_TYPE="Take-Out">
       <CAFE_NAME>Aby's Diner</CAFE_NAME>
       <FOOD_QUALITY>Fantastic</FOOD_QUALITY>
       <ENVIRON>Splendid</ENVIRON>
       <COST_RATING>$7 per plate</COST_RATING>
       <COMMENTS>Always eat out at Aby's Diner.</COMMENTS>
   </CAFE>
</CAFES>

Save it as CAFE.xml.

The file begins with a preamble that defines the location of the XSL specification by the following line: <xsl:stylesheet xmlns:xsl=“http://www.w3.org/TR/WD-xsl”>”. If it is not working, please try this line:
“<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">”.
And, remember to add “<?xml version=“1.0” ?>” as the first line.

Template Match. The line: <xsl:template match=“/”> instructs the system to match the XSL template right from the root stage of the structure described in the XML file (i.e.,the entire structure of CAFES/CAFE is to be processed as per the XSL file).

The HTML tags for the file and for defining the table are achieved by the following code:

<?xml version="1.0">
<!-- XML Declaration by June Lu-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" version"1.1">

<!--Declaration that the document is a stylesheet -->

<xsl:template match"/">
<!-- Apply template from the root node -->

<HTML>
   <BODY>
       <P><B>This is an XML Document on View! </B></P>
       <P><EM>It uses XSL Sheet </EM></P>
       <P>These XML Docuements have been produced</P>
   </BODY>
</HTML>
  

The header row of the table is defined by the code:

<!-- Set up the first, that is, the header row -->

   <TR>
       <TD><B>Cafe Type</B></TD>
       <TD><B>Cafe Name</B></TD>
       <TD><B>Food</B></TD>
       <TD><B>Environment</B></TD>
       <TD><B>Meal Cost</B></TD>
       <TD><B>Comments</B></TD>
   </TR>


Related Solutions

Describe how the Hypertext Markup Language (HTML) and Extensible Markup Language (XML) would be utilized in...
Describe how the Hypertext Markup Language (HTML) and Extensible Markup Language (XML) would be utilized in relation to your e-business and the related user Web interfaces. Also indicate the relationship between XML and the Extensible Business Reporting Language (XBRL). How do you envision using XBRL in relation to your e-business? Finally, what role does XML play in the Semantic Web project discussed in this module?
Week 4 Assignment HTML – Creating a Simple Web Page “HTML or HyperText Markup Language as...
Week 4 Assignment HTML – Creating a Simple Web Page “HTML or HyperText Markup Language as it is formally known is the main markup language for creating web pages and other information that can be displayed in a webbrowser”. It was created by Tim Berners-Lee in 1989 as a user friendly way of sharing information on the Internet. http://en.wikipedia.org/wiki/HTML Assignment Instructions - Create a simple HTML Web Page that includes hyperlinks to three of your favorite websites. Use the online...
HTML mark-up text know the following  HTML tags: · <html> · <body> · <head> · <p> ·...
HTML mark-up text know the following  HTML tags: · <html> · <body> · <head> · <p> · <h1>, <h2>, <h3>, etc… · <a> · <img> · <br> · <hr> · <pre> · <i> · <b> · <em> · <sub> · <ins> · <strong> · <mark> · <cite> · <address> · <abbr> After you have reviewed these HTML tags and developed a sense of how they manipulate the presentation of the mark-up, write a sample page of HTML that briefly goes over...
this is done in HTML In footer, use HTML tags/style of your choice to explain steps...
this is done in HTML In footer, use HTML tags/style of your choice to explain steps you took to add css file and _Layout. Should include the following: Folder structure Short description of what layout does You should not include the content of css or how you defined your css
Topic: HTML Styling Elements - CSS3 Write some HTML code that includes three Semantic HTML tags....
Topic: HTML Styling Elements - CSS3 Write some HTML code that includes three Semantic HTML tags. Describe the semantic meaning of each one you choose.
The following HTML tags will be used to complete assignment below: · <table> · <tr> ·...
The following HTML tags will be used to complete assignment below: · <table> · <tr> · <td> Explore CSS and the various ways attributes can be manipulated to change the width and style of table borders in addition to the physical dimensions of the space that resides within each cell. Demonstrate mastery of the concepts of "absolute" vs. "relative" sizes when specifying table dimensions and create a traditional 12x12 multiplication table and a different HTML table on the same markup...
Your HTML document should contain the following elements/features: HTML tags: An <input> tag labeled "Timer Duration"...
Your HTML document should contain the following elements/features: HTML tags: An <input> tag labeled "Timer Duration" with the initial value 0 A <button> tag labeled "Start" Script: When the user presses the button (1b), a function will begin that does the following: Reads the value from the input field (1a) Removes the <input> and <button> tags (1a & 1b) Creates a new <p> tag, initialized to show the input value Starts a timer that ticks down to zero. For every...
1. Create a PHP page with standard HTML tags. Remember to save the file with the...
1. Create a PHP page with standard HTML tags. Remember to save the file with the .php extension. Inside the <body> tag, create a PHP section that will show the text "Hello World!" 2. For this exercise, echo the phrase "Twinkle, Twinkle little star." Create two variables, one for the word "Twinkle" and one for the word "star". Echo the statement tothe browser. 3. PHP includes all the standard arithmetic operators. For this PHP exercise, you will use them along...
Develop a one-page website using HTML tags and element to implement the following. THIS IS HEADING...
Develop a one-page website using HTML tags and element to implement the following. THIS IS HEADING 1 THIS IS HEADING 2 THIS IS HEADING 3 THIS IS HEADING 4 THIS IS HEADING 5 THIS IS HEADING 6 THIS IS A PARAGRAPH. THIS IS A PARAGRAPH. THIS IS A PARAGRAPH THIS IS ANOTHER PARAGRAPH. THIS IS ANOTHER PARAGRAPH. THIS IS ANOTHER PARAGRAPH THIS IS A LINE BREAK THIS IS A LINE BREAK THIS IS A LINE BREAK THIS IS AN ORDERED...
What is the percentage markup on a proposal as a percent if the fixed bid price...
What is the percentage markup on a proposal as a percent if the fixed bid price offered is 552,000 and the sum of direct cost is 480,000? The calendar day duration of a project is planned for 19 days based on a Monday through Friday work week. How many work days were available in this period if the start of the project was on the last Monday in July 2020? What is the forecasted total project cost if the reported...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT