title: How can I make a comma delimited list of xml values? xml version 1.0
body: <p>I have searched for an answer to this with no luck.  I'm sure I have overlooked the answer somewhere. However, I am trying to print/display a subset of xml values as a comma delimited list. Here is an example of what I am trying to do;</p>
  
  <p>XML Doc.</p>
  
  <pre><code>&lt;vehicle&gt;
    &lt;car new="y"&gt;
      &lt;yr&gt;2012&lt;/yr&gt;
      &lt;make&gt;Ford&lt;/make&gt;
      &lt;model&gt;Mustang&lt;/model&gt;
      &lt;color&gt;Blue&lt;/color&gt;
    &lt;/car&gt;
    &lt;car new="y"&gt;
      &lt;yr&gt;2012&lt;/yr&gt;
      &lt;make&gt;Chevy&lt;/make&gt;
      &lt;model&gt;Camaro&lt;/model&gt;
      &lt;color&gt;Red&lt;/color&gt;
    &lt;/car&gt;
    &lt;car new="y"&gt;
      &lt;yr&gt;2012&lt;/yr&gt;
      &lt;make&gt;Subaru&lt;/make&gt;
      &lt;model&gt;Impreza&lt;/model&gt;
      &lt;color&gt;White&lt;/color&gt;
    &lt;/car&gt;
    &lt;car new="n"&gt;
      &lt;yr&gt;2000&lt;/yr&gt;
      &lt;make&gt;Toyota&lt;/make&gt;
      &lt;model&gt;Tacoma&lt;/model&gt;
      &lt;color&gt;Silver&lt;/color&gt;
    &lt;/car&gt;
    &lt;car new="n"&gt;
      &lt;yr&gt;1998&lt;/yr&gt;
      &lt;make&gt;Dodge&lt;/make&gt;
      &lt;model&gt;Durango&lt;/model&gt;
      &lt;color&gt;Green&lt;/color&gt;
    &lt;/car&gt;
  &lt;/vehicle&gt;
  </code></pre>
  
  <p>XSL DOC..</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
    &lt;xsl:output method="html"/&gt;
    &lt;xsl:template match="/" &gt;
  
  &lt;html&gt;
    &lt;head&gt;
      &lt;link rel="stylesheet" type="text/css" href="styles2.css" /&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;h2&gt; New Cars &lt;/h2&gt;
        &lt;p&gt;
          &lt;xsl:for-each select="vehicle/car"&gt;
          &lt;xsl:sort select="./yr" data-type="text" order="ascending" /&gt;
          &lt;xsl:if test="./@new='y'"&gt;
          &lt;xsl:value-of select="yr" /&gt;
          &lt;xsl:text&gt; &lt;/xsl:text&gt;
          &lt;xsl:value-of select="make" /&gt;
          &lt;xsl:text&gt; - &lt;/xsl:text&gt;
          &lt;xsl:value-of select="model" /&gt;
          &lt;/xsl:if&gt;
          &lt;/xsl:for-each&gt;
        &lt;/p&gt;
    &lt;/body&gt;
  &lt;/html&gt;
    &lt;/xsl:template&gt;
   &lt;/xsl:stylesheet&gt; 
  </code></pre>
  
  <p>So, in this example I want to select all "new" cars and place them in a comma delimited list and not have a comma after the last item in the list.  </p>
  
  <p>I can't use <code>xsl:if test="position() != last()&gt;</code> since the position of the "last" "new" car may not be the "last" position in the xml. I would prefer this to be done in xml version 1.0.  </p>
  
  <p>Any Suggestions or Ideas?  Thanks in advance!</p>
  
  <p>Example output:</p>
  
  <pre><code>2012 Ford Mustang, 2012 Chevy Camaro, 2012 Subaru Impreza
  </code></pre>