This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

following-sibling or grouping maybe


Hi

I would like to transform XML like the sample below to a HTML table. I dont
want to add any more cells to the HTML rows if the current cell's <data> and
<comment> or the following cells on the same row are empty. 

the XSL below produces this:

<html><table border="1">
<tr><td>1 aa  </td><td>2  bb </td><td>3   </td><td>4   </td></tr>
<tr><td>1 aa  </td><td>2   </td><td>3   </td><td>4 dd </td></tr>
</table></html>

but i would like it this way:

<html><table border="1">
<tr><td>1 aa  </td><td>2  bb </td></tr>
<tr><td>1 aa  </td><td>2   </td><td>3   </td><td>4 dd </td></tr>
</table></html>


thanks,
matts isuls

###################

<?xml version="1.0"?>
<table>
<row>
  <cell id="1">
    <data>aa</data>
    <comment></comment>
  </cell>
  <cell id="2">
    <data></data>
    <comment>bb</comment>
  </cell>
  <cell id="3">
    <data></data>
    <comment></comment>
  </cell>
  <cell id="4">
    <data></data>
    <comment></comment>
  </cell>
  <cell id="5">
    <data></data>
    <comment></comment>
  </cell>
</row>
<row>
  <cell id="1">
    <data>aa</data>
    <comment></comment>
  </cell>
  <cell id="2">
    <data></data>
    <comment></comment>
  </cell>
  <cell id="3">
    <data></data>
    <comment></comment>
  </cell>
  <cell id="4">
    <data>dd</data>
    <comment></comment>
  </cell>
  <cell id="5">
    <data></data>
    <comment></comment>
  </cell>
</row>
</table>

####################################

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="/">
  <html>
    <table border="1">
      <xsl:for-each select="/table/row">
        <tr>
          <xsl:for-each select="cell">
            <xsl:if test="following-sibling::*!=''"> 
              <td>
                <xsl:value-of select="@id"/><xsl:value-of select="."/>
              </td>
            </xsl:if> 
          </xsl:for-each> 
        </tr>
      </xsl:for-each> 
    </table>
  </html>
</xsl:template>
</xsl:stylesheet>

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]