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

commenting in xslt2.0 - input-subtree to ouput-comment

Subject: commenting in xslt2.0 - input-subtree to ouput-comment
From: Siegfried Baiz <baiz@xxxxxxxxx>
Date: Mon, 23 May 2005 13:14:07 +0200
xslt copy comment
Hi,

is it possible to create an xml comment in the XSLT-output
which consists of a complete subtree of the xml-input-document?
Im using XSLT 2.0.

I've been trying things like:
   <xsl:comment>
       <xsl:copy-of select="//section[3]"/>
   <xsl:comment>
but but never got the desired output like:
   <!--
       <section>... please comment the section in ...<section/>
   -->

Siggi



Bryan Rasmussen wrote:

Hi,
I just had an idea about how to write useful comments in XSLT (which I very
seldomly see), it struck me that what one needs to see in a complex transform is
a comment that explains the expected input and the expected output, the reason
being that the input is in a format that the developer working with the xslt
might not know, or even if they have developed the stylesheet themselves might
not remember the expected input, so:

<xsl:template match="x:*[starts-with(@type,'payment')][1]">

<!--
if input = <x:restrictive type="paymentdue" amount="$500"/>
the output will be <div class="paymentdue" onclick="calculator(paymentdue,500)">
paymentdue for $500
</div>


the various types of class expected are paymentdue, paymentmade, paymentpast



-->
<div class="{@type}"
onclick="calculator({concat(@type,',',substring(@amount,2,string-length(@amount)-1))})">
<xsl:value-of select="concat(@type,' for ',@amount)"/>
</div>
</xsl:template>

yes I know this is not a particular good way to structure ones output, it's a
spur of the moment example. Obviously the comment could be done as an xml
fragment, so
<!--
<doc:fragment>
<doc:input>
<x:restrictive type="paymentdue" amount="$500"/>
</doc:input>
<doc:output>
<div class="paymentdue" onclick="calculator(paymentdue,500)">
paymentdue for $500
</div>

</doc:output>
<doc:remarks>
the various types of class expected are paymentdue, paymentmade, paymentpast
</doc:remarks>
</doc:fragment>
-->

I haven't defined any namespaces for the examples.

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.