In: Computer Science
Hint: Use my files “threadSlides.xml”, “slideshow.xsd” and “slideHTML.xsl” as reference or starting point, and modify them for your project.
Explanation
==========================
sample_XSD :: This form of XSD allows easy modification/addition of new elements.
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