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

Re: Writing out '<', not '&lt;'.

Subject: Re: Writing out '<', not '&lt;'.
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 20 Sep 1999 16:39:57 -0400
xslt not lt
At 99/09/20 14:26 -0400, Michael.Scepaniak@xxxxxxxxxxxxx wrote:
I'd like to assign the string "<body bgcolor="White">" to an xsl:variable and
then output that variable as part of my HTML output, but I am unable to do it.

Correct ... you are unable to do it because you are attempting to add a string of text to the result tree and text content is, by default, escaped using typical XML and HTML mechanisms.


To get the result you desire, you must add a <body> element node with a bgcolor="White" attribute node to the result tree and not try to effect the result using a string.

Using a result tree template, this would be as easy as:

  <xsl:template match="/">
    <body bgcolor="white">
      <xsl:apply-templates/>
    </body>
  </xsl:template>

Using result tree instructions, this would be:

  <xsl:template match="/">
    <xsl:element name="body">
      <xsl:attribute name="bgcolor">white</xsl:attribute>
      <xsl:apply-templates/>
    </xsl:element>
  </xsl:template>

I hope this helps.

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

p.s. there *is* a technique to actually emit the "<" character from a string, but that technique is not portable across all XSLT engines because an engine is allowed to not implement the technique ... plus, what you want to do can be done without resorting to the technique.

--
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   (Fax:-0995)
Website:  XSL/XML/DSSSL/SGML services, training, libraries, products.
Practical Transformation Using XSLT and XPath      ISBN 1-894049-01-2
Next instructor-led training:  1999-09-24, 1999-11-08, 1999-12-05/06,
                             1999-12-07, 2000-02-27/28, 2000-05-11/12



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.