Presentation is loading. Please wait.

Presentation is loading. Please wait.

XSLT (eXtensible Stylesheet Language Transformation) 1.

Similar presentations


Presentation on theme: "XSLT (eXtensible Stylesheet Language Transformation) 1."— Presentation transcript:

1 XSLT (eXtensible Stylesheet Language Transformation) 1

2 XSLT XSLT is a language for transforming XML documents into HTML documents or to other XML documents. An XSL style sheet is a set of transformation instructions for converting a source XML document to a target document. 2 XML Document XSL Style Sheet 2 Output from Style Sheet 1 Output from Style Sheet 2 XSL Style Sheet 1 Parser XSLT Processor

3 3 3 table.xsl bar.xsl art.xsl

4 XSLT Two tree structures are involved in transforming an XML document using XSLT  source tree (usually the XML file)  result tree (the result of the transformation either html or other XML file) For XSLT to function, the source (XML) tree must be properly structured.  XML document must be validated against a DTD to make sure the structure is correct. XSL documents have the extension.xsl All major browsers have support for XML and XSLT. 4

5 Example Sarah ISC 3.0 Fatma AAD 2.5 Aseel ISC Name Major XML FileXSTL File

6 Example 6 XML file without XSLT Output after applying the XSLT to the XML file

7 XSLT Declaration The XSTL file begins with the XML declaration The root element XSLT document is The correct way to declare an XSL style sheet according to the W3C XSLT Recommendation is 7.

8 Link the XSLT File to the XML Document The XML document should include the XSLT style sheet reference. 8 Sarah ISC 3.0 Fatma.

9 XSLT - Element The element is used to build templates. The match attribute is used to associate a template with an XML element.  Setting match="/" attribute associates the template with the root of the XML source document. 9.

10 XSLT - Element 10 Sarah ISC 3.0 Fatma AAD 2.5 Aseel ISC 3.3 XML File Here the template is associated with the root element The XSTL processor will start from the root element in the XML file

11 XSLT - Element 11 Name Major

12 XSLT - Element The XSL element is used to extract the value of an XML element and add it to the output of the transformation. Notice that only one line of data was copied from the XML document to the output.  Usually the first instance of the element is Selected. 12 NOTE: the forward slash (/) is to specify a sub-element (child element)

13 XSLT - The Element The XSL element can be used to select every XML element of a specific type Select every element in the XML document (similar to a loop) For each element print the content of the 1. element 2. element

14 XSLT - The Element 14 Sarah ISC 3.0 Fatma AAD 2.5 Aseel ISC 3.3 XML File

15 XSLT- Filtering the Output Relational and logical operators can be used in the element to filter the output from the XML file. Legal relational operators are:  = (equal to)  != (not equal to)  < (less than), <= (less than or equal)  > (greater than), >= (greater than or equal) Logical operators are:  and  or 15

16 XSLT- Filtering the Output Print the names and GPAs of students whose (GPA > 3.0). 16..

17 XSLT- Filtering the Output Examples Print the names and GPAs of students in ISC. Print the names, majors, and GPAs, of AAD students and students with gpa greater than or equal to


Download ppt "XSLT (eXtensible Stylesheet Language Transformation) 1."

Similar presentations


Ads by Google