Question

In: Computer Science

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 defined in the XML schema of previous exercise. Process this document by using the previous XML schema, and produce a display of the raw XML document. Create a CSS style sheet for the XML document and use it to override the default styles of the XML document.

Solutions

Expert Solution

1.

cars.xsd:

<?xml version="1.0" encoding="UTF-8" ?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="Cars">

<xs:complexType>

<xs:sequence>

<xs:element name="make" type="xs:string"/>

<xs:element name="model" type="xs:string"/>

<xs:element name="year" type="xs:string"/>

<xs:element name="color" type="xs:string"/>

<xs:element name="engine">

<xs:complexType>

<xs:sequence>

<xs:element name="number_of_cylinders" type="xs:string"/>

<xs:element name="fuel_system" type="xs:string"/>

</xs:sequence>

</xs:complexType>

</xs:element>

<xs:element name="number_of_doors" type="xs:string"/>

<xs:element name="transmission_type" type="xs:string"/>

<xs:element name="accessories">

<xs:complexType>

<xs:sequence>

<xs:element name="radio" type="xs:string"/>

<xs:element name="air_conditioning" type="xs:string"/>

<xs:element name="power_windows" type="xs:string"/>

<xs:element name="power_steering" type="xs:string"/>

<xs:element name="power_brakes" type="xs:string"/>

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:schema>

2.

cars.xml

<?xml version="1.0" encoding="UTF-8"?>

<!-- Link to css file -->

<?xml-stylesheet type = "text/css" href = "cars.css" ?>

<!--CREATE A CATALOG ROOT TAG-->

<catalog

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xsi:noNamespaceSchemaLocation="cars.xsd">

<h1>CARS CATALOG</h1>

<car>

<make> <h4> Make: </h4> Buggati </make>

<model> <h4> Model: </h4> Veyron </model>

<year> <h4> Year: </h4> 2016 </year>

<color> <h4> Color: </h4> Gray </color>

<engine>

    <cylinders> <h4> Cylinders: </h4> 16 </cylinders>

    <fuel_system> <h4> Fuel System: </h4> Fuel Injected </fuel_system>

</engine>

<number_of_doors> <h4> Doors: </h4> 2 </number_of_doors>

<transmission_type> <h4> Transmission: </h4> Automatic </transmission_type>

<accessories>

    <radio> <h4> Radio: </h4> Yes </radio>

    <air_conditioning> <h4> Air Conditioning: </h4> Yes </air_conditioning>

    <power_windows> <h4> Power Windows: </h4> Yes </power_windows>

    <power_steering> <h4> Power Steering: </h4> Yes </power_steering>

    <power_brakes> <h4> Power Brakes: </h4> Yes </power_brakes>

</accessories>

</car>

<car>

<make> <h4> Make: </h4> Lamborghini </make>

<model> <h4> Model: </h4> Aventador </model>

<year> <h4> Year: </h4> 2016 </year>

<color> <h4> Color: </h4> Orange </color>

<engine>

    <cylinders> <h4> Cylinders: </h4> 12 </cylinders>

    <fuel_system> <h4> Fuel System: </h4> Fuel Injected </fuel_system>

</engine>

<number_of_doors> <h4> Doors: </h4> 2 </number_of_doors>

<transmission_type> <h4> Transmission: </h4> Automatic </transmission_type>

<accessories>

    <radio> <h4> Radio: </h4> Yes </radio>

    <air_conditioning> <h4> Air Conditioning: </h4> Yes </air_conditioning>

    <power_windows> <h4> Power Windows: </h4> Yes </power_windows>

    <power_steering> <h4> Power Steering: </h4> Yes </power_steering>

    <power_brakes> <h4> Power Brakes: </h4> Yes </power_brakes>

</accessories>

</car>

<car>

<make> <h4> Make: </h4> Jaguar </make>

<model> <h4> Model: </h4> XJ </model>

<year> <h4> Year: </h4> 2016 </year>

<color> <h4> Color: </h4> Black </color>

<engine>

    <cylinders> <h4> Cylinders: </h4> 6 </cylinders>

    <fuel_system> <h4> Fuel System: </h4> Fuel Injected </fuel_system>

</engine>

<number_of_doors> <h4> Doors: </h4> 2 </number_of_doors>

<transmission_type> <h4> Transmission: </h4> Automatic </transmission_type>

<accessories>

    <radio> <h4> Radio: </h4> Yes </radio>

    <air_conditioning> <h4> Air Conditioning: </h4> Yes </air_conditioning>

    <power_windows> <h4> Power Windows: </h4> Yes </power_windows>

    <power_steering> <h4> Power Steering: </h4> Yes </power_steering>

    <power_brakes> <h4> Power Brakes: </h4> Yes </power_brakes>

</accessories>

</car>

</catalog>

cars.css

catalog {

     background-color: black;

}

h1 {

     text-align: center;

     color: red;

     margin-top: 30px;

     display: block;

     text-transform: uppercase;

     font-weight: 900;

     font-family: monospace;

     font-size: 38px;

}

car {

      padding: 15px;

      width: 250px;

      margin-left: auto;

      margin-right: auto;

      margin-top: 15px;

      margin-bottom: 15px;

      background-color: gray;

      border-radius: 25px;

      display: block;

}

h4 {

     font-weight: 900;

     font-family: monospace;

}

make, model, year, color, cylinders, fuel_system, number_of_doors, transmission_type {

     display: block;

     font-family: monospace;

     font-size: 12pt;

}

radio, air_conditioning, power_windows, power_steering, power_brakes {

     display: block;

     font-family: monospace;

     font-size: 12pt;

}



Related Solutions

Create a XSD Schema to validate and provide structure for the XML document below: <?xml version="1.0"...
Create a XSD Schema to validate and provide structure for the XML document below: <?xml version="1.0" encoding="UTF-8" ?> <forecast qTime="28/10/20 10:00 PM" qLocation="Singapore"> <weather yyyymmdd="20200430"> <year>2020</year>   <month>04</month> <date>30</date> <comment>Plenty of sunshine</comment> <code>sunny</code> <highest>32.6</highest> <lowest>28.4</lowest> </weather> <weather yyyymmdd="20200218"> <year>2020</year>   <month>02</month> <date>18</date> <comment>Plenty of sunshine</comment> <code>sunny</code> <highest>34.6</highest> <lowest>30.5</lowest> </weather> <weather yyyymmdd="20200710"> <year>2020</year>   <month>07</month> <date>10</date> <comment>Partly sunny</comment> <code>partlySunny</code> <highest>33.1</highest> <lowest>29.2</lowest> </weather> <weather yyyymmdd="20200616"> <year>2020</year>   <month>06</month> <date>16</date> <comment>Considerable clouds</comment> <code>cloudy</code> <highest>30.5</highest> <lowest>25.4</lowest> </weather> <weather yyyymmdd="20200612"> <year>2020</year>   <month>06</month> <date>12</date> <comment>Cloudy with a thunderstorm</comment> <code>thunderstorm</code> <highest>29.1</highest>...
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....
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...
Consider a market for used cars. Suppose that each car on the market is 1 of...
Consider a market for used cars. Suppose that each car on the market is 1 of seven possible levels of quality x={1000,2000,…,7000}. There is an equal amount of cars at each quality level. Each current owner (and potential seller) knows the quality (x) of the car that they have. (Note: We did not do a problem like this explicitly in class, but it is a very simplified version of the “A” insurance example from the notes.) a. Suppose that buyers...
Consider a market for used cars where each buyer wants to purchase exactly one used car...
Consider a market for used cars where each buyer wants to purchase exactly one used car if at all. In case he does not buy a car, his utility is zero. There are two kinds of used cars, good quality, called peaches, and bad quality, called lemons. Let there be 100 lemons with valuation 0 for both buyers and sellers, whereas there are 100 peaches with valuations of 100 for the buyers, and 60 for the sellers. There are 500...
A used car lot has 150 cars, 90 of the cars are black and 60 cars...
A used car lot has 150 cars, 90 of the cars are black and 60 cars are blue. What is the probability of 2 blue cars being test drove back to back; assuming the first car is purchased? What is the probability of 2 blue cars being test drove back to back; assuming the first car was not purchased?
Question 1 A Japanese firm manufactures cars in the US. Assume that each car sells for...
Question 1 A Japanese firm manufactures cars in the US. Assume that each car sells for $20,000 to a consumer in the US. Also assume that on each car the Japanese manufacturer earns $2000 in profits and remits those to the holding company in Japan. Assume that the car is manufactured with US made parts only. What is the contribution of each car to the US GNP? $ 18,000 $20,000 $22,000 $2,000 Question 2 A Japanese firm manufactures cars in...
Estimating Car Pollution: In a sample of seven cars, each car was tested for nitrogen oxide...
Estimating Car Pollution: In a sample of seven cars, each car was tested for nitrogen oxide emissions (in grams per mile) and the following results were obtained: 0.06, 0.11, 0.16, 0.15, 0.14, 0.08, 0.15 (based on data from the Environmental Protection agency). a) Assuming that this sample is representative of the cars in use, construct a 99% confidence interval estimate of the mean amount of nitrogen-oxide emissions for all cars. b) If the Environmental Protection Agency requires that nitrogen-oxide emissions...
There are many sellers of used cars. Each seller has exactly one used car to sell...
There are many sellers of used cars. Each seller has exactly one used car to sell and is characterised by the quality of the used car he wishes to sell. The quality of a used car is indexed by θ, which is uniformly distributed between 0 and 1. If a seller sells his car of quality θ for price p, his utility is p − θ2. If he does not sell his car, his utility is 0. Buyers of used...
Create and display an XML file in Android studio that has -One edittext box the does...
Create and display an XML file in Android studio that has -One edittext box the does NOT use material design -One edittext box that DOES use material design Provide a “hint” for each, and make sure the string that comprises the hint is referenced from the strings.xml file. Observe the differences in how the hints are displayed. Here is sample code for a material design editText: <android.support.design.widget.TextInputLayout         android:id="@+id/input_layout_price1Text"         android:layout_width="80dp"         android:layout_height="40dp"            >     <EditText             android:id="@+id/price1Text"             android:importantForAutofill="no"...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT