Condividi tramite


Elemento <xsl:comment>

Genera un commento nell'output.

<xsl:comment>
</xsl:comment>

Informazioni sull'elemento

Numero di occorrenze

Illimitato

Elementi padre

xsl:copy, xsl:element, xsl:fallback, xsl:for-each, xsl:if, xsl:message, xsl:otherwise, xsl:param, xsl:template, xsl:variable, xsl:when, xsl:with-param, elementi di output

Elementi figlio

xsl:apply-imports, xsl:apply-templates, xsl:call-template, xsl:choose, xsl:copy, xsl:copy-of, xsl:fallback, xsl:for-each, xsl:if, xsl:message, xsl:number, xsl:text, xsl:value-of, xsl:variable

Note

Il testo generato dagli elementi figlio di <xsl:comment> è contenuto tra i caratteri iniziali (<!--) e quelli finali (-->).

Esempio

Nell'esempio seguente, il foglio di stile news.xsl consente di trasformare il documento news.xml e di inserire un commento nell'output XSLT.

File XML (news.xml)

<?xml version ="1.0"?>
<?xml-stylesheet type="text/xsl" href="news.xsl"?>
<news>
<story1>Here is the top news story.</story1>
    <story2> Here is the next news story.</story2>
</news>

File XSLT (news.xsl)

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >

<xsl:template match="/">
<HTML>
<BODY>
<xsl:comment>insert top news story</xsl:comment>
<P>
<xsl:value-of select="//story1"/>
</P>
</BODY>
</HTML>
</xsl:template>

</xsl:stylesheet>

Output

L'output formattato è il seguente:

Here is the top news story.

L'output del processore è il seguente:

<HTML>
<BODY><!--insert top news story-->
<P>Here is the top news story.</P>
</BODY>
</HTML>