title: How to build a string with XSLT?
body: <p>I have this XML snippet</p>
  
  <pre><code>&lt;MediaTypes&gt;
    &lt;DVD&gt;true&lt;/DVD&gt;
    &lt;HDDVD&gt;false&lt;/HDDVD&gt;
    &lt;BluRay&gt;true&lt;/BluRay&gt;
  &lt;/MediaTypes&gt;
  </code></pre>
  
  <p>And I want to create an output that looks like this</p>
  
  <pre><code>DVD / Blu-ray
  </code></pre>
  
  <p>or like this</p>
  
  <pre><code>DVD
  </code></pre>
  
  <p>or like this</p>
  
  <pre><code>DVD / HD-DVD / Blu-ray
  </code></pre>
  
  <p>depending on the true/false states</p>
  
  <p>But I'm a total beginner in the XSLT game. :-/</p>
  
  <p>Here's a snippet of the full XML</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="Windows-1252"?&gt;
  &lt;Collection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;DVD&gt;
      &lt;ProfileTimestamp&gt;2012-06-07T05:20:51Z&lt;/ProfileTimestamp&gt;
      &lt;ID&gt;0044005507027.5&lt;/ID&gt;
      &lt;MediaTypes&gt;
        &lt;DVD&gt;true&lt;/DVD&gt;
        &lt;HDDVD&gt;false&lt;/HDDVD&gt;
        &lt;BluRay&gt;false&lt;/BluRay&gt;
      &lt;/MediaTypes&gt;
      &lt;UPC&gt;0-044005-507027&lt;/UPC&gt;
      &lt;CollectionNumber&gt;448&lt;/CollectionNumber&gt;
      &lt;CollectionType IsPartOfOwnedCollection="true"&gt;Owned&lt;/CollectionType&gt;
      &lt;Title&gt;The Big Lebowski&lt;/Title&gt;
      &lt;DistTrait /&gt;
      &lt;OriginalTitle /&gt;
      &lt;CountryOfOrigin&gt;United States&lt;/CountryOfOrigin&gt;
      ...
    &lt;/DVD&gt;
    &lt;DVD&gt;
       ...
    &lt;/DVD&gt;
  &lt;/Collection&gt;
  </code></pre>
  
  <p>I tried to follow the advices given below (regarding the loop), but it doesn't seem to work.</p>
  
  <p>This is the XSL I have so far (complete):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  
      &lt;xsl:template name="MediaTypes" match="MediaTypes"&gt;
          Test
          &lt;xsl:for-each select="*[.='true']"&gt;            
              &lt;xsl:value-of select="name()"/&gt;
              &lt;xsl:if test="position()!=last()"&gt;
                  &lt;xsl:text&gt;/&lt;/xsl:text&gt;
              &lt;/xsl:if&gt;
          &lt;/xsl:for-each&gt;        
      &lt;/xsl:template&gt;
  
      &lt;xsl:template match="/"&gt;
          &lt;html&gt;
              &lt;head&gt;
                  &lt;title&gt;DVD Profiler Double Dips&lt;/title&gt;
              &lt;/head&gt;
              &lt;body&gt;
                  &lt;div&gt;
                      &lt;h1&gt;DVD Profiler Double Dips&lt;/h1&gt;
                  &lt;/div&gt;
                  &lt;table border="1" cellpadding="3" cellspacing="0"&gt;
                      &lt;tr&gt;
                          &lt;th&gt;Title&lt;/th&gt;
                          &lt;th&gt;Edition&lt;/th&gt;
                          &lt;th&gt;Production Year&lt;/th&gt;
                          &lt;th&gt;DVD /&lt;/th&gt;
                          &lt;th&gt;Purchase Date&lt;/th&gt;
                          &lt;th&gt;Collection Type&lt;/th&gt;
                          &lt;th&gt;Original Title&lt;/th&gt;
                          &lt;th&gt;Sort Title&lt;/th&gt;
                      &lt;/tr&gt;
                      &lt;xsl:for-each select="/Collection/DVD"&gt;
                          &lt;tr&gt;
                              &lt;td&gt;
                                  &lt;xsl:value-of select="Title"/&gt;
                              &lt;/td&gt;
                              &lt;td&gt;
                                  &lt;xsl:if test="DistTrait != ''"&gt;
                                      &lt;xsl:value-of select="DistTrait"/&gt;
                                  &lt;/xsl:if&gt;
                                  &lt;xsl:if test="DistTrait = ''"&gt;
                                      &amp;#160;
                                  &lt;/xsl:if&gt;
                              &lt;/td&gt;
                              &lt;td&gt;
                                  &lt;xsl:if test="ProductionYear != ''"&gt;
                                      &lt;xsl:value-of select="ProductionYear"/&gt;
                                  &lt;/xsl:if&gt;
                                  &lt;xsl:if test="ProductionYear = ''"&gt;
                                      &amp;#160;
                                  &lt;/xsl:if&gt;
                              &lt;/td&gt;
                              &lt;td&gt;
                                  &lt;xsl:call-template name="MediaTypes" /&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                      &lt;/xsl:for-each&gt;
                  &lt;/table&gt;
              &lt;/body&gt;
          &lt;/html&gt;
      &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>But where </p>
  
  <pre><code>&lt;xsl:call-template name="MediaTypes" /&gt;
  </code></pre>
  
  <p>is standing, only "Test" comes out</p>
  
  <p><strong>Yay!</strong></p>
  
  <p>You guys are awesome. Yes </p>
  
  <pre><code>&lt;xsl:apply-templates select="MediaTypes"/&gt;
  </code></pre>
  
  <p>Was my weapon of choice.</p>
  
  <p>My final template looks like this:</p>
  
  <pre><code>&lt;xsl:template name="MediaTypes" match="MediaTypes"&gt;
      &lt;xsl:for-each select="*[.='true']"&gt;
          &lt;xsl:value-of select="name()"/&gt;
          &lt;xsl:if test="position()!=last()"&gt;
              &lt;xsl:text&gt; / &lt;/xsl:text&gt;
          &lt;/xsl:if&gt;
      &lt;/xsl:for-each&gt;
      &lt;xsl:if test="CustomMediaType != ''"&gt;
          &lt;xsl:if test="*[.='true']"&gt;
              &lt;xsl:text&gt; / &lt;/xsl:text&gt;
          &lt;/xsl:if&gt;
          &lt;xsl:value-of select="CustomMediaType"/&gt;
      &lt;/xsl:if&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p><em>begins to understand how stuff works</em></p>
  
  <p>Thanks for all your help!</p>