Question

In: Computer Science

Write a simple XML Schema file to define an XML document structure for simplified technical reports...

  1. 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.
  2. Write a simple XSL stylesheet to transform your technical report sample XML file into an HTML file with my utility “Transform”.
  3. Submit a zip file containing your XML Schema file, your sample XML document, your XSL stylesheet file, and the resulting HTML file as your assignment submission.

Hint: Use my files “threadSlides.xml”, “slideshow.xsd” and “slideHTML.xsl” as reference or starting point, and modify them for your project.

Solutions

Expert Solution

Explanation

==========================

sample_XSD :: This form of XSD allows easy modification/addition of new elements.

  • XSD created with the requirement. You can add as many elements as you would like on the start of XSD at the section <!--Define Elements Below -->.
  • Create types for elements in hierarchy order. Use REF attribute to reference the elements created in previous step.

sample_XML :: XML data generated based on the xsd.

sample_XSL :: Sample XSL file to transform.

sample_XSDtoXML_usingXSL_page :: html output.

==========================

Docs

==========================

sample_XSD

<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
   <!--Define Elements Below -->
   <xs:element name="ITEM1" type="xs:string"/>
   <xs:element name="ITEM2" type="xs:string"/>
   <xs:element name="ITEM3" type="xs:string"/>
   <xs:element name="REPORT_TITLE" type="xs:string"/>
   <xs:element name="CHAPTER" type="xs:string"/>
   <xs:element name="SECTION1" type="xs:string"/>
   <xs:element name="SECTION2" type="xs:string"/>
   <!--Define Elements Types and add reference of elments created above-->
   <!--Parent Element -->
   <xs:element name="SAMPLE">
       <xs:complexType>
           <xs:sequence>
               <xs:element ref="REPORT"/>
           </xs:sequence>
       </xs:complexType>
   </xs:element>
   <!--Child Element 1-->
   <xs:element name="REPORT">
       <xs:complexType>
           <xs:sequence>
               <xs:element ref="REPORT_TITLE"/>
               <xs:element ref="CHAPTER"/>
               <xs:element ref="SECTION_LIST" maxOccurs="unbounded" minOccurs="0"/>
               <xs:element ref="ITEM_LIST"/>
           </xs:sequence>
       </xs:complexType>
   </xs:element>
   <!--Subchild Element 1-->
   <xs:element name="ITEM_LIST">
       <xs:complexType>
           <xs:sequence>
               <xs:element ref="ITEM1"/>
               <xs:element ref="ITEM2"/>
               <xs:element ref="ITEM3"/>
           </xs:sequence>
       </xs:complexType>
   </xs:element>
   <!--Subchild Element 2-->
   <xs:element name="SECTION_LIST">
       <xs:complexType>
           <xs:sequence>
               <xs:element ref="SECTION1"/>
               <xs:element ref="SECTION2"/>
           </xs:sequence>
       </xs:complexType>
   </xs:element>
</xs:schema>

==========================

sample_XSL

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:output method="text"/>
   <xsl:template match="/">
       Report - <xsl:value-of select="/SAMPLE/REPORT/REPORT_TITLE"/>
       Chapters: <xsl:apply-templates select="//SAMPLE/REPORT/CHAPTER"/>
       Sections: <xsl:apply-templates select="//SAMPLE/REPORT/SECTION_LIST"/>
       Items: <xsl:apply-templates select="//SAMPLE/REPORT/ITEM_LIST"/>
   </xsl:template>
   <xsl:template match="Report">
       - <xsl:value-of select="."/>
   </xsl:template>
</xsl:stylesheet>

==========================

sample_XML

<?xml version="1.0" encoding="utf-8"?>
<SAMPLE>
<REPORT>
<REPORT_TITLE>SAMPLE REPORT TITLE</REPORT_TITLE>
<CHAPTER>SAMPLE CHAPTER</CHAPTER>
<SECTION_LIST>
<SECTION1>SAMPLE SEC1</SECTION1>
<SECTION2>SAMPLE SEC2</SECTION2>
</SECTION_LIST>
<ITEM_LIST>
<ITEM1>SAMPLE ITEM1</ITEM1>
<ITEM2>SAMPLE ITEM2</ITEM2>
<ITEM3>SAMPLE ITEM3</ITEM3>
</ITEM_LIST>
</REPORT>
</SAMPLE>

==========================

sample_html


       Report - SAMPLE REPORT TITLE
       Chapters: SAMPLE CHAPTER
       Sections:
SAMPLE SEC1
SAMPLE SEC2
  
       Items:
SAMPLE ITEM1
SAMPLE ITEM2
SAMPLE ITEM3
  ==========================

In case of any further queries please share the sample files threadSlides.xml, slideshow.xsd and slideHTML.xsl


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>...
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...
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 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>...
Exercise 1: Write an XML document describing the exercises in this document: the root element is...
Exercise 1: Write an XML document describing the exercises in this document: the root element is <exercises>. The root has an attribute number that has value 1. The root element has three child elements; <date> that contains as text the date of the exercise, and two <item> elements for the first two exercises (1--2). Write some text in the <item> elements. Exercise 2: Write an XML document describing a person: name, occupation, address and hobbies. Please do not use your...
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)>
Please Write an XML document describing a person: name, occupation, address, and hobbies. Decide on suitable...
Please Write an XML document describing a person: name, occupation, address, and hobbies. Decide on suitable element names and nesting. Check your document for well-formedness. And draw a tree that represents the XML document you created. Thanks
Exercise 2: Write an XML document describing a person: name, occupation, address and hobbies. Please do...
Exercise 2: Write an XML document describing a person: name, occupation, address and hobbies. Please do not use your own information, you can use fake data. Decide on suitable element names and nesting. Check your document for well-formedness. Exercise 3: Draw a tree that represents the XML document you created in task 2.
Write a simple text-formating.cpp file that reads (asks for then reads) a text file and produces...
Write a simple text-formating.cpp file that reads (asks for then reads) a text file and produces another text file in Which blank lines are removed, multiple blanks are replaced with a single blank, and no lines are longer than some given length (let say 80). Put as many words as possible on the same line (as close as possible to 80 characters). You will have to break some lines of the given file, but do not break any words or...
Write a C++ program that implements a simple scanner for a source file given as a...
Write a C++ program that implements a simple scanner for a source file given as a command-line argument. The format of the tokens is described below. You may assume that the input is syntactically correct. Optionally, your program can build a symbol table (a hash table is a good choice), which contains an entry for each token that was found in the input. When all the input has been read, your program should produce a summary report that includes a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT