title: Formatting table columns to ignore duplicates XSLT-1.0
body: <p>I was hoping that someone could point me in the correct direction with a concept in XSLT 1.0. I am generating a PDF so the code is a bit long and I thought it would be more appropriate to include only the relevant bits.</p>
  
  <p>I have XML similar to the following skeleton (the full XML has dozens of rows that each contain more than just producer and publication):</p>
  
  <pre><code>&lt;root&gt;
      &lt;table&gt;
          &lt;row&gt;
              &lt;PRODUCER/&gt;
              &lt;PUBLICATION_CODE_-_NAME/&gt;
          &lt;/row&gt;
          &lt;row&gt;
              &lt;PRODUCER/&gt;
              &lt;PUBLICATION_CODE_-_NAME/&gt;
          &lt;/row&gt;
      &lt;/table&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>I am currently able to generate a table using XSLT that looks similar to this that contains multiple rows:</p>
  
  <pre><code>|  Producer Name  |  Publication  |
  ----------------------------------            
  |Producer 1       |Publication A  |
  |Producer 1       |Publication B  |
  |Producer 1       |Publication C  |
  |Producer 2       |Publication D  |
  |Producer 2       |Publication E  |
  |Producer 2       |Publication F  |
  </code></pre>
  
  <p>And so on in this fashion.</p>
  
  <p>The main portion of the code that produces this in my XSLT is:</p>
  
  <pre><code>&lt;xsl:template match ="table"&gt;
      &lt;fo:table&gt;
          &lt;fo:table-body  font-size="10pt"
                          font-family="sans-serif"
                          line-height="10pt"
                          space-after.optimum="3pt"&gt;
              &lt;xsl:for-each select="row"&gt;
                  &lt;fo:table-row&gt;
                      &lt;fo:table-cell  width="2.125in"
                                      height="0.2in"&gt;
                          &lt;xsl:choose&gt;
                          &lt;xsl:apply-templates select="PRODUCER"/&gt;
                          &lt;/xsl:choose&gt;
                      &lt;/fo:table-cell&gt;
                      &lt;fo:table-cell  width="3.25in"
                                      height="0.2in"&gt;
                          &lt;xsl:apply-templates select="PUBLICATION_CODE_-_NAME"/&gt;
                      &lt;/fo:table-cell&gt;
                  &lt;/fo:table-row&gt;
              &lt;/xsl:for-each&gt;
          &lt;/fo:table-body&gt;
      &lt;/fo:table&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="PRODUCER"&gt;
      &lt;fo:block&gt;
              &lt;xsl:value-of select="@value"/&gt;
      &lt;/fo:block&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="PUBLICATION_CODE_-_NAME"&gt;
      &lt;fo:block&gt;
          &lt;xsl:value-of select="@value"/&gt;
      &lt;/fo:block&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>Now the question arises where I want the output of the table to look more like this as opposed to the table above.</p>
  
  <pre><code>|  Producer Name  |  Publication  |
  ----------------------------------            
  |Producer 1       |Publication A  |
  |                 |Publication B  |
  |                 |Publication C  |
  |Producer 2       |Publication D  |
  |                 |Publication E  |
  |                 |Publication F  |
  </code></pre>
  
  <p>The way that I am attempting to do this is within this portion of the XSLT </p>
  
  <pre><code>&lt;xsl:template match="PRODUCER"&gt;
      &lt;fo:block&gt;
              &lt;xsl:value-of select="@value"/&gt;
      &lt;/fo:block&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>At this point, as far as I understand, the context node is PRODUCER. So in order to compare PRODUCER values in previous rows I would need to use something to the effect of ../preceding-sibling in order to find the preceding-sibling of last row (instead of PRODUCER). Additionally, the information is already ordered by producer, so it is only necessary for me to look at the closest preceding-sibling as opposed to all of them.</p>
  
  <p>The code that I am attempted to use to solve this issue is the following:</p>
  
  <pre><code>&lt;xsl:template match="PRODUCER"&gt;
      &lt;fo:block&gt;
          &lt;xsl:if test="not(../preceding-sibling::PRODUCER/@value = self/@value&gt;
              &lt;xsl:value-of select="@value"/&gt;
          &lt;/xsl:if&gt;
      &lt;/fo:block&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>I don't know if the syntax is incorrect, or whether this a good way to go about doing this, but any and all input would be greatly appreciated. If there is any other information I can provide that would help clarify or if there are any issues with my question please let me know.</p>
  
  <p>Thank you</p>