[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: commenting an XML element [XSLT 1.0][xsltproc]

Subject: Re: commenting an XML element [XSLT 1.0][xsltproc]
From: pankaj.c@xxxxxxxxxxxxxxxxxx
Date: Wed, 18 Aug 2010 18:16:59 +0530
Re:  commenting an XML element [XSLT 1.0][xsltproc]
Thanks again Martin for looking into it.

I tried testing it with below stylesheet, now complete one but with same 
error. Something is terribly missing in code.

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

    <!--Identity transform copies all items by default -->
    <xsl:template match="@* | node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="colspec">
        <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>

</xsl:stylesheet>

Just for reference, below is the sample xml


<?xml version="1.0" encoding="UTF-8"?>
<!-- New document created with EditiX at Wed Aug 18 17:37:11 IST 2010 -->
<root>
<table id="t0010" frame="topbot" rowsep="0" colsep="0">
<label>Table 3-1</label>
<caption>
<simple-para id="sp0200" role="title">This is a dummy title.</simple-para>
<simple-para id="sp0210">Ranjan</simple-para>
</caption>
<source>Source if present.</source>
<tgroup cols="2">
<colspec colname="col1"/>
<colspec colname="col1"/>
<colspec colname="col2"/>
<thead valign="top">
<row>
<entry rowsep="1" align="left">Abbreviation</entry>
<entry rowsep="1" align="left">Dosage Interval</entry>
</row>
</thead>
<!-- More code here 
-->
</tgroup>
</table>
</root>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.