Summary Templates are particularly suited to processing document-oriented XML. Each template acts in Font

Drawer PDF417 in Font Summary Templates are particularly suited to processing document-oriented XML. Each template acts

Summary Templates are particularly suited to processing document-oriented XML. Each template acts
PDF-417 2d Barcode Printer In None
Using Barcode printer for Font Control to generate, create PDF 417 image in Font applications.
www.OnBarcode.com
Code 39 Extended Creator In None
Using Barcode creator for Font Control to generate, create Code 39 Extended image in Font applications.
www.OnBarcode.com
as a mapping rule from input to result.
Encode ECC200 In None
Using Barcode creator for Font Control to generate, create Data Matrix image in Font applications.
www.OnBarcode.com
Generating Barcode In None
Using Barcode drawer for Font Control to generate, create Barcode image in Font applications.
www.OnBarcode.com
Creating Presentation Rules
Making EAN 13 In None
Using Barcode drawer for Font Control to generate, create GS1 - 13 image in Font applications.
www.OnBarcode.com
Printing Barcode In None
Using Barcode maker for Font Control to generate, create Barcode image in Font applications.
www.OnBarcode.com
We can add support for lots of different elements that we want to be able to use within the <Description> element. Highlighting character names and providing links to other web sites is useful, but you might also want to add elements for emphasis, foreign words, names of directors, series, channels, films, and so on different elements for TV programs and series.
Code 128C Printer In None
Using Barcode printer for Font Control to generate, create Code 128 Code Set A image in Font applications.
www.OnBarcode.com
Paint ISBN In None
Using Barcode generation for Font Control to generate, create ISBN - 10 image in Font applications.
www.OnBarcode.com
CHAPTER 3 TEMPLATES
PDF417 Creator In Java
Using Barcode creator for Java Control to generate, create PDF417 image in Java applications.
www.OnBarcode.com
Print PDF-417 2d Barcode In None
Using Barcode drawer for Font Control to generate, create PDF 417 image in Font applications.
www.OnBarcode.com
We ll add just a few of these elements in TVGuide2.xml, to create TVGuide3.xml, shown in Listing 3-5. Listing 3-5. TVGuide3.xml < xml version="1.0" encoding="ISO-8859-1" > <TVGuide start="2001-07-05" end="2001-07-05"> <Channel> <Name>BBC1</Name> ... <Program rating="5" flag="favorite"> <Start>2001-07-05T19:30:00</Start> <Duration>PT30M</Duration> <Series>EastEnders</Series> <Title></Title> <Description> <Character>Mark</Character>'s health scare forces him to reconsider his future with <Character>Lisa</Character>, while <Link href="http://www.bbc.co.uk/eastenders/characters/jamie_m_biog.shtml"> <Character>Jamie</Character> </Link> is torn between <Character>Sonia</Character> and <Character>Zoe</Character>. </Description> <CastList> <CastMember> <Character> <Name>Zoe Slater</Name> <Description> The youngest Slater girl, <Character>Zoe</Character> really makes the most of the fact she's the baby of the family. </Description> </Character> <Actor> <Name>Michelle Ryan</Name> <Description> For more details, see <Link href="http://www.ajmanagement.co.uk/michelle-ryan.htm"> <Actor>Michelle Ryan</Actor>'s Agency </Link>. </Description> </Actor> </CastMember> <CastMember> <Character> <Name>Jamie Mitchell</Name> <Description> Jamie's a bit of a heartthrob (who could resist that little-boy-lost look ) but until <Character>Janine
Decoding UPC - 13 In None
Using Barcode scanner for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
Draw Barcode In Visual Studio .NET
Using Barcode encoder for ASP.NET Control to generate, create Barcode image in ASP.NET applications.
www.OnBarcode.com
CHAPTER 3 TEMPLATES
QR-Code Scanner In .NET
Using Barcode recognizer for VS .NET Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
Barcode Recognizer In Java
Using Barcode Control SDK for BIRT Control to generate, create, read, scan barcode image in Eclipse BIRT applications.
www.OnBarcode.com
Butcher</Character> came along he'd steered clear of girls. </Description> </Character> <Actor> <Name>Jack Ryder</Name> <Description> Won Best Newcomer for <Character>Jamie Mitchell</Character> in the 1999 TV awards. </Description> </Actor> </CastMember> <CastMember> ... </CastMember> </CastList> ... </Program> ... </Channel> ... </TVGuide> Try using TVGuide6.xsl with TVGuide3.xml, which uses <xsl:apply-templates> to apply templates to the <Description> element. There aren t any templates for <Character> or <Link> elements, so the built-in templates are used instead. The result of the transformation of the <Description> element looks just the same as before, because the built-in templates automatically show any text within an element. We want a new version of the stylesheet (TVGuide8.xsl), which generates HTML where the words and phrases in the description that we ve picked out with <Character> and <Link> elements are displayed and behave slightly differently from the rest of the text. Links should be links, for example, and character names should be slightly larger than the surrounding text. To make the marked-up text display and act differently, we need to introduce templates for these new elements: one for the <Link> element, to create a hypertext link with an HTML <a> element: <xsl:template match="Link"> <a href="{@href}"><xsl:apply-templates /></a> </xsl:template> and one for the <Character> element, to create a <span> element with a class of character around the character names: <xsl:template match="Character"> <span class="character"><xsl:apply-templates /></span> </xsl:template> To make the character names slightly bigger, we ll add a rule to TVGuide.css, to create TVGuide2.css, which contains .character { font-size: larger; }
UCC-128 Printer In None
Using Barcode printer for Software Control to generate, create EAN 128 image in Software applications.
www.OnBarcode.com
Recognize EAN / UCC - 13 In Visual C#
Using Barcode decoder for .NET framework Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
CHAPTER 3 TEMPLATES
Create Barcode In Java
Using Barcode encoder for Android Control to generate, create Barcode image in Android applications.
www.OnBarcode.com
1D Barcode Maker In Visual Basic .NET
Using Barcode creator for Visual Studio .NET Control to generate, create Linear image in Visual Studio .NET applications.
www.OnBarcode.com
Putting the final touches on TVGuide8.xsl, we need the HTML that it creates to point to TVGuide2.css rather than TVGuide.css, so the <link> element generated in the template matching the document node needs to be altered slightly: <xsl:template match="/"> <html> <head> <title>TV Guide</title> <link rel="stylesheet" href="TVGuide2.css" /> ... </head> ... </html> </xsl:template> Having made this final change, transform TVGuide3.xml with TVGuide8.xsl. When viewed in a browser, the result of the transformation TVGuide8.html should look something like the screenshot shown in Figure 3-8.
Painting ANSI/AIM Code 39 In Objective-C
Using Barcode maker for iPad Control to generate, create USS Code 39 image in iPad applications.
www.OnBarcode.com
Paint UPC - 13 In Java
Using Barcode drawer for Java Control to generate, create GS1 - 13 image in Java applications.
www.OnBarcode.com
Figure 3-8. Viewing TVGuide8.html in Internet Explorer
The character names are slightly larger than the rest of the text, and clicking the word Jamie takes you to the EastEnders site with Jamie Mitchell s biography. Feel free to add your own elements to that description, and add your own templates matching them to present the document-oriented XML.
CHAPTER 3 TEMPLATES
Context-Dependent Processing
We ve now introduced a number of elements into our XML structure that we re actually using elsewhere in different ways. For example, we use the <Character> element to indicate the name of a character in a description, and to hold information about a character within the <CastMember> element. The template makes no distinction between these two uses of the <Character> element, and does the same thing for each, making a <span> element with a character class: <xsl:template match="Character"> <span class="character"> <xsl:apply-templates /> </span> </xsl:template> At the moment, we re also creating a <span> element when we create the cast list, in the template matching the <CastMember> element: <xsl:template match="CastMember"> <li> <span class="character"> <xsl:apply-templates select="Character" /> </span> <span class="actor"> <xsl:apply-templates select="Actor" /> </span> </li> </xsl:template> This means we end up with two <span> elements around the names of the characters in the cast list. We can get rid of the superfluous <span> element either by reverting back to using <xsl:value-of> to get the name of the character, or by removing the <span> element in the template that matches <CastMember> elements (and the same applies for the <Actor> elements as well, since we might name actors in a description): <xsl:template match="CastMember"> <li> <xsl:apply-templates select="Character" /> <xsl:apply-templates select="Actor" /> </li> </xsl:template> So now we have the same template being used to process <Character> elements in different contexts. However, one of the extensions that we made earlier in this chapter was to have the <Character> and <Actor> elements within <CastMember> actually give both a name and a description of the character. When we take this into account, we have a problem because we don t want the <span> element to contain both the name and the description of the character. We need a different template for the <Character> and <Actor> elements when they are children of <CastMember> elements (ones that just apply templates to the <Name> element child of the <Character> or <Actor> element). The new templates for the <Character> elements that occur in <CastMember> elements need to look like the following:
Copyright © OnBarcode.com . All rights reserved.