Notepad/enter/Coding Tips (Classical)/Terminal Tips/Languages/XML/XSL.md

81 lines
1.8 KiB
Markdown
Raw Normal View History

### XSL/XSLT
XSL - eXtensible Stylesheet Language
- a styling language for XML
XSLT - XSL Transformations
- transforms XML documents into other formats like HTML
```xml
<?xml-stylesheet type = "text/xsl" href = "student".xml?>
<class>
<student>
<firstname> Graham </firstname>
<lastname> Hall </lastname>
<nickname> Garry </nickname>
</student>
</class>
```
```xsl
<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 ](https://www.youtube.com/redirect?event=video_description&redir_token=QUFFLUhqbXVlTHJCdm96UjRDSzJHOVZwVklhRTF1YWNZZ3xBQ3Jtc0ttVE5qc3BGV3d5d3NoUDBKUXYwZFpBbFdRX2xJODZkcDVsWDRqLXhobE9yYXVsRDFMbW5HWndkcmpaNk5zLXZxZ1VVQVRPZ0RWd0w1ZXR0ZEIzdnEzRFNYUE9SeGpTSzgxcnpKUm5NdWF5WWFWWHdlZw&q=https%3A%2F%2Fwww.freeformatter.com%2Fxsd-generator.html&v=1BjmZHRHDv0)
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.