[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] avoiding assignment statements


Subject: RE: [xsl] avoiding assignment statements
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 8 Dec 2006 16:07:18 -0000

In 2.0:

<xsl:value-of select="string-join(
    ('Reps'[$showreplicates=1], 'MetaData'[$showMetadata=1],
'Signatures'[$showElectronicSignature=1]),
     ', ')"/> 

Michael Kay
http://www.saxonica.com/


> -----Original Message-----
> From: scarleton@xxxxxxxxx [mailto:scarleton@xxxxxxxxx] On 
> Behalf Of Sam Carleton
> Sent: 08 December 2006 14:03
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] avoiding assignment statements
> 
> I have three global xsl:param's which I need to display if 
> any of them are selected:
> 
>   <xsl:param name="showReplicates" select="1"/>
>   <xsl:param name="showMetadata" select="1"/>
>   <xsl:param name="showElectronicSignature" select="1"/>
> 
> if all the flags are turned on, the output would be:
> 
> (View - Reps, Meta-Data, Signatures)
> 
> Normally I would do something like this:
> 
> bool isFirst = true
> 
> if(showReplicates == 1) {
>    Output("Reps");
>    isFirst = false;
> }
> 
> if(showMetadata == 1) {
>    if(isFirst == false) Output(", ");
>    Output("Meta-Data");
>    isFirst = false;
> }
> 
> if(showElectronicSignature == 1) {
>    if(isFirst == false) Output(", ");
>    Output("Signatures");
>    isFirst = false;
> }
> 
> if(isFirst == true) {
>    Output("Only Summary");
> }
> 
> The question is:  How do I do the same thing in the 
> Functional Programming world?
> --
> Miltonstreet Photography
> http://www.miltonstreet.com


Current Thread