Question

In: Computer Science

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>
<lowest>23.2</lowest>
</weather>
<weather yyyymmdd="20200421">
<year>2020</year>  
<month>04</month>
<date>21</date>
<comment>Plenty of sunshine</comment>
<code>sunny</code>
<highest>32.2</highest>
<lowest>29.8</lowest>
</weather>
<weather yyyymmdd="20200628">
<year>2020</year>  
<month>06</month>
<date>28</date>
<comment>A morning shower, then rain</comment>
<code>rain</code>
<highest>30.2</highest>
<lowest>22.7</lowest>
</weather>
<weather>
<weather yyyymmdd="20200502">
<year>2020</year>  
<month>05</month>
<date>02</date>
<comment>Cloudy with a thunderstorm</comment>
<code>thunderstorm</code>
<highest>28.1</highest>
<lowest>26.9</lowest>
</weather>
<weather yyyymmdd="20200428">
<year>2020</year>  
<month>04</month>
<date>28</date>
<comment>A morning shower</comment>
<code>rain</code>
<highest>28.8</highest>
<lowest>22.2</lowest>
</weather>
<weather yyyymmdd="20200410">
<year>2020</year>  
<month>04</month>
<date>10</date>
<comment>Partly sunny</comment>
<code>partlySunny</code>
<highest>33.7</highest>
<lowest>29.3</lowest>
</weather>
<weather yyyymmdd="20200730">
<year>2020</year>  
<month>07</month>
<date>30</date>
<comment>Plenty of sunshine</comment>
<code>sunny</code>
<highest>32.3</highest>
<lowest>28.4</lowest>
</weather>
<weather yyyymmdd="20200706">
<year>2020</year>  
<month>07</month>
<date>06</date>
<comment>Plenty of sunshine</comment>
<code>sunny</code>
<highest>34.5</highest>
<lowest>30.6</lowest>
</weather>
</forecast>

Solutions

Expert Solution

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xs:element name="forecast">
                <xs:complexType>
                        <xs:sequence>
                                <xs:element maxOccurs="unbounded" name="weather">
                                        <xs:complexType>
                                                <xs:sequence>
                                                        <xs:element name="year" type="xs:int"></xs:element>
                                                        <xs:element name="month" type="xs:int"></xs:element>
                                                        <xs:element name="date" type="xs:int"></xs:element>
                                                        <xs:element name="comment" type="xs:string"></xs:element>
                                                        <xs:element name="code" type="xs:string"></xs:element>
                                                        <xs:element name="highest" type="xs:decimal"></xs:element>
                                                        <xs:element name="lowest" type="xs:decimal"></xs:element>
                                                </xs:sequence>
                                                <xs:attribute name="yyyymmdd" type="xs:unsignedInt" use="required" />
                                        </xs:complexType>
                                </xs:element>
                        </xs:sequence>
                        <xs:attribute name="qTime" type="xs:string" use="required" />
                        <xs:attribute name="qLocation" type="xs:string" use="required" />
                </xs:complexType>
        </xs:element>
</xs:schema>

Screenshots

Browser Output


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....
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...
1. The following XML document describes some employees of a company. <?xml version="1.0" encoding="UTF-8"?> <company> <person...
1. The following XML document describes some employees of a company. <?xml version="1.0" encoding="UTF-8"?> <company> <person age="25" id="p29432" manager="p48293"> <ssn>123456789</ssn> <name> John Davis</name> <office>B432</office> <phone>1234</phone> </person> <person age="27" id="p29333" manager="p48222"> <ssn>987654321</ssn> <name>Jim Handler</name> <office>B123</office> </person> <person age=55 id="p29432" manager="p48221"> <ssn>123456789</ssn> <name> Christo Dichev</name> <office>A4210</office> <phone>2477</phone> </person> <person age="57" id="p29333" manager="p4832"> <ssn>987654321</ssn> <name>Elva Jones</name> <office>A4211</office> </person> </company> 1. Check if the XML document is well-formed. If it is not, change it so that it becomes wellformed, making as little changes as...
Write a DTD for this XML document such that the corrected version of the example is...
Write a DTD for this XML document such that the corrected version of the example is a valid XML document <?xml version="1.0"?> <computers> <item type = "Laptop" code = "Dell437">    <make>    <brand>Dell Inspiration</Brand>    <supplier id = "Dell"/>    </make>    <spec>    <cpu speed = "900"/>    <harddisk size = "12" units = "GB"/>    </Spec>    <price n = "950" units = "USD"/> </item> <item type = "Desktop" code = "Apple1679">    <make>    <brand>Apple iMac</brand>...
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...
Consider the XML DTD definition below. Write a well-formed and valid XML Document that conforms to...
Consider the XML DTD definition below. Write a well-formed and valid XML Document that conforms to this definition. <!ELEMENT wine-catalog (wine+)> <!ELEMENT wine (properties,origin,price,year,tasting-note?)> <!ATTLIST wine    code   ID #REQUIRED name   #PCDATA #REQUIRED    classification #PCDATA #REQUIRED format (375ml|750ml) “750ml”> <!ELEMENT properties (color,alcohol-content)> <!ELEMENT color (#PCDATA)> <!ELEMENT alcohol-content (#PCDATA)> <!ELEMENT origin (country, region, producer)> <!ELEMENT country (#PCDATA)> <!ELEMENT region (#PCDATA)> <!ELEMENT producer (#PCDATA)> <!ELEMENT price (#PCDATA)> <!ELEMENT year (#PCDATA)> <!ELEMENT tasting-note (#PCDATA)>
Create, test, and validate an HTML document that has a form with the following controls: a....
Create, test, and validate an HTML document that has a form with the following controls: a. A text box to collect the user's name b. Four checkboxes, one for each of the following items: i. Four 25-watt light bulbs for $2.39 ii. Eight 25-watt light bulbs for $4.29 iii. Four 25-watt long-life light bulbs for $3.95 iv. Eight 25-watt long-life light bulbs for $7.49 c. A collection of three radio buttons that are labeled as follows: i. Visa ii. Master...
.Create, test, and validate an XHTML document that describes an ordered list with the following contents:...
.Create, test, and validate an XHTML document that describes an ordered list with the following contents: The highest level should be the names of your parents, with your mother first. Under each parent, you must have a nested, ordered list of the brothers and sisters of your parents, in order by age, eldest first. Each of the nested lists in turn must have nested lists that list the children of your uncles and aunts (your cousins)—under the proper parents, of...
Create, test, and validate an HTML document that defines a table with columns for state, state...
Create, test, and validate an HTML document that defines a table with columns for state, state bird, state flower, and state tree. There must be at least five rows for states in the table.
Create, test, and validate an HTML document for yourself, including your name, address, and email address....
Create, test, and validate an HTML document for yourself, including your name, address, and email address. If you are a student, you must include your major and your grade level. This document must use several headings and <em>, <strong>, <hr />, <p>, and <br /> tags.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT