title: XSLT 1.0 Idiom for ternary if?
body: <p>This Java program makes use of a Ternary if, to map booleans to output strings: (a "*" for true, an empty string for false).</p>
  
  <pre><code>public class ternary {
    public static void main(String[] args) {
      boolean flags[]={true,false,true};
      for (boolean f : flags) {
        System.out.println(f?"*":"");
      }
    }
  }
  </code></pre>
  
  <p>So the output is *, [empty], *.</p>
  
  <p>I have an input XML document, something like:</p>
  
  <pre><code>&lt;?xml version="1.0" ?&gt;
  &lt;?xml-stylesheet type="text/xsl" href="change.xsl"?&gt;
  &lt;root&gt;
    &lt;change flag="true"/&gt;
    &lt;change flag="false"/&gt;
    &lt;change flag="true"/&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>And I have the following XSLT template which maps true to '*' and false to '' (it works):</p>
  
  <pre><code>&lt;xsl:template match="change"&gt;
    &lt;xsl:variable name="flag" select="translate(substring(@flag,1,1),'tf','*')"/&gt;
    &lt;xsl:value-of select="$flag"/&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>Is there is more concise version of this ?</p>
  
  <p>a) Can I automatically get a value of boolean true|false directly from the string 'true|false' ?
  b) Is there an (xpath?) construct to map the boolean true|false to '*', '' ?</p>