xml
students.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="students.xsl"?>
<students>
<student>
<name>Aswath S</name>
<age>21</age>
<dob>09/08/2000</dob>
<mobile>912345674</mobile>
<address>CBE</address>
</student>
<student>
<name>Surya M</name>
<age>21</age>
<dob>04/08/2000</dob>
<mobile>998765439</mobile>
<address>CBE</address>
</student>
</students>
students.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>Students Personal Details</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Name</th>
<th>Age</th>
<th>DOB</th>
<th>Mobile</th>
<th>Address</th>
</tr>
<xsl:for-each select="students/student">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="age"/></td>
<td><xsl:value-of select="dob"/></td>
<td><xsl:value-of select="mobile"/></td>
<td><xsl:value-of select="address"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
validation xml and xsd
university.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="university">
<xs:complexType>
<xs:sequence>
<xs:element name="department" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="course" maxOccurs="unbounded" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
university.xml
<?xml version="1.0" encoding="UTF-8"?>
<university xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="university.xsd">
<department>
<name>kiran</name>
<course>Introduction to Programming</course>
<course>Data Structures</course>
</department>
<department>
<name>Arun</name>
<course>Calculus I</course>
<course>Linear Algebra</course>
</department>
</university>
👍🏻
ReplyDelete