xsl-list
[Top] [All Lists]

commenting in xslt

2005-04-27 00:40:29
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="{(_at_)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. 
-- 
Bryan Rasmussen






--~------------------------------------------------------------------
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>
--~--



<Prev in Thread] Current Thread [Next in Thread>
  • commenting in xslt, Bryan Rasmussen <=