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

Re: Append Attribute

Subject: Re: Append Attribute
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Sun, 14 Nov 2004 09:03:29 -0500
xsl append
At 2004-11-13 07:18 -0800, Karl J. Stubsjoen wrote:
Using xsl:attribute (or similar), is there a way to append an attribute to
an existing attribute set?

No. Every time you define an attribute value it will replace any pending attribute value for the currently open set of specified attributes. I'm assuming when you say "attribute set" you are speaking of the open set of specified attributes and not the XSLT "attribute-set" construct.


Example:
  <div class="my_div">
      <xsl:attribute name="class">big_font</xsl:attribute>
  </div>

Desired Output:
  <div class="my_div big_font">
  </div>

Assuming that your <xsl:attribute/> is embedded in some testing logic (otherwise you would have explicitly added it), my recommendation would be to use the attribute instruction for all of the properties with the logic as follows (note the spacing inside the <xsl:text>):


  <div>
    <xsl:attribute name="class">
      <xsl:text>my_div</xsl:text>
      <xsl:if test="$mytest">
        <xsl:text> big_font</xsl:text>
      </xsl:if>
      <xsl:if test="$myothertest">
        <xsl:text> other_property</xsl:text>
      </xsl:if>
    </xsl:attribute>
    ...
   </div>

Since all attributes need to be added before any content, the above should not be disruptive to the flow of logic you would need if such a thing as an append existed ... which it does not.

I hope this helps.

.................... Ken

--
World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

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.