Presentation is loading. Please wait.

Presentation is loading. Please wait.

University of Nottingham School of Computer Science & Information Technology Introduction to XML 2. XSLT Tim Brailsford.

Similar presentations


Presentation on theme: "University of Nottingham School of Computer Science & Information Technology Introduction to XML 2. XSLT Tim Brailsford."— Presentation transcript:

1 University of Nottingham School of Computer Science & Information Technology Introduction to XML 2. XSLT Tim Brailsford

2 University of Nottingham 2 XSL / XSLT / FO l eXtensible Stylesheet Language l A language (an XML application) to define the appearance and behaviour of an XML document. l Transformation l The logical restructuring of a “source document” to produce a “result document”. l For example XML  HTML l Formatting l The precise description of screen/page layout. l XSLT vs FO

3 University of Nottingham 3 The XSLT Language l XML syntax (using the xsl: namespace) l XSL language consists of directives (ie elements in this namespace) l Rule-based l stylesheets consist of a series of templates that contain rules for the processing of a particular element. l XSL stylesheets are not a sequential programming language - rules are applied depending upon the logical structure of the document. l Rules may be conditional l XSL may contain variables (numeric or string), it may perform arithmetic calculations. l There is a library of parameterised functions

4 University of Nottingham 4 The Tree Model of XML export vt Send out (goods) to another country Latin ex out portare to carry

5 University of Nottingham 5 The Tree Model of XML

6 University of Nottingham 6 The Tree Model of XML

7 University of Nottingham 7 XML Node Types l Root Node l The top level node (1 per document) l Element Node l An element bound by a start and finish tag (or a single empty-element tag) l Text Node l A sequence of consecutive characters (PCDATA) l Attribute Node l The name and value of an attribute inside an element l Comment Node l Processing Instruction Node l Namespace Node

8 University of Nottingham 8 XML Node Relationships l Self l Parent l Ancestor l Child l Descendant l Following l Following-Sibling l Preceding l Preceding-Sibling

9 University of Nottingham 9 Self 1

10 University of Nottingham 10 Parent 1

11 University of Nottingham 11 Ancestor 2 1

12 University of Nottingham 12 Child 12

13 University of Nottingham 13 Descendant 12 345

14 University of Nottingham 14 Following 14 2356

15 University of Nottingham 15 Following-Sibling 12

16 University of Nottingham 16 Preceding 3 21

17 University of Nottingham 17 Preceding-Sibling 21

18 University of Nottingham 18 XSL Templates... l Templates contain transformation rules l either XSL directives or valid XML output. l Templates are matched to an XML node. see greeting-1.xsl

19 University of Nottingham 19 XPATH l XPATH is a sub-language within XSLT - used to identify components of the document. l XPATH expressions can be used to match a template, or the contents of an element. l Example:

20 University of Nottingham 20 Example XPATH Expressions l./MESSAGE../MESSAGE */MESSAGE MESSAGE/TITLE|MESSAGE/BODY ancestor(CHAPTER)/HEAD BOOK[@title] BOOK[not(@title)] //BOOK[@category=‘fiction’]

21 University of Nottingham 21 XSL apply-templates directive l Specifies that immediate children of a node should be processed further. It is possible to specify which children with an optional “select=xpath” see greeting-2.xsl


Download ppt "University of Nottingham School of Computer Science & Information Technology Introduction to XML 2. XSLT Tim Brailsford."

Similar presentations


Ads by Google