[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] xsl:choose and xsl:when


Subject: Re: [xsl] xsl:choose and xsl:when
From: oryann9 <oryann9@xxxxxxxxx>
Date: Thu, 30 Aug 2007 06:43:40 -0700 (PDT)

--- Abel Braaksma <abel.online@xxxxxxxxx> wrote:

> [somehow this didn't reach the list, retry. probably
> outdated now though..]
> 
> Hi Oryan,
> 
> see my comments,
> 
> Cheers,
> Abel
> 
> oryann9 wrote:
> > <?xml version="1.0" ?>
> > <xsl:stylesheet version="1.0"
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> > <xsl:output method="html"/>
> > <xsl:template match="/">
> >      <HTML>
> >      <HEAD>
> >      <TITLE>My Phone Book</TITLE>
> >      </HEAD>
> >      <BODY BGCOLOR="BLACK">
> >           <xsl:apply-templates select="//LISTING"
> />
> >   
> 
> You probably want just LISTING here. You are
> selecting every possible
> LISTING from the root through all the document when
> you use //LISTING.
> 
> >      </BODY>
> >      </HTML>
> > </xsl:template>
> > <xsl:template match="LISTING">
> >      <FONT COLOR="WHITE"><xsl:value-of
> > select="LAST"/>,
> >           <xsl:value-of select="FIRST"/></FONT>
> >      <FONT COLOR="orange" SIZE="+2"><xsl:value-of
> > select="PHONE"/>
> > <xsl:choose>
> >       <xsl:when test="boolean(PHONE/@TYPE)">
> >            (<xsl:value-of select="PHONE/@TYPE" />)
> >   
> 
> No need for an xsl:choose. In almost all cases that
> I've seen on this
> list, xsl:choose is over-used, because it feels so
> easy (or looks so
> much like in the other programming languages).
> Instead, use:
> 
> <FONT COLOR="orange" SIZE="+2">
>     <xsl:apply-templates select="PHONE" />
> 
> then, have twotemplate matches (one for empty or
> non-existing @TYPE, the
> other for all other @TYPE):
> 
> <xsl:template match="PHONE[@TYPE='' | not(@TYPE)]" >
>     <xsl:value-of select="."/> (HOME)
> </
> 
> <xsl:template match="PHONE[@TYPE != '']">
>     <xsl:value-of select="."/> (<xsl:value-of
> select="PHONE/@TYPE" />)
> </
> 
> 

Hi to all!
I thank you all very much for all the assistance you
have provided since I am new to XSL(T).
Allow me some more time to absorb and practice what
was sent. :)


       
____________________________________________________________________________________
Choose the right car based on your needs.  Check out Yahoo! Autos new Car Finder tool.
http://autos.yahoo.com/carfinder/


Current Thread