O'Reilly logo

XML and Java™ from scratch by Nicholas Chase

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Conditionals

Now that we've begun to take control of the flow of our document by using looping, it's time to take even tighter control by adapting to the data itself.

We can output different data and differently formatted data based on the data itself. In this case, we're going to use the webvendor attribute of the vendor elements, displaying all information for vendors with a webvendor attribute of full, displaying only some information for those with a webvendor attribute of partial, and not displaying at all those with a webvendor attribute of no.

This last is easy. In Listing 2.28, we'll instruct the processor not to output any text unless the webvendor attribute is something other than “no.”

Listing 2.28. catalog.xsl: A Simple Conditional ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required