May 28, 2021 XSL T
Example study: How to convert XML to XHTML using XSLT.
We'll explain the details of this example in the next chapter.
The root element that declares the document as an XSL style sheet is slt;xsl:stylesheets;or slt;xsl:transform>.
Note: slt;xsl:stylesheet and slt;xsl:transform> are completely synonymable and can be used!
According to W3C's XSLT standard, the correct way to declare an XSL style sheet is to:
Or:
To access the elements, properties, and attributes of XSLT, we must declare the XSLT namespace at the top of the document.
xmlns:xsl""http://www.w3.org/1999/XSL/Transform""" If you use this namespace, you must include the property version "1.0".
Let's now convert the following XML document ("cdcatalog.xml") to XHTML:
View XML files in Firefox and Internet Explorer: Open an XML file (usually by clicking on a link) - The XML document displays the root and child elements in colored code. C licking on the plus sign to the left of the element or minus sign (-) expands or shrinks the structure of the element. To view the original XML source file without plus or minus sign, select View Page Source code or View Source Code in the browser menu.
View the XML file in Netscape 6: Open the XML file, then right-click on the XML file and select View page source code. XML documents display root and child elements in colored code.
View the XML file in Opera 7: Open the XML file, then right-click on the XML file, select Frame/View Source Code. The XML document appears as plain text.
Then create an XSL style sheet with a conversion template ("cdcatalog.xsl"):
Add an XSL style sheet reference .xml XML document ("cdcatalog"):
If you're using a browser that's compatible with XSLT, it's going to convert your XML to XHTML very smoothly.
In the next section, we'll cover the examples that appear in this section in more detail!