John Congratulations,, you are a winner! Input document: Output: Congratulations, John, you are a winner!">

Presentation is loading. Please wait.

Presentation is loading. Please wait.

©CSW Group Ltd 2005 Intermediate XSLT Bob DuCharme these slides: 1.0.

Similar presentations


Presentation on theme: "©CSW Group Ltd 2005 Intermediate XSLT Bob DuCharme these slides: 1.0."— Presentation transcript:

1 ©CSW Group Ltd 2005 Intermediate XSLT Bob DuCharme these slides: 1.0

2 Outline Variables and parameters Named templates and parameters xsl:for-each and “looping” XSLT extensions and EXSLT Using keys for faster lookups XSLT and browsers

3 Variables John Congratulations,, you are a winner! Input document: Output: Congratulations, John, you are a winner!

4 Passing Parameters to Stylesheets John Congratulations,, you are a winner! Same input document, same result, but when we override the default parameter value: C:\>saxon temp.xml test.xsl winnerName=Jane Congratulations, Jane, you are a winner!

5 Named Templates

6 Passing Parameters to Named Templates h4 h1

7 Iterating across a set of nodes output:

8 Repetition 1 -

9 Testing the recursive template rule Print 1 hyphen: Print 20 hyphens: Print 0 hyphens:

10 Recursive template rule: result Print 1 hyphen: - Print 20 hyphens: Print 0 hyphens:

11 XSLT Extension functions

12 Testing the extension function Source document: test Result: /a /a/b[1] /a/b[2] /a/b[2]/c[1] test /a/b[3]

13 Extension elements (and attributes) The value of i is

14 Extension element test output The value of i is 0 The value of i is 1 The value of i is 2 The value of i is 3 The value of i is 4 The value of i is 5 The value of i is 6 The value of i is 7 The value of i is 8 The value of i is 9

15 Checking for extension support (option 1) The value of i is Your XSLT processor doesn't support saxon:while.

16 Checking for extension support (option 2) The value of i is Your XSLT processor doesn't support saxon:while. checking for extension function support: function-available()

17 EXSLT Saxon documentation on its extensions: “ Before using a Saxon extension, check whether there is an equivalent EXSLT extension available. EXSLT extensions are more likely to be portable across XSLT processors.”

18 Some EXSLT extensions (pt 1) exsl:object-type(3): exsl:object-type('potrzebie'): exsl:object-type(2 > 1):

19 Some EXSLT extensions (pt 2) math:constant('PI',4): math:constant('PI',12): math:sqrt(256): date:date-time: date:day-name:

20 EXSLT demo result exsl:object-type(3): number exsl:object-type('potrzebie'): string exsl:object-type(2 > 1): boolean math:constant('PI',4): math:constant('PI',12): math:sqrt(256): 16 date:date-time: T11:24:12-04:00 date:day-name: Saturday same result with Saxon and Xalan Java!

21 Declaring and using lookup keys we have: yellow blue orange green oxford button-down poly blend, straight collar monogrammed, tab collar we want: blue oxford button-down yellow poly blend, straight collar white monogrammed, tab collar

22 Without keys

23 With keys

24 How key lookup works

25 More lookups (part 1) c4 colorKey Looking up the color name with the color ID: c3's color: c4's color: c8's color: c7's colors:

26 More lookups (part 2) Looking up the color ID with the color name: blue's cid: black's cid: gray's cid:

27 More lookups: result Looking up the color name with the color ID: c3's color: red c4's color: blue c8's color: c7's colors: orange green Looking up the color ID with the color name: blue's cid: c4 black's cid: c2 gray's cid:

28 Muenchian Grouping , bytes

29 Muenchian Grouping: result jupiter gadabout.pas,685 bytes kwatz.xom,43 bytes potrzebie.dbf,1102 bytes mars schtroumpf.txt,389 bytes swablr.eps,4313 bytes ummagumma.zip,2441 bytes neptune batboy.wks,424 bytes mondegreen.doc,1993 bytes paisley.doc,988 bytes

30 Web Browsers and XSLT W3C Recommendation "Associating Style Sheets with XML documents" (http://www.w3.org/TR/xml-stylesheet) shows how:

31 Web Browsers and XSLT (part 1) Squares body { font-family: arial,helvetica; } h1 { font-size: 14pt } p { font-size: 10pt} Squares

Similar presentations


Ads by Google