[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: "Thomas B. Passin" <tpassin@xxxxxxxxxxxx>
Date: Wed, 20 Feb 2002 10:18:39 -0500
xsl a tag
[Matts Isuls]>
> 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>
>
> ^-no go
>
> <xsl:choose>
>   <xsl:when test="ss:Data/@ss:Type = 'Number'">
>     <xsl:text><td align="right"></xsl:text>
>   </xsl:when>
>   <!--snip-->
> </xsl:choose>
>
> ^-still nothing
>
> <xsl:choose>
>   <xsl:when test="ss:Data/@ss:Type = 'Number'">
>     &#60;td align="right"&#62;
>   </xsl:when>
>   <!--snip-->
> </xsl:choose>
>
> ^-hmmm now what?
>
>

What you have to keep in mind is that you are writing well-formed xml, even
if you will produce html at the end.  When you put a start tag within
another element, in this case xsl:when, the close tag for that element has
to be nested properly within that element as well.  There is no way around
that, since it is an inherent characteristic of xml (I won't talk about
faking it with disable-output-escaping, which will not be needed here in any
way, shape, or form).

Some people can see this more easily by thinking about the tree that is
constructed by the processor- each node may contain other nodes.  A node
cannot contain part of another node - it's all or nothing.  The xsl:when can
either contain a whole, intact td element or not, but it cannot contain half
of a td element.

You just have to rearrange your thinking a little and get the end tag for
the <td> into the same parent element.  If you think that you need to split
the element, you do not yet understand clearly what you really want to
accomplish, but it should quickly get clear.

Cheers,

Tom P


 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.