0% found this document useful (0 votes)
50 views34 pages

XSLT

XSLT (Extensible Stylesheet Language Transformations) is a declarative programming language designed for transforming XML documents into other formats like HTML. It utilizes XPath for selecting nodes and allows for dynamic properties such as iteration and conditional statements. XSLT is primarily used for XML-to-XML and XML-to-HTML transformations, reducing server load by performing transformations on the client side.

Uploaded by

Bijay Kc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
50 views34 pages

XSLT

XSLT (Extensible Stylesheet Language Transformations) is a declarative programming language designed for transforming XML documents into other formats like HTML. It utilizes XPath for selecting nodes and allows for dynamic properties such as iteration and conditional statements. XSLT is primarily used for XML-to-XML and XML-to-HTML transformations, reducing server load by performing transformations on the client side.

Uploaded by

Bijay Kc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 34
XSLT Introduction What is XSLT? — XSLT is a short term for Extendable Stylesheet Language Transformation. DEFINITION: = Adeclarative programming language for specifying transformations between XML languages — Even though it is a "stylesheet," it has a different goal than CSS (Cascading Stylesheets). XSLT is not used for visual effect, but instead extracting data (or transforming) from XML and using the combination of HTML and CSS to format them. — XSLT also has the dynamic properties where you can do iteration and conditional statements upon a static XML file. USES OF XSLT XML documents are self describing and structured documents, To generate the XML file as HTML file to be displayed by a browser. XSLT can be used for organizing large trees of XML so that anyone can read it To generate new XML documents from existing XML documents. Designed primarily for XML-to-XML and XML-to-HTML transformations. XSLT also cuts down on server load. Since XSLT can do the transformation on the client site, the server has to do less work, since we are not querying upon data in database. Why XSLT? Simple syntax Easy to write Easy to read and understand Reusable ~All the advantages of being the XML based language ~ XSLT uses XPath to find information in an XML document. “In the transformation process, XSLT uses XPath to define parts of the source document that should match one or more predefined templates. “When a match is found, XSLT will transform the matching part of the source document into the result document. bh ~ XSL uses XSLT which uses Xpath. - The style sheet describes rules for transforming a source tree into a result tree. - When a pattern is matched in the source tree, the corresponding pattern is generated in the result tree. = XSUT processor reads both an XML document and an XSLT style sheet, and it outputs a new XML document or fragment. To get access to the XSLT Slements, attributes and features we must declare the XSLT namespace at the top of the document. - _ xmins:xsl="http://www.w3.org/1999/XSL/Transform" points to the official W3C XSLT namespace. - To use this namespace, we must also include the attribute version="1.0". xmins:xsl: + XSLT uses two input files: — The XML document containing the actual data, = The XSL document containing both the “framework” in which to insert the data, and XSLT commands to do so. [action] "> + File data.xml: Welcome to this Course! le + File render.xst: ‘An XSLT document has the .xsl extension The XSLT document begins with: XML declaration Every XSLT file must have a root element, Contains one or more templates, such as: ... And ends with: + The template says to select the — selecting the root node of the XML tree + Inside this template, — selects the message child R = Alternative Xpath expressions that would also work: + ./message + /message/text() (text() is an XPath function) + /message/text() Matching and Selecting Templates * xsl:template © xsl:apply-template * xsi:value-of h Branching Elements ¢ xsl:for-each © xshif * xsl:choose XSLT