Question

In: Computer Science

Internet Programming Project #4:  XML, Schema and XSLT 1.   Write a complete XML file named textbooks.xml, in which...

Internet Programming

Project #4:  XML, Schema and XSLT

1.   Write a complete XML file named textbooks.xml, in which you describe at least a partial list of the textbooks you are using this semester. You should include at least two distinct textbooks. If you are using only one text this semester, expand your list to cover the current academic year.

Your description of each book must include the title, author(s), publisher, year of publication, and the ISBN. For each author, specify the first and last name as distinct values. Include both a name and website for the publisher. Optionally, try also to include any book-specific website (especially if it is distinct from the main publisher site, and if its URL is not ridiculously long). Finally, specify the edition and cover type (paperback or hardcover) of each book you are using. Make sure your final XML document is well-formed.

2.  Write an XML Schema that can be used to validate textbooks.xml and name it textbook.xsd . Finally, remember to modify your new XML document so that it references your schema.

3. Develop an XSL Stylesheet for easy viewing of your textbook list and name it textbook.xsl

Solutions

Expert Solution

PLEASE RATE MY ANSWER I SUFFERING FROM SCORE ANY DOUBTS ASK ME

Textbooks.xml :

<?xml version="1.0" encoding="utf-8"?>
<textbooks>
<textbook>
    <title>Introduction to Algorithms</title>
    <authors>
      <author>
        <firstName>Thomas H.</firstName>
        <lastName>Cormen</lastName>
      </author>
      <author>
        <firstName>Charles E.</firstName>
        <lastName>Leiserson</lastName>
      </author>
    </authors>
    <publisher>
      <name>PHI Learning Pvt. Ltd. (Originally MIT Press)</name>
      <website>www.mitpress.com</website>
    </publisher>
    <Year-of-Publication>2010</Year-of-Publication>
    <ISBN>8120340078</ISBN>
    <book-specific-website></book-specific-website>
    <edition>3</edition>
    <cover-type>Paperback</cover-type>
</textbook>
<textbook>
    <title>Operating System Concepts</title>
    <authors>
      <author>
        <firstName>Abraham</firstName>
        <lastName>Silberschatz</lastName>
      </author>
    </authors>
    <publisher>
      <name>Wiley India</name>
      <website>www.wileyindia.com</website>
    </publisher>
    <Year-of-Publication>2005</Year-of-Publication>
    <ISBN>8126554274</ISBN>
    <book-specific-website>fgdfg</book-specific-website>
    <edition>9</edition>
    <cover-type>Hardcover</cover-type>
</textbook>
</textbooks>


-----------------------------------------------------------------------------------------------------------------------------------------------------------

textbook.xsd :

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="textbooks">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" name="textbook">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="title" type="xs:string" />
              <xs:element name="authors">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element maxOccurs="unbounded" name="author">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="firstName" type="xs:string" />
                          <xs:element name="lastName" type="xs:string" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="publisher">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="name" type="xs:string" />
                    <xs:element name="website" type="xs:string" />
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="Year-of-Publication" type="xs:unsignedShort" />
              <xs:element name="ISBN" type="xs:unsignedLong" />
              <xs:element name="book-specific-website" type="xs:string" />
              <xs:element name="edition" type="xs:unsignedByte" />
              <xs:element name="cover-type" type="xs:string" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
</xs:element>
</xs:schema>

-----------------------------------------------------------------------------------------------------

textbook.xsl :

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
    <tr bgcolor="#9acd32">
      <th style="text-align:left">Title</th>
      <th style="text-align:left">Author First name</th>
<th style="text-align:left">Author Last name</th>
<th style="text-align:left">Publisher name</th>
<th style="text-align:left">Publisher website</th>
<th style="text-align:left">Year of Publication</th>
<th style="text-align:left">ISBN</th>
<th style="text-align:left">book website</th>
<th style="text-align:left">edition</th>
<th style="text-align:left">cover type</th>

    </tr>
<xsl:for-each select="catalog/cd">
    <tr>
      <td><xsl:value-of select="catalog/cd/title"/></td>
      <td><xsl:value-of select="catalog/cd/authors/firstName"/></td>
<td><xsl:value-of select="catalog/cd/authors/lastName"/></td>
<td><xsl:value-of select="catalog/cd/publisher/name"/></td>
<td><xsl:value-of select="catalog/cd/publisher/website"/></td>
<td><xsl:value-of select="catalog/cd/Year-of-Publication"/></td>
<td><xsl:value-of select="catalog/cd/ISBN"/></td>
<td><xsl:value-of select="catalog/cd/book-specific-website"/></td>
<td><xsl:value-of select="catalog/cd/edition"/></td>
<td><xsl:value-of select="catalog/cd/cover-type"/></td>
    </tr>
    </xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>


Related Solutions

3.1. Create an XML schema to validate the following XML file. <?xml version="1.0" encoding="utf-8"?> <root> <whats>Everything</whats>...
3.1. Create an XML schema to validate the following XML file. <?xml version="1.0" encoding="utf-8"?> <root> <whats>Everything</whats> <up>Is</up> <doc>Fine</doc> </root> Schema starter: <xsd:schema xmlns:xsd=""> <xsd:element name="root" type="rootType" /> <xsd:complexType name="rootType">     <xsd:sequence>       <xsd:element name="" type="" minOccurs="1" />       <xsd:element name="” type="" minOccurs="1" />       <xsd:element name="" type="" minOccurs="1" />     </xsd:sequence> </xsd:complexType> </xsd:schema> 3.2. Use your schema to validate the XML file.                     3.2.1. You can use Visual Studio or online utilities to apply the schema to the XML file....
XML 1) Create an XML schema for a catalog of cars, where each car has the...
XML 1) Create an XML schema for a catalog of cars, where each car has the child elements make, model, year, color, engine, number_of_doors, transmission_type, and accessories. The engine element has the child elements number_of_cylinders and fuel_system (carbureted or fuel injected). The accessories element has the attributes radio, air_conditioning, power_windows, power_steering, and power_brakes, each of which is required and has the possible values yes and no. 2) Create an XML document with at least three instances of the car element...
Write a complete Java program that does the following: Open an input file named data.txt that...
Write a complete Java program that does the following: Open an input file named data.txt that consists of a series of unknown number of integers. If data.txt does not exist, give an appropriate error message and terminate the program. Define a constant MAX of value 100 and create an array of size MAX to hold items from the input file. Make sure your program will not generate ArrayIndexOutOfBounds exception. Open an output file named result.txt and write the array elements...
Write a C++ pgm which 1.reads an input file named 'input.txt' 2.content of input.txt are not...
Write a C++ pgm which 1.reads an input file named 'input.txt' 2.content of input.txt are not known to you 3.copies content of input file into an output file named 'output.txt' 4.contents of output.txt should be exactly the same as contents of input.txt 5.the user should be given a choice to select input and output file in any folder 6.remember to check that input file opened successfully
Write a program that creates an output file named rand_nums.txt. Open the file and write 100...
Write a program that creates an output file named rand_nums.txt. Open the file and write 100 random integers between -50 and +50 (inclusive) to the file. Be sure to handle any file IO exceptions. Remember to close the file. Write a program that opens rand_nums.txt for input. Create two output files pos.txt and neg.txt. Read through the input file, one line at a time, converting each line into an integer (no exception handling, yet). If the number is positive, write...
Write scores of 20 students on a quiz to a file. The file should be named...
Write scores of 20 students on a quiz to a file. The file should be named scores.txt. The scores should be random numbers between 0-10. Next, read the scores from scores.txt and double them and print the scores to screen. c++
* Python * * Python Programming * Part 1: Product Class Write a class named Product...
* Python * * Python Programming * Part 1: Product Class Write a class named Product that holds data about an item in a retail store.   The class should store the following data in attributes: product id, item description, units in inventory, and price. Write the __init__ method to require all four attributes. Also write a __str__ method for debugging output.    Once you have written the class, write a main() function that creates three Product objects and stores the following...
1. Create one XML data file and one DTD file for the entire data set (using...
1. Create one XML data file and one DTD file for the entire data set (using a subset of SQL assignment – see below). [Use of ID and IDREF are not required.] 2. Write and execute XML statements for the following two queries: Q1. Find the name of an employee who lives in Lincoln and works in Omaha. Q2. Find salaries of employees who live in the same cities as the companies for which they work. [You can replace one...
Write a program named FinalExamProgram2 that reads numbers from a file (which you will create using...
Write a program named FinalExamProgram2 that reads numbers from a file (which you will create using Notepad) into a one-dimensional array and then analyzes the numbers as described below. Your program must use loops to read the numbers into the array and to analyze the contents of the array. The program’s main function should do the following:  Read eight floating-point numbers from the file named numbers.txt into a onedimensional array, displaying each number on the screen.  Pass the...
Using the Prelude to Programming book, complete Programming Challenge 2 on page 463. Save your file...
Using the Prelude to Programming book, complete Programming Challenge 2 on page 463. Save your file as LASTNAME_FIRSTNAME_M07HW2. (worth 15 points) Create a program that allows the user to input a list of first names into one array and last names into a parallel array. Input should be terminated when the user enters a sentinel character. The output should be a list of email addresses where the address is of the following form: [email protected]. please help!!!!
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT