[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: HTML tag inside <xsl:when></xsl:when> tag

Subject: Re: HTML tag inside <xsl:when></xsl:when> tag
From: Mike Brown <mike@xxxxxxxx>
Date: Wed, 20 Feb 2002 10:29:15 -0700 (MST)
html tags inside xsl
Matts Isuls wrote:
> How do i go about writing a HTML tag inside a xsl:when. Have tried three
> different ways:
> 
> <xsl:choose>
>   <xsl:when test="ss:Data/@ss:Type = 'Number'">
>     <td align="right">
>   </xsl:when>
>   <!--snip-->
> </xsl:choose>

This is a FAQ. Don't think in terms of writing tags, because XSLT is not about 
slapping together a result document from serially pasted-together strings 
(well, it can be, if you use the text output method and only write out text 
nodes, but that's not what you want to do).

Generally when people ask questions about HTML tables, they've tried a 
tag-based approach, which inevitably fails because they are thinking about how 
to arbitrarily declare the beginning and end of each row. In the well-formed 
world of XML and XSLT, one needs a more object-oriented approach. If you break 
the problem down into the answers to these questions, you might see your 
solution more quickly: 

 - What always determines when a new row is added?
 - What always goes into each row?
 - What always goes into each cell?

It might also help if you turn things around ... rather than deciding whether
to create foo-sub-x or foo-sub-y based on some condition, create foo always,
and make the -sub-x or -sub-y be a choice made during instantiation of the
foo:

<td>
  <xsl:attribute name="align">
    <xsl:choose>
      <xsl:when test="ss:Data/@ss:Type = 'Number'">right</xsl:when>
      <xsl:otherwise>center</xsl:otherwise>
    </xsl:choose>
  </xsl:attribute>
</td>

   - Mike
____________________________________________________________________________
  mike j. brown, fourthought.com  |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  personal: http://hyperreal.org/~mike/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.