xsl-list
[Top] [All Lists]

[xsl] commenting an XML element [XSLT 1.0][xsltproc]

2010-08-18 05:53:13
Hello all,

I am trying to comment one of the empty element (<spec/>) in my xml tree 
but seems I am missing something.


My stylesheet look something below:

<xsl:template match="spec">
        <xsl:comment>
           <xsl:apply-templates select="self::*" mode="comment"/>
     </xsl:comment>
</xsl:template>

   <xsl:template match="*" mode="comment">
        <xsl:value-of select="'&lt;'"/>
            <xsl:value-of select="name()"/>
        <xsl:value-of select="'&gt;'"/>
            <xsl:apply-templates select="@*|node()" mode="comment" />
        <xsl:value-of select="'&lt;/'"/>
            <xsl:value-of select="name()"/>
        <xsl:value-of select="'&gt;'"/>
    </xsl:template>

    <xsl:template match="text()" mode="comment">
        <xsl:value-of select="."/>
    </xsl:template>

    <xsl:template match="@*" mode="comment">
        <xsl:value-of select="name()"/>
        <xsl:text>="</xsl:text>
        <xsl:value-of select="."/>
        <xsl:text>" </xsl:text>
    </xsl:template>

This is what I get using xsltproc (MAC)

Error:
element text
misplaced text element

Any ideas please.

PS: I do have my identity transform defined in stylesheet.

TIA,
Pankaj

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--