Notepad/enter/Coding Tips (Classical)/Terminal Tips/2. CLI Tools/Languages/Middle/XML/XSL.md

1.8 KiB

XSL/XSLT

XSL - eXtensible Stylesheet Language - a styling language for XML

XSLT - XSL Transformations - transforms XML documents into other formats like HTML

<?xml-stylesheet type = "text/xsl" href = "student".xml?>

<class>
	<student> 
		<firstname> Graham </firstname> 
		<lastname> Hall </lastname> 
		<nickname> Garry </nickname> 
	</student> 
</class> 
<xsl:stylehseet verion = "1.0"
xmins:xml = "http://www.w1.org/1999/XML/tranform">

<xml.template match = "/class">
	<html> 
		<body>
		<h2> Student List < /h2> 
	<table border = "1"> 
			<tr bgcolor="lightgreen"> 
				<tr> First Name </tr> 
				<tr> Last Nam </tr> 
				<tr> Nick Name </tr> 
			</tr>
			
			<xsl: for-each select = "student">
				<tr>
					<td><xsl:value-of select = "firstname"/>
					</td>
					<td><xsl:value-of select = "lastname"/>
					</td>
					<td><xsl:value-of select = "nickname"/>
					</td>
		</body> 
	</html> 
<xml:template> 
</xsl:stylesheet> 

Output: !Pasted image 20230901130417.png

XML Scheme:

<class> 
	<student> 
		<firstname> 
</class>

It is Valid if it follows an XML Schema or XSD (XML Scheme definition) XML Scheme describes the structure of an XML document, written in XML

XSD Generator

Example:

<xs:schema xmins:xs="http://www.w3.org"> 
	<xs:element name="class">
		<xs:complexType> 
			<xminselement name ="student> maxOccurs="Unbounded" minOccurs="0">
				

Ensure that it is valid.