Previous | Next | Indexes
Zvon > Tutorials > XSLT 2.0 Tutorial > Comments and processing instructions (2/9) >

Comments with "--" string

If the text of comment contains "--" string, a space is automatically inserted between "-" characters as comments with "--" string cannot be used in well-formed XML documents.
XSLT

      <xsl:stylesheet
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  version="2.0">
            <xsl:output  method="xml"
                        indent="yes"
                        omit-xml-declaration="yes"/>

            <xsl:template  match="/aaa">
                  <bbb>
                        <ccc>
                              <xsl:comment>The comment containing "--" two "-" characters</xsl:comment>
                        </ccc>
                  </bbb>
                  <xsl:comment>------------------</xsl:comment>
            </xsl:template>

      </xsl:stylesheet>
XML

      <aaa/>
Output

      <bbb>
            <ccc><!--The comment containing "- -" two "-" characters--></ccc>
      </bbb> <!--- - - - - - - - - - - - - - - - - - -->


Previous chapter: Date and Time
Next chapter: Built in Types
Previous page: Comments
Next page: Comments based on source document