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

Write a simple XML Schema file to define an XML document structure for simplified technical reports...
Write a simple XML Schema file to define an XML document structure for simplified technical reports (it must support tags for report title, chapter, two levels of sections, and item lists; more features for extra credits); write a sample XML document for technical report based on your Schema specification (the document should make reference to your external Schema file); validate your XML document against your Schema specification with my utility “SaxParse” to remove any bugs. Write a simple XSL stylesheet...
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
Project Part 4: Part Four: Complete the addCruise() Method 1. In the Driver.java file, see below...
Project Part 4: Part Four: Complete the addCruise() Method 1. In the Driver.java file, see below for where you will add code to finish the addCruise() method. // Adda New Cruise public static void addCruise() { // complete this method } 2. Next, review the required functionality of the “Add Cruise” menu option below. Menu Option Validation Check(s) Functionality Add Cruise - Ensures cruise does not already exist in our system - Ensures all class variables are populated Adds cruise...
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++
Write a C++ programm which reads an input file named 'input.txt' content of input.txt are not...
Write a C++ programm which reads an input file named 'input.txt' content of input.txt are not known to you copies content of input file into an output file named 'output.txt' contents of output.txt should be exactly the same as contents of input.txt the user should be given a choice to select input and output file in any folder remember to check that input file opened successfully Please add comments next to the code, so I can learn from the solution....
Create a new project called Lab05b. Keep the main file named main. Write a function readAndPrint,...
Create a new project called Lab05b. Keep the main file named main. Write a function readAndPrint, and power with parameters noted below in the Functions.h file. //Your Last Name #ifndef FUNCTIONS_H #define FUNCTIONS_H #include <fstream> #include <iostream> #include <string> using namespace std; /*reads from a file and prints every item to the screen*/ // file contains sets of //int //string //Don't forget to use infile.ignore() between << and getline //ifstream must be passed by reference void readAndPrint(ifstream &infile); //uses a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT