![]() | |
XML Style Sheet (XSL) Syntax XSL is used to define, how the XML file should be converted so that it can seen in the required format in the Browser. For Example say in the XML file we declare a Tag called <showbold>This is The Heading Text </showbold> , and you want to show the Text inside these tags in a different Font and Color , then in your XSL file you would declare it as
Here as soon as the Tag "showbold" is encountered in the XML file, then automatically the Text is replaced with Different Font size and color in bold. This is just an example. In real time, some tags, will be creating Table and show the Data in a well formatted way. Also note that tag "showbold" is not part of the standard HTML and here you have defined a Custom Tag. Declaring Sequences in XSL FileSequences are useful if you want to show the same kind of tags, declared multiple times in the XML file in a more suitable format like, using Tables. Let's consider the Following Example XML File.
The above XML file has a Parent Tag called LIBRARY which has lots of Sub Tags called BOOK. Now while Displaying this XML file, say we want to Display it in the Form of a Table. Here's how we will be generating Sequence in the XSL file,
As you can see in the above Example, we consider each BOOK Tag under Main Tag LIBRARY and in a Sequence we display the List of all Books. The Main difference is made by tag "xsl:for-each" which helps in iterating through all the BOOK tags. Also note that when we say xsl:value-of select="PUBLISHER , then it retrieves the Value given inside the Tags </PUBLISHER> within the current Tag <BOOK>.
|