When we open our XML document on browser, we will notice only the elements of that XML document. If we want to display our XML data in a table like format then we need to know about XSL.
HTML
HTML contains the predefined tags like <TABLE>, <H1>, etc. This will be well understood by the browser. And the browser also knows how to display these tags.
XML & XSL
The most recent version of XSLT is XSLT 2.0.
XML does not use any predefined tags i.e., we can use any tag-name we like. And these names are not well understood. The browser doesn’t know how to display these tags. Now the XSL plays its role, it stands for “Extensible Stylesheet Language”, which describes how the XML document should be displayed on the browser.Have a look at the following XML Document, which describes about Employees. It contains reference to the XSL file (Employee.xsl).
Employee.xml:
Now we need to create a XSL file, by name “Employee.xsl”.
Employee.xsl:
In the above code, xmlns:xsl="http://www.w3.org/1999/XSL/Transform" points to the official W3C XSLT namespace. The is used to build a template, and match attribute is used to associate a template with an XML element. Use “/” to associate the whole XML document.
XML data will be displayed in a table format. XSL also used to transform XML documents into some other formats.
1 comment:
thanks
Post a Comment