Extensible Stylesheet Language

What is XSL-: XSL stands for eXtensible Stylesheet Language. In English, that means XSL is an XML document that contains instructions for taking a source XML file and transforming it into something else. This “something else” could be HTML, XML, text, or all of those. XSL is one of the most important uses of XML.

it allows a single source XML document to be transformed in many different ways. In still other words, XSL is an XML document, so we must follow all of XML’s rules when creating XSL files

Use of XSL -: We are using only XSL behind the scenes to show how XML can be translated into HTML to view in our web browser. We know enough about XML now to begin experimenting in XSL.

XSL can be used to transform XML, but what else can it do? We can use XSL to add some sorting capability so our XML phone book information will be returned in alphabetical order. This is especially useful when we have several people accessing our PhoneBook.xml document.

People who use our phone book file may add phone book listings at the top of the file, the bottom of the file, or they may even try to alphabetize the list themselves. Instead of depending on users to sort the information themselves, we can use an XSL document to translate the source XML phonebook into an alphabetically ordered phonebook (in HTML or XML).This is only one of many possible uses for XML.

How to use Translate Function in CodeRunner -: CodeRunner has a powerful Translate function. For understanding this we take a example and see how it works. Open your Friends.xml file and modify the code as shown:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://www.netnic.org/" type="text/xsl"?>
<!DOCTYPE Friends>
<Friends xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Friends.xsd">
<Phone Type="Cell">999-1717</Phone>

We link it XSL to our XML Source-:We used xml-stylesheet statements in our xml files back in our first XML document, so the new code probably looks familiar. When working with XML and XSL documents.We need to specify which XSL document will be used to translate our XML document by default. The xml-stylesheet statement serves that purpose. Here’s the code we might use to link XSL inside our XML document.

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="vikram.xsl"?>

We added a reference to the XSL file vikram.xsl, which makes that our default XSL file

If We were open our XML file in a web browser, it would automatically perform the translation using the vikram.xsl style sheet and the results would be displayed on our screen. Now, click to translate our XML file. Our XML document is translated and the results displayed in a new window.

More Read about XML Topic List

Leave a Comment