Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I need to display HTML-element in comments (for example)

<!-- <img src="path" width="100px" height="100px"/> -->

I use this approach

<?xml version="1.0" encoding="windows-1251"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="no" encoding="windows-1251"/>

    <xsl:template match="myNode">
        ...
        <xsl:comment><xsl:apply-templates select="image" /></xsl:comment>
        ...
    </xsl:template>

    <xsl:template match="image">
        <img src="{@src}" width="{@width}px" height="{@height}px" />
    </xsl:template>

</xsl:stylesheet>

As a result:

<!---->

that is the code in the element xsl:comment ignored.

How do I display an item in the comments?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
594 views
Welcome To Ask or Share your Answers For Others

1 Answer

It might be possible to replace

<xsl:comment><xsl:apply-templates select="image" /></xsl:comment>

with

<xsl:text disable-output-escaping="yes">&lt;!--</xsl:text>
<xsl:apply-templates select="image" />
<xsl:text disable-output-escaping="yes">--&gt;</xsl:text>

Haven't tried though.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...