Beginning XSLT 2.0 from Novice to Professional

Total Page:16

File Type:pdf, Size:1020Kb

Beginning XSLT 2.0 from Novice to Professional 3243chFM.qxd 6/20/05 10:06 AM Page i Beginning XSLT 2.0 From Novice to Professional JENI TENNISON 3243chFM.qxd 6/20/05 10:06 AM Page ii Beginning XSLT 2.0: From Novice to Professional Copyright © 2005 by Jeni Tennison All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN (pbk): 1-59059-324-3 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Lead Editor: Chris Mills Technical Reviewer: Norman Walsh Editorial Board: Steve Anglin, Dan Appleman, Ewan Buckingham, Gary Cornell, Tony Davis, Jason Gilmore, Jonathan Hassell, Chris Mills, Dominic Shakeshaft, Jim Sumser Assistant Publisher: Grace Wong Project Manager: Kylie Johnston Copy Manager: Nicole LeClerc Copy Editor: Ami Knox Assistant Production Director: Kari Brooks-Copony Production Editor: Kelly Winquist Compositor and Artist: Kinetic Publishing Services, LLC Proofreader: Elizabeth Berry Indexer: Kevin Broccoli Cover Designer: Kurt Krames Manufacturing Manager: Tom Debolski Distributed to the book trade in the United States by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013, and outside the United States by Springer-Verlag GmbH & Co. KG, Tiergartenstr. 17, 69112 Heidelberg, Germany. In the United States: phone 1-800-SPRINGER, fax 201-348-4505, e-mail [email protected], or visit http://www.springer-ny.com. Outside the United States: fax +49 6221 345229, e-mail [email protected], or visit http://www.springer.de. For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley, CA 94710. Phone 510-549-5930, fax 510-549-5939, e-mail [email protected], or visit http://www.apress.com. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indi- rectly by the information contained in this work. The source code for this book is available to readers at http://www.apress.com in the Downloads section. 3243chFM.qxd 6/20/05 10:06 AM Page iii Contents at a Glance About the Author . xv About the Technical Reviewer. xvii Acknowledgments . xix Introduction. xxi CHAPTER 1 Introducing XML . 1 CHAPTER 2 Creating HTML from XML . 47 CHAPTER 3 Templates . 85 CHAPTER 4 Conditions. 137 CHAPTER 5 Manipulating Atomic Values. 181 CHAPTER 6 Variables and Parameters. 233 CHAPTER 7 Paths and Sequences. 275 CHAPTER 8 Result Trees . 343 CHAPTER 9 Sorting and Grouping . 399 CHAPTER 10 IDs, Keys, and Numbering. 429 CHAPTER 11 Named Templates, Stylesheet Functions, and Recursion . 473 CHAPTER 12 Building XSLT Applications . 499 CHAPTER 13 Schemas . 525 CHAPTER 14 Backwards Compatibility and Extensions . 557 CHAPTER 15 Dynamic XSLT . 587 CHAPTER 16 Creating SVG . 625 CHAPTER 17 Interpreting RSS with XSLT. 669 APPENDIX A XPath Quick Reference . 697 APPENDIX B XSLT Quick Reference . 747 INDEX. 773 iii 3243chFM.qxd 6/20/05 10:06 AM Page iv 3243chFM.qxd 6/20/05 10:06 AM Page v Contents About the Author . xv About the Technical Reviewer. xvii Acknowledgments . xix Introduction. xxi ■CHAPTER 1 Introducing XML . 1 Markup Languages . 1 Extending HTML. 2 Meta-Markup Languages . 5 XML: The Extensible Markup Language. 6 XML Rules. 7 XHTML . 10 Naming Conventions . 10 Elements in XML . 12 Attributes in XML . 13 Entities, Characters, and Encodings . 15 Other Components of XML . 21 Moving to XHTML. 24 Creating Markup Languages . 26 Designing Markup Languages. 27 Validating Markup Languages . 35 Presenting XML . 40 Presenting XML with CSS. 41 Associating Stylesheets with XML . 42 Limitations of CSS . 44 Summary . 44 Review Questions . 45 ■CHAPTER 2 Creating HTML from XML. 47 XSL: The Extensible Stylesheet Language. 47 Using XSLT Processors . 50 Using Saxon . 53 Using MSXML . 55 v 3243chFM.qxd 6/20/05 10:06 AM Page vi vi ■CONTENTS Simplified Stylesheets . 59 Literal Result Elements . 61 The <xsl:value-of> Instruction . 62 The XSLT Namespace . 63 Generating HTML Pages. 69 Iterating Over Elements . 71 Generating Attribute Values . 79 Summary . 83 Review Questions . 83 ■CHAPTER 3 Templates. 85 XSLT Stylesheet Structure . 85 Stylesheet Document Elements. ..
Recommended publications
  • Radio 4 Extra Listings for 9 – 15 July 2011 Page 1 of 7 SATURDAY 09 JULY 2011 Voyage Is Yet to Begin
    Radio 4 Extra Listings for 9 – 15 July 2011 Page 1 of 7 SATURDAY 09 JULY 2011 voyage is yet to begin... Series 3 Jack London's 1904 tale of brutality and survival on the high Episode 6 SAT 00:00 Jenny Stephens - Project Archangel (b00wmznd) seas. Kenneth Horne heads a Bohemian Paris romp and Julian and Episode 4 Starring Jack Klaff, Kerry Shale and Ian Dury. Sandy report on the latest bona goings on for the Daily Polari. The reason for Mike's involvement with the Nablovski colony is Dramatised by Ed Thomason With Kenneth Williams, Hugh Paddick, Betty Marsden and Bill revealed, and also why Moira's case is so heavy. Stars Dan Wolf Larsen ...... Jack Klaff Pertwee. Hagley. Humphrey Van Weyden ...... Kerry Shale Recorded at the BBC's Paris Studio in Lower Regent Street, SAT 00:30 The Brightonomicon (b00fksh6) Mugridge ...... Ian Dury London. Announcer: Douglas Smith The Concluding Chaotic Conundrum of the Coldean Cat Kelly ...... Norman Jones Round The Horne was born out of the demise of BBC radio Can Rizla survive with only a messiah for company? Fantastical Smoke ...... Anthony Jackson comedy Beyond Our Ken, after the end of writer Eric comic serial with David Warner and Rupert Degas. Latimer ...... Peter Penry-Jones Merriman's involvement. Using the same cast and producer, SAT 01:00 W Somerset Maugham - Ashenden, Gentleman Horner ...... Clarence Smith Barry Took and Marty Feldman were persuaded to write the Spy (b008ggv1) Henderson ...... Andrew Wincott scripts - which led to four series that ran between 1965 and Giulia Lazzari Maud Brewster ...... Shelley Thompson 1968 - packed full of parodies, recurring characters, Agent Ashenden's summoned to a Paris hotel and tasked with Telefson .....
    [Show full text]
  • Ag 17 March 2021
    Since Sept 27 1879 Wednesday, March 17, 2021 $2.20 Court Another news P7 M. bovis case P10 MIDWEEK Bringing home the bacon PHOTO LAURA BAGRIE 70 million dollar dream Proposed Lake Hood sports campus gets serious Ph 03 307 7900 to subscribe! 2 NEWS Ashburton Guardian Wednesday, March 17, 2021 Hinds pool goes to the dogs Dottie the bulldog was one of the dozen dogs that enjoyed a dip at Hinds Community Pool at the weekend. It was the end of the pool season, but before the pool drained for the colder months, the Hinds pool committee thought it would be a fun thing to do for the dog owners in the community to let their pooches plunge in the pool. According to her owner, pool committee member Sarah Wakelin, Dottie had a great time at the pool although being a bulldog she sinks more than swims, but loved to splash around. The Hinds pool will go to the dogs again this Sunday – from 12 noon to 2pm. PHOTO LAURA BAGRIE Above – This pooch looks blissful as it enjoys a dip at the Hinds Community Pool. Thunder struck Firefighters were called to an area near Fairton after lightning splintered a tree, causing a nearby pump shed to fume. Fire and Emergency (Fenz) confirmed the strike caused smoking to the shed at a property near the intersection of Works Road and State Highway 1. A local farm manager said the strike splintered a tree, causing a current to travel to the shed about 40 metres away. Smoke could still be seen about 20 minutes later.
    [Show full text]
  • Ultimateregeneration1.Pdf
    First published in England, January 2011 by Kasterborous Books e: [email protected] w: http://www.kasterborous.com ISBN: 978-1-4457-4780-4 (paperback) Ultimate Regeneration © 2011 Christian Cawley Additional copyright © as appropriate is apportioned to Brian A Terranova, Simon Mills, Thomas Willam Spychalski, Gareth Kavanagh and Nick Brown. The moral rights of the authors have been asserted. Internal design and layout by Kasterborous Books Cover art and external design by Anthony Dry Printed and bound by [PRINTER NAME HERE] No part of this book may be reproduced in any form, by photocopying or by any electronic or mechanical means, including information storage or retrieval systems, without permission in writing from both the copyright owner and the publisher of this book. This book is sold subject to the condition that it shall not by way of trade or otherwise, be lent, resold, hired out or otherwise circulated without the publisher’s prior written consent in any form binding or cover other than that in which it is published for both the initial and any subsequent purchase. 2 ABOUT THE AUTHOR Christian Cawley is a freelance writer and author from the north east of England who has been the driving force behind www.kasterborous.com since its launch in 2005. Christian’s passion for Doctor Who and all things Time Lordly began when he was but an infant; memories of The Pirate Planet and Destiny of the Daleks still haunt him, but his clearest classic Doctor Who memory remains the moment the Fourth Doctor fell from a radio telescope… When the announcement was made in 2003 that Doctor Who would be returning to TV, Christian was nowhere to be seen – in fact he was enjoying himself at the Munich Oktoberfest.
    [Show full text]
  • Local Election Results 2008
    Local Election Results May 2008 Andrew Teale August 15, 2016 2 LOCAL ELECTION RESULTS 2008 Typeset by LATEX Compilation and design © Andrew Teale, 2012. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License”. This file, together with its LATEX source code, is available for download from http://www.andrewteale.me.uk/leap/ Please advise the author of any corrections which need to be made by email: [email protected] Contents Introduction and Abbreviations9 I Greater London Authority 11 1 Mayor of London 12 2 Greater London Assembly Constituency Results 13 3 Greater London Assembly List Results 16 II Metropolitan Boroughs 19 4 Greater Manchester 20 4.1 Bolton.................................. 20 4.2 Bury.................................... 21 4.3 Manchester............................... 23 4.4 Oldham................................. 25 4.5 Rochdale................................ 27 4.6 Salford................................. 28 4.7 Stockport................................ 29 4.8 Tameside................................. 31 4.9 Trafford................................. 32 4.10 Wigan.................................. 34 5 Merseyside 36 5.1 Knowsley................................ 36 5.2 Liverpool................................ 37 5.3 Sefton.................................. 39 5.4 St Helens................................. 41 5.5 Wirral.................................. 43 6 South Yorkshire 45 6.1 Barnsley................................ 45 6.2 Doncaster............................... 47 6.3 Rotherham............................... 48 6.4 Sheffield................................ 50 3 4 LOCAL ELECTION RESULTS 2008 7 Tyne and Wear 53 7.1 Gateshead............................... 53 7.2 Newcastle upon Tyne........................
    [Show full text]
  • Eastenders Goes Live
    explore.gateway.bbc.co.uk/ariel THE BBC NEWSPAPER 09·02·10 Week 6 PHOTOGRAPH: ADRIAN WEINBRECHT PHOTO COMPOSITION: JAMIE CURREY a Happy birthday? EastEnders goes live - p8-9 216 News aa 00·00·08 09·02·10 a Collaboration and better use of social media will alter ways of working Horrocks tells journalists Room 2316, White City 201 Wood Lane, London W12 7TS 020 8008 4222 Editor change is coming, embrace it Candida Watson 02-84222 Deputy editor by Kate Arkless Gray Cathy Loughran 02-27360 Chief writer PETER HORROCKS, DIRECTOR of Global News, Sally Hillier 02-26877 has issued a challenge to BBC journalists – em- Features editor brace change, accept collaboration and make Clare Bolt 02-27445 use of new information sources like social Broadcast Journalists media, or re-consider what you are doing. Claire Barrett 02-27368 Delivering the keynote speech at the Global Adam Bambury 02-27410 News Creative Network ‘Fit for the Future’ ses- AV Manager sion in Bush House, (run in conjunction with Peter Roach 02-24622 the College of Journalism) Horrocks said BBC Art editor journalism needed to be more collaborative and make better use of the resources offered by Ken Sinyard 02-84229 sites like Twitter. He said there must be a cul- Digital Design Executive tural shift to take account of the way technol- David Murray 02-27380 ogy is changing both the job and the way audi- ences relate to output. He drew on his experiences as a former News- night editor to highlight the contrast between Guest contributors this week the programme-based mindset, and his vision of a more open and sharing culture in future.
    [Show full text]
  • 2001-Pages.Pdf
    SERGEANT _JOHN As the election reaches fever pitch, ITN's political editor is in his element, although he admits he might be overdosing.Just as well then that he's got a comedic side to keep him - and us - sane ... "I stopped calling Blair 'Tony' when he became PM" As we proceed towards election day, this?' I had a fantasy I'd be left on a desert island and have to ITV Election 200 Thursday ITV pummelled by humbug, tawdry gimmicks, reinvent everything, so I did a lot of science and was obsessed and some idealism, there are few more to quite an alarming extent thinking I'd have to know how the amiable and authoritative guides than the slightly dishevelled, petrol engine works, and so on. I'd love not to have been like wispy-haired 56-year-old who started his career as a stand-up that, but it's a neurosis. My father [a parson] was an obsessive comedian, spent 30 years with the BBC, and is now ITN's politi- in a different way, an intellectual who learnt 30 languages. I cal editor, on screen daily during the campaign between eight asked him in my early twenties, 'Dad, have you been a suc- in the morning and 10.30 at night. "It's a great buzz moment cess?' and he replied, 'Of course. Because I'm your father,' for all of us," he says, admitting he retains undiminished which was neat because it works on so many different levels: enthusiasm and a heroic - some might say naive or self-serving either, 'Don't ask me that, you cheeky bugger,' or 'If you ques- - lack of cynicism, even though this is the ninth election he tion me, you question yourself.' He was a clever man, but has covered.
    [Show full text]
  • Analysing the Language of Television the Case of Media Cockney
    Analysing the language of television The case of Media Cockney Claire Timmins and Jane Stuart-Smith Department of English Language University of Glasgow Fachbereich Literatur- und Sprachwissenschaften Universität Hannover 15 November 2004 Analysing the language of television The case of Media Cockney Paper overview This paper investigates the linguistic, and specifically, phonetic nature of popular television shows set in London (media- Cockney), namely Only Fools and Horses, The Bill, and EastEnders. All three shows topped viewing ratings for their genre at the time of our data collection (spring 2003), and were also very popular with our informants. Note that the results for GOOSE/FOOT for Kat and Alfie are based on very small numbers of tokens. Subsequent measurements of these vowels from another episode confirm our findings, and will be incorporated into the written version of the paper. JSS/CT 31/03/05 Analysing the language of television The case of Media Cockney • Why analyse accents portrayed on television? • Previous research on represented accents • ‘media-Cockney’ – the accent of television shows set in London • Our sample: police drama; comedy; soap • Methods •Results • Concluding remarks Background: TV and accent change • traditional view: sociolinguists deny effect of watching popular television on accent change, insist on face to face interaction as mechanism (e.g. Milroy and Milroy 1985) BUT • speculations about a possible role for television (e.g. Bayard 1990 on New Zealand English) AND • recent findings in British English accents provoke discussion of the topic (e.g. Williams and Kerswill 1999) The Glasgow problem • least geographically mobile, working-class adolescents in Glasgow, Scotland • using accent features typical of South East/London English, e.g.
    [Show full text]
  • Cache/Sample
    Templates In the last chapter, you saw how to take a well-formed HTML document and turn it into a stylesheet by adding the XSLT elements <xsl:value-of> and <xsl:for-each> to pick out information from a source XML document and produce an HTML result. The stylesheets that we looked at were simplified stylesheets. Simplified stylesheets are good as a starting point when you're creating a stylesheet, and they can be all you need in some cases. However, to utilize the more sophisticated functionality of XSLT, you need to use full stylesheets. In this chapter, we'll take the simplified stylesheet that we developed during the last chapter and turn it into a full stylesheet. I'll also introduce you to templates as a way of breaking up your code and look in a bit more detail at how XSLT processors construct a result from some source XML. You'll learn: ❑ What full stylesheets look like ❑ How the XSLT processor navigates the source document to create a result ❑ How to break up your code into separate templates ❑ How templates help with document-oriented and unpredictable XML ❑ How to create tables of contents in your pages using template modes XSLT Stylesheet Structure The simplified stylesheets that we used in the last chapter are a specialized form of stylesheet that make a good starting point when we're creating an XSLT stylesheet. Simplified stylesheets aren't all that common in larger applications because they're fairly restricted in what they can do, especially with document-oriented XML. Technically, simplified stylesheets are defined in the XSLT Recommendation in terms of how they map on to full stylesheets.
    [Show full text]
  • Gjf% " I Can ' Tthinkofanyothershowt Hatcouldcombineallthe Se Elements and St
    "I can't think of any other show ^gjf% that could combine all these elements and still make sense" DAVID TENNANT A bus-smash in Dubai, an alien fly and Michelle Ryj in a catsuit - it's all go in the Doctors 200th story! Doctor Who time, they'll still remember 'the one with the 1* Saturday 6.45pm BBC1, BBC HD - and a red double-decker seems so Brit.! which is always one of Doctor Who's strengths! T'S SAFE TO say that of all the unfortunate "It's a barmy adventure," says David Tennant things that could happen to a film crew in sheltering from the sandstorm under a violently the desert, getting caught in a sandstorm flapping gazebo. "It's quite 'out there'. A Londl - rendering a whole day's footage practi­ bus in the middle of the desert kind of sets, cally unusable - would be one of the worst. tone. It's not a plot that ai. show could do. IIt's 12 February 2009, and the BBC crew filming It's very specifically a Doctor Who story. I can't this year's Doctor Who Easter special, Planet of think of any other show that could combine al the Dead, is experiencing the worst sandstorm to these elements and still make sense!" hit Dubai since last September. But that's the The production team's first hurdle was to g least of their recent problems... the bus into the desert. "We'd always looked at It all began with a red London bus. "That bus going abroad," explains producer Trade Simpson.
    [Show full text]
  • BBC Annual Report and Accounts 2001/2002
    BBC Annual Report and Accounts 2001/2002 This BBC Annual Report and Accounts is available in public libraries throughout the UK and on the BBC’s website at www.bbc.co.uk/info. It is also available in Welsh, in an audio version, in Braille and in a version tailored for people with learning difficulties. We also publish the BBC Statements of Programme Policy, setting out the BBC’s objectives and plans for the coming year.This is available in public libraries and on the BBC’s website at www.bbc.co.uk/info. It is available in Welsh, in an audio version and in Braille. Annual Reviews of BBC Scotland, BBC Wales, BBC Northern Ireland and BBC English Regions are published simultaneously with this document, as is the Annual Review of the BBC World Service. The BBC’s wholly-owned commercial subsidiaries, BBC Worldwide Limited and BBC Ventures Group (BBC Broadcast Limited, BBC Resources Limited, BBC Technology Holdings Limited and Kingswood Warren Ventures Limited) trade at arm’s length from the BBC and their accounts are independently audited.This Annual Report includes a summary of their activities in 2001/2002. Copies of any of these publications may be obtained by writing to The Secretary, BBC, Broadcasting House, London W1A 1AA. This publication has been printed using waterless technology which eliminates the combination of harmful solvents and polluting water.The inks and varnishes are soya-based and are 100% free of mineral oils and harmful emissions from volatile organic compounds.The paper is made from 50% totally chlorine-free pulp from plantation forests, and from 50% recycled and de-inked fibres, and any wastage in the finishing process has been addressed and minimised.
    [Show full text]