Presentation is loading. Please wait.

Presentation is loading. Please wait.

Extensible Stylesheet Language for Transformations XSLT An introduction.

Similar presentations


Presentation on theme: "Extensible Stylesheet Language for Transformations XSLT An introduction."— Presentation transcript:

1 Extensible Stylesheet Language for Transformations XSLT An introduction

2 Why ‘transformations’? XML document XML document XML document HTML document XML document HTML document

3 Why ‘transformations’? XML document XML document HTML document Corpus search results More readable presentations

4 (1) Take an XML file… e.g., a play…. The Two Gentlemen of Verona Text placed in the public domain by Moby Lexical Tools, 1992. SGML markup by Jon Bosak, 1992-1994. XML version by Jon Bosak, 1996-1998. This work may be freely copied and distributed worldwide. Dramatis Personae DUKE OF MILAN, Father to Silvia. VALENTINE PROTEUS the two Gentlemen. …

5

6

7

8 (2) Take an XSLT file… http://www.w3.org/1999/XSL/Transform

9 (2) Take an XSLT file… http://www.w3.org/1999/XSL/Transform From the top of an XML file(“/”), go looking for any place where we can find a TITLE element (“//TITLE”). XPath

10 (2) Take an XSLT file… http://www.w3.org/1999/XSL/Transform Whenever we find a TITLE element (“TITLE”), take the value of that ‘node’ (“.”) and put it in our output document

11 … (3) apply the XSLT file to the XML file of the play …

12 (4) And hey presto…. … all the TITLES from the play…

13 … that is not very readable though, so we can …

14 (5) … add some HTML

15 (5) … add some HTML

16 (5) … add some HTML Search Results

17 (5) … add some HTML Search Results HTML

18 … (6) apply the XSLT file to the XML file of the play again…

19 … and we get …

20 We can also start making it fancier… Search Results Our search results This time we wrap the HTML code for a table around our XSLT expressions…

21 … (7) apply the XSLT file to the XML file of the play again …

22 … and we get …

23 Lets make this more useful… Task: select all the lines in the play that were spoken by some particular character…

24 How do we do this? Look in the XML file to see how speaker turns are represented Write a proper XPath expression to pick out just the turns that we are interested in Put that XPath expression in place of our “TITLE” XPath in the example XSLT file Apply the XSLT file to the play again

25 The DTD gives us the kinds of XPath expressions that we need /PLAY

26 The DTD gives us the kinds of XPath expressions that we need /PLAY /ACT

27 The DTD gives us the kinds of XPath expressions that we need /PLAY /ACT/SCENE

28 The DTD gives us the kinds of XPath expressions that we need /PLAY /ACT/SCENE/SPEECH

29 The DTD gives us the kinds of XPath expressions that we need /PLAY /ACT/SCENE/SPEECH

30 Try #1 Search Results Our search results

31 Result #1

32

33 Try #2

34 Result #2

35

36 A variant of Try #2

37 Try #3

38 Result #3

39

40 As final icing on the cake… Lets replace the redundant name with the title of the scene that the turns occur in!

41 A solution…

42

43 And one more complex example still… The turns of SPEED plus the preceding turn to show the dialogue context… The stylesheet is on the course website

44

45 There is very little one cannot do with an XSLT for transforming documents Although it can be quite difficult sometimes to see how!


Download ppt "Extensible Stylesheet Language for Transformations XSLT An introduction."

Similar presentations


Ads by Google