Quick References
      ADO
      ASP
      CSS2
      HTML
      JavaScript
      Jet SQL
      VBScript
      WML
      WMLScript
      WSH
      XHTML
      XML DOM
      XSLT

Features
      Knowledge Base
      Tutorials

Partners
     ZVON.ORG
     XML
     Planet Source Code
     VisualBuilder
     Web Design
     Your HTML Source
     XML/XSLT Forums
     ASPAlliance
     Scripts
     
     Programmers Heaven
     Tek-Tips Forums
     Developer Fusion
     Code Project


   







ELEMENT:  xsl:text

<xsl:text
  disable-output-escaping="yes" | "no"
>
</xsl:text>

 
The xsl:text element is used to add literal text to the output. This element cannot contain any other XSL elements. It can only contain text.
 
Normally, any text that occurs in a stylesheet will be copied to the output regardless if it is enclosed by an xsl:text element. However, there are two primary reasons for using the xsl:text element:
 
  • The first is to control white-space. Extra white-space is preserved by using this element. In other words, a text will be displayed as it really is without any extra white-spaces being removed.

  •  
  • The second is to handle special characters such as an ampersand (&) or a greater-than sign (>). For example, you may wish a &gt; to be displayed as a >. This is referred to as controlling output escaping.

  •  
    This is not a self-closing element. The separate closing element is mandatory.
     
    disable-output-escaping="yes" | "no"
     
    The optional disable-output-escaping attribute turns on or off the ability to escape special characters. If set to no, a &gt; will appear as a &gt; in the text. If set to yes, a &gt; will appear as a >. (This attribute should be used with care. Remember that XML requires a well-formed code in that all tags or elements must be closed. If set to yes, you could accidentally create a non-well-formed document.)
     
    We use the DevGuru Staff List XML file for our example with the following header:
    <?xml-stylesheet type="text/xsl" href="xslt_example_text.xsl"?>
    and we name it: xslt_example_text.xml
     
    Code for xslt_example_text.xsl:
     
    <?xml version="1.0"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html" />
    <xsl:template match="/">
    <html>
    <body>
    <xsl:text>The DevGuru Staff Members are < /xsl:text>
    <xsl:for-each select="devguru_staff/programmer">
    <xsl:value-of select="name" />
    <xsl:if test="position()!=last()">
    <xsl:text>, </xsl:text>
    </xsl:if>
    <xsl:if test="position()=last()-1">
    <xsl:text> and </xsl:text>
    </xsl:if>
    <xsl:if test="position()=last()">
    <xsl:text>!</xsl:text>
    </xsl:if>
    </xsl:for-each>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>

     
    Output:
     
    Click to view output in separate window - requires Internet Explorer

     
     


    Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
    Trademark Information