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

Re: Escaping within an xsl:attribute element

Subject: Re: Escaping within an xsl:attribute element
From: "Brett McLaughlin" <bmclaugh@xxxxxxxx>
Date: Thu, 9 Dec 1999 10:15:45 -0600
xsl attribute bgcolor
>
> > It all has to be within the xsl:attribute
>
> But your example stylesheet you posted was did _not_ have the code
> inside xsl:attribute.

Sorry, David, you've been helpful and I am confusing the matter because I
haven't had my morning coffee... it should have all been inside the
xsl:element, which makes more sense to you (I hope).  Once I replaced nowrap
with nowrap="nowrap", &nbsp; with &#160;, and pulled out the xsl-text
element (which I actually had already done), it transformed fine, with the
desired results.

>
> You can not have element markup inside attribute values in XML (or HTML)
> so there is no way to get elements into attribute values, irrespective
> of xsl syntax.

Right, again, that was my dumb typo :-(

>
> > <tr bgcolor="<something-defined-in-my-xml>">
>
> to get that you just want
>
> <tr bgcolor="{@color}">

Here's what it ended up looking like:

     <xsl:element name="tr">
      <xsl:attribute name="bgcolor">
       <xsl:value-of
select="/Portal:Page/Portal:Preferences/Portal:trimColor"/>
      </xsl:attribute>
      <td valign="bottom" align="left" nowrap="nowrap">
       <xsl:element name="font">
        <xsl:attribute name="face">
         <xsl:value-of
select="/Portal:Page/Portal:Preferences/Portal:fontFace"/>
        </xsl:attribute>
        <xsl:attribute name="color">
         <xsl:value-of
select="/Portal:Page/Portal:Preferences/Portal:trimFontColor"/>
        </xsl:attribute>
       <xsl:attribute name="size">
        <xsl:text>-1</xsl:text>
       </xsl:attribute>
        <b>
         &#160;&#160;&#160;Welcome,
         <xsl:value-of select="/Portal:Page/Portal:User/Portal:firstName"/>
         <xsl:text> </xsl:text>
         <xsl:value-of select="/Portal:Page/Portal:User/Portal:lastName"/>
         &#160;&#160;&#160;&#160;&#160;&#160;
        </b>
       </xsl:element>
      </td>
      <td align="right" colspan="2">
       <nobr/>
       &#160;
      </td>
     </xsl:element>

>
> or any other expression instea dof @color to extract the data from your
> input.

I wouldn't think I could do this because the value of color is defined in an
XML element, not an attribute, so I have to use an xsl:value-of to pull it
out of the document.  Of course, there may be a better way to do this and I
am more than open to it.

Thanks,
Brett


 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.