This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: HTML tag inside <xsl:when></xsl:when> tag
- From: Mike Brown <mike at skew dot org>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Wed, 20 Feb 2002 10:29:15 -0700 (MST)
- Subject: Re: [xsl] HTML tag inside <xsl:when></xsl:when> tag
- Reply-to: xsl-list at lists dot mulberrytech dot com
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