Subject: [xsl] commenting in xslt From: Bryan Rasmussen <bry@xxxxxxxxxx> Date: Wed, 27 Apr 2005 09:40:29 +0200 |
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. -- Bryan Rasmussen
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] xsl apply template is not, Michael Kay | Thread | [xsl] logic for writing two nested , RahilQ |
RE: [xsl] XSLT to conver flat XML t, sreekanth.gangula | Date | RE: [xsl] Should XSLT be used to ge, Pawson, David |
Month |