Presentation is loading. Please wait.

Presentation is loading. Please wait.

10/06/041 XSLT: crash course or Programming Language Design Principle XSLT-intro.ppt 10, Jun, 2004.

Similar presentations


Presentation on theme: "10/06/041 XSLT: crash course or Programming Language Design Principle XSLT-intro.ppt 10, Jun, 2004."— Presentation transcript:

1 10/06/041 XSLT: crash course or Programming Language Design Principle http://www-sato.cc.u-tokyo.ac.jp/schuko/ XSLT-intro.ppt 10, Jun, 2004

2 10/06/042 Why XSLT ? Very Simple to Parse (just XML), a little Harder than Scheme A Typical Programming Language on XML Informal Semantics, but well Described. XSLT Processors at Hand! No Need of Installation. (MSXML)

3 10/06/043

4 4 References XSLT Programmer’s Reference Michael Kay, WROX Press, 2001 XSLT Doug Tidwell, O’Reilly, 2001 XSLT Cookbook Sal Mangano, O’Reilly, 2002

5 10/06/045 What is XSLT? eXtensible Stylesheet Language Transformation A transformation expressed in XSLT describes rules for transforming a source tree into a result tree. Show by Example:

6 10/06/046

7 7

8 8

9 9 Why XSLT Designed? Requirements of XML o Separating Data from Presentation o Transmitting Data between Applications.  XML Fixed, and Transformer Designed  XSLT (to HTML, PDF, …)

10 10/06/0410 Systems for XML Handling XSLT XQuery  XML as Semi-Structured DataBase Rigid Formal Semantics is Given with Type System. XPath  Navigation in XML

11 10/06/0411 How XSLT Works A transformation expressed in XSLT describes rules for transforming a source tree into a result tree. XML

12 10/06/0412 How XSLT Works? (2) The transformation is achieved by associating patterns with templates. Patterns in Templates:

13 10/06/0413 Template Match

14 10/06/0414 How XSLT Works (3) A pattern is matched against elements in the source tree. A template is instantiated to create part of the result tree.

15 10/06/0415

16 10/06/0416

17 10/06/0417 In Summary, A transformation expressed in XSLT is called a stylesheet. This is because, in the case when XSLT is transforming into the XSL formatting vocabulary, the transformation functions as a stylesheet.

18 10/06/0418 StyleSheet – A Key Idea A stylesheet contains a set of template rules. A template rule has two parts: (1) a pattern which is matched against nodes in the source tree and (2) a template which can be instantiated to form part of the result tree.

19 10/06/0419 Execution Model The result tree is constructed by (1) finding the template rule for the root node and (2) instantiating its template.

20 10/06/0420 Instantiating a Template When a template is instantiated, each instruction is executed and replaced by the result tree fragment that it creates. contents of template = Instructions (explained later) Literal Result Element(Data)

21 10/06/0421

22 10/06/0422 Instantiating a Template (2) Instructions can select and process descendant source elements. Processing a descendant element creates a result tree fragment by finding the applicable template rule and instantiating its template.

23 10/06/0423 Programming Style (Digression) Push Processing -- Just call Execution (1) Select All Children, (2) Push Them to the Stylesheet, and (3) Let the Stylesheet Select Appropriate Templates

24 10/06/0424

25 10/06/0425 Programming Style (2) Pull Processing -- Select a Class of Specific Nodes as Execution (1) Select Specific Nodes, (2) Pull a Specific Template for their Processing

26 10/06/0426

27 10/06/0427 Key Ideas in Execution Execution by Template Instantiation Elements are only processed when they have been selected by the execution of an instruction.  Selection Schema is Critical

28 10/06/0428 Templates, Expressions, Datatypes So much for Templates  Templates = Functions in Traditional Sense. Remaining Part of Programming Languages  Expressions and Datatypes

29 10/06/0429 Variable and Binding Form: The Same as Traditional Variables name = (value of select)

30 10/06/0430 Example of XSL:VARIABLE 12pt

31 10/06/0431 Another Mechanism for Binding a Value to a Variable. -- Parameters of Template

32 10/06/0432 Example of Parameters 1. a.

33 10/06/0433 Scope of Variables Ordinary Rules for Scope. Does not Exceed the Extent of Template. From the Binding Point to the Point that Another Value is bound to the same name Variable.

34 10/06/0434

35 10/06/0435 To See the Result… Call factorial with the XML file: 100

36 10/06/0436 What is VALUE? Factorial isn’t Everything. Expression and Datatype to Represent XML Tree Structure. Boolean, Number, String (Ordinary) + NodeSet

37 10/06/0437 XPath Defines Expressions and their Expressive Power. Ordinary Boolean, Number, String Variable Reference, Function Call Path Expressions Specifying Node-Sets.

38 10/06/0438

39 10/06/0439 Node-Set in XPATH Selecting a Subset of a Tree. Traversing a Tree, and Specifying Conditions of the form STEP: Axis:: NodeTest [Predicates]

40 10/06/0440 Self Descendant Following Preceding Ancestor

41 10/06/0441

42 10/06/0442 XPATH Syntax (2) Abbreviations: (frequently used axis) // -- /decendant-or-self:: @ -- /attribute::

43 10/06/0443 XPATH Syntax Basic Form [/]Step/Step/Step/…/Step Step ≡ Axis::Node-Set ([ Predicate ]?) Axis ≡ self | child | descendant | parent | ancestor | sibling | following- sibling | following | preceding-sibling | preceding | attribute | …

44 10/06/0444 Examples of LocationPATH //figure @title book/author/first-name para[3]

45 10/06/0445 Control Structure of XSLT Conditional Jump

46 10/06/0446 Control Structure of XSLT (2) Note XSLT has NO ITERATION. ITERATION must be written in Recursion.

47 10/06/0447

48 10/06/0448 General Theory in Design Design of Programming Language ⇔ Model of Computing o Machine (CPU and memory) o Object Interaction o Recursion Thoery o λ-Calculus o Term Rewriting o …

49 10/06/0449 Model of Computing Goal 1: Representing Key Concepts of Computing o functional language  function o OO language  object Objects for “Key Concepts” must be treated as a FIRST CLASS OBJECT.

50 10/06/0450 Model of Computing (2) Goal 2: Representing Control o Control Structure (Conditional) o Subroutine Call o Data Structure They can Make Overlap. Object, Type, Class

51 10/06/0451 XSLT Execution Model Tree Manipulation Node Selection by XPATH Expression Basic Control Structure Given as Tree Construction in XML way.


Download ppt "10/06/041 XSLT: crash course or Programming Language Design Principle XSLT-intro.ppt 10, Jun, 2004."

Similar presentations


Ads by Google