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

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...
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
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...
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...
Please use markup language HTML5 please. For this homework assignment, you will create a Web site...
Please use markup language HTML5 please. For this homework assignment, you will create a Web site made up of three different pages and links between those pages Index.htm The Web pages in a site should have a similar look-and-feel. For this site, you should create a simple menu as follows: Create a horizontal line across the very top and bottom of the page. Also on the home (Index) page, create links to the other two pages. The links should appear...
why are owners considered external users of financial information while board of directors are internal users.
why are owners considered external users of financial information while board of directors are internal users.
Using a combination of HTML/PHP, implement a web page where the users can upload a text...
Using a combination of HTML/PHP, implement a web page where the users can upload a text file, exclusively in .txt format, which contains a string of 400 numbers, such as: 71636269561882670428 85861560789112949495 65727333001053367881 52584907711670556013 53697817977846174064 83972241375657056057 82166370484403199890 96983520312774506326 12540698747158523863 66896648950445244523 05886116467109405077 16427171479924442928 17866458359124566529 24219022671055626321 07198403850962455444 84580156166097919133 62229893423380308135 73167176531330624919 30358907296290491560 70172427121883998797 Your code should contain a PHP function that, accepting the string of 400 numbers in input, is able to find the greatest product of four adjacent numbers in all the...
You are designing a web page that allows users to create an event listing. The event...
You are designing a web page that allows users to create an event listing. The event listing should include the date, time, location, title, phone, email, coordinator, and description of the event. The location should be between 10 and 100 characters long. The title should be between 1 and 50 characters long. The description should be between 10 and 200 characters long. Phone number consists of numbers and dashes. Email has to have an @ symbol. All data elements should...
Create a web page using PHP that allows the users to create an account (a username...
Create a web page using PHP that allows the users to create an account (a username and a password). There should be a login page that allows users to create an account by entering their preferred username and password. The same page should also let users login if they already have an account. If a user is logged in successfully , they should be able to enter a comment and also read the comments entered by others previously.
Please provide HTML code for the following: - Create a page that lists a set of...
Please provide HTML code for the following: - Create a page that lists a set of audio files and shows their duration - Create a page that lists a set of video files and plays a different video when you click on the play icon
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT