Link to home
Start Free TrialLog in
Avatar of al4ddin
al4ddin

asked on

inserting table row every tens rows XSLT

Hi,

I have an XSLT file that displays my XML feed in a table format.
What I need to do is every 10 records insert a row with some default information.

I can attach my XSLT if it would make it easier

Thanks
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Please attach teh XSLT

IF what you want to do is "have records in a cell, and ten cells per row", then you should not do this in a procedural way
I will show you how to do it if you can show source XML and the XSLT you have so far
Avatar of al4ddin
al4ddin

ASKER


<xsl:template match="/">
    <xsl:apply-templates select="Offers"/>
  </xsl:template>
  <xsl:template match="Offers">
    <xsl:choose>
      <xsl:when test="normalize-space($county) and normalize-space($county) != 'n/a' and normalize-space($county) != 'All'">
        <xsl:apply-templates mode="county_only" select="county[contains(normalize-space($county), ./CID)]"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates select="county"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <xsl:template match="county">
    <xsl:choose>
      <xsl:when test="normalize-space($city) and normalize-space($city) != 'n/a'">
        <xsl:choose>
          <xsl:when test="normalize-space($freight) and normalize-space($freight) != 'n/a'">
            <xsl:call-template name="county_table">
              <xsl:with-param name="records" select="descendant::record"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:otherwise>
            <xsl:call-template name="county_table">
              <xsl:with-param name="records" select="descendant::record"/>
            </xsl:call-template>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:when>
      <xsl:when test="normalize-space($freight) and normalize-space($freight) != 'n/a'">
        <xsl:call-template name="county_table">
          <xsl:with-param name="records" select="descendant::record"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="county_table">
          <xsl:with-param name="records" select="descendant::record"/>
        </xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <xsl:template match="county" mode="county_only">
    <xsl:call-template name="county_table">
      <xsl:with-param name="records" select="descendant::record"/>
    </xsl:call-template>
  </xsl:template>
  <xsl:template name="county_table">
    <xsl:param name="records"/>
    <xsl:choose>
      <xsl:when test="count($records) &gt; 0">
        <xsl:element name="a">
          <xsl:attribute name="name">
            <xsl:value-of select="CID"/>
          </xsl:attribute>
          <xsl:attribute name="href">#</xsl:attribute>
          <xsl:comment>anchor text</xsl:comment>
        </xsl:element>
        <h2>
          <xsl:call-template name="county_map">
            <xsl:with-param name="cid" select="CID"/>
          </xsl:call-template>
        </h2>
        <div class="template_content_wrapper clear">
          <div class="table_wrapper sorting_table">
            <table>
              <thead>
                <tr class="no-background">
                  <th>
                    <span class="sorting_header_text">
                      <xsl:value-of select="$sf_destination"/>
                    </span>
                    <xsl:choose>
                      <xsl:when test="$sort_order='ascending' and $sort='DestFrom'">
                        <a href="?sort=DestFrom&amp;sort_order=descending">
                          <img alt="Sort ascending selected" src="{$uparrow-on}"/>
                          <img alt="Sort descending" src="{$downarrow}"/>
                        </a>
                      </xsl:when>
                      <xsl:when test="$sort_order='descending' and $sort='DestFrom'">
                        <a href="?sort=DestFrom&amp;sort_order=ascending">
                          <img alt="Sort ascending" src="{$uparrow}"/>
                          <img alt="Sort descending selected" src="{$downarrow-on}"/>
                        </a>
                      </xsl:when>
                      <xsl:otherwise>
                        <a href="?sort=DestFrom&amp;sort_order=ascending">
                          <img alt="Sort ascending" src="{$uparrow}"/>
                          <img alt="Sort descending" src="{$downarrow}"/>
                        </a>
                      </xsl:otherwise>
                    </xsl:choose>
                  </th>
                  <th>
                    <span class="sorting_header_text">
                      <xsl:value-of select="$sf_destinationTo"/>
                    </span>
                    <xsl:choose>
                      <xsl:when test="$sort_order='ascending' and $sort='DestTo'">
                        <a href="?sort=DestTo&amp;sort_order=descending">
                          <img alt="Sort ascending selected" src="{$uparrow-on}"/>
                          <img alt="Sort descending" src="{$downarrow}"/>
                        </a>
                      </xsl:when>
                      <xsl:when test="$sort_order='descending' and $sort='DestTo'">
                        <a href="?sort=DestTo&amp;sort_order=ascending">
                          <img alt="Sort ascending" src="{$uparrow}"/>
                          <img alt="Sort descending selected" src="{$downarrow-on}"/>
                        </a>
                      </xsl:when>
                      <xsl:otherwise>
                        <a href="?county={CID}&amp;sort=DestTo&amp;sort_order=ascending">
                          <img alt="Sort ascending" src="{$uparrow}"/>
                          <img alt="Sort descending" src="{$downarrow}"/>
                        </a>
                      </xsl:otherwise>
                    </xsl:choose>
                  </th>
                  <th>
                    <span class="sorting_header_text">
                      <xsl:value-of select="$sf_price_from"/>
                    </span>
                    <xsl:choose>
                      <xsl:when test="$sort_order='ascending' and $sort='Price'">
                        <a href="?county={CID}&amp;sort=Price&amp;sort_order=descending">
                          <img alt="Sort ascending selected" src="{$uparrow-on}"/>
                          <img alt="Sort descending" src="{$downarrow}"/>
                        </a>
                      </xsl:when>
                      <xsl:when test="$sort_order='descending' and $sort='Price'">
                        <a href="?county={CID}&amp;sort=Price&amp;sort_order=ascending">
                          <img alt="Sort ascending" src="{$uparrow}"/>
                          <img alt="Sort descending selected" src="{$downarrow-on}"/>
                        </a>
                      </xsl:when>
                      <xsl:otherwise>
                        <a href="?county={CID}&amp;sort=Price&amp;sort_order=ascending">
                          <img alt="Sort ascending" src="{$uparrow}"/>
                          <img alt="Sort descending" src="{$downarrow}"/>
                        </a>
                      </xsl:otherwise>
                    </xsl:choose>
                  </th>
                  <th>
                    <xsl:comment>anchor text</xsl:comment>
                  </th>
                </tr>
              </thead>
              <tbody>
                <xsl:for-each select="$records">
                  <!-- Sort by price in descending/asceding-->
                  <xsl:sort data-type="{$data-type}" order="{$sort_order}" select="*[name(.)=$sort]"/>
                  <!-- <xsl:sort order="{$sort_order}" select="*[name(.)=$sort]"/> -->
                  <xsl:call-template name="record"/>
                </xsl:for-each>
              </tbody>
            </table>
          </div>
          <div class="wowRSSLinks clearfix">
            <div class="rss">
              <a href="{$page_url_rss}?rss=true&amp;county={CID}" onclick="dcsMultiTrack('DCS.dcsuri', '{$rdeXmlID}', 'WT.ti', 'Page {$feed_title}', 'DCSext.button_placement',dcsPageURL, 'DCSext.lnk_bt','RSS Feed CID={CID}');">
                <xsl:value-of select="concat($sf_prefix_rss_link, ' ')"/>
                <strong>
                  <xsl:call-template name="county_map">
                    <xsl:with-param name="cid" select="CID"/>
                  </xsl:call-template>
                </strong>
                <xsl:value-of select="concat(' ', $sf_conjuncion_rss_link, ' ')"/>
                <span class="rss_icon">RSS</span>
              </a>
            </div>
            <!--                         <ul>
                            <li><a href="#">Google<span></span></a></li>
                            <li><a href="#">MSN<span></span></a></li>
                            <li><a href="#">Yahoo<span></span></a></li>
                            </ul> -->
          </div>
          <!-- close wowrss-->
        </div>
        <!-- close table -->
      </xsl:when>
      <xsl:otherwise>
        <!-- TODO
                <p>
                    <xsl:value-of select="$sf_no_result"/>
                </p> -->
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <xsl:template name="record">
    <tr>
      <td>
        <xsl:value-of select="DestFrom"/>
      </td>
      <!-- Destinatin To -->
      <td>
        <xsl:value-of select="DestTo"/>
      </td>
      <!-- End -->
      <td>
        <xsl:value-of select="$sf_price_currency"/>
        <xsl:value-of select="Price"/>
      </td>
      <td>
        <xsl:choose>
          <xsl:when test="CallToAction='phone'">
            <div>
              <a href="#">
                <xsl:element name="img">
                  <xsl:attribute name="src">call.png</xsl:attribute>
                  <xsl:attribute name="alt">Call us</xsl:attribute>
                </xsl:element>
              </a>
            </div>
          </xsl:when>
          <xsl:when test="CallToAction='online'">
            <div>
              <a href="#">
                <xsl:element name="img">
                  <xsl:attribute name="src">click_to_call.png</xsl:attribute>
                  <xsl:attribute name="alt">Call us</xsl:attribute>
                </xsl:element>
              </a>
            </div>
          </xsl:when>
        </xsl:choose>
      </td>
    </tr>
  </xsl:template>
  <xsl:template name="county_map">
    <xsl:param name="cid"/>
    <xsl:choose>
      <xsl:when test="$cid='A'">
        <xsl:value-of select="$sf_county_a"/>
      </xsl:when>
      <xsl:when test="$cid='B'">
        <xsl:value-of select="$sf_county_b"/>
      </xsl:when>
      <xsl:when test="$cid='C'">
        <xsl:value-of select="$sf_county_c"/>
      </xsl:when>
      <xsl:when test="$cid='D'">
        <xsl:value-of select="$sf_county_d"/>
      </xsl:when>
      <xsl:when test="$cid='E'">
        <xsl:value-of select="$sf_county_e"/>
      </xsl:when>
      <xsl:when test="$cid='F'">
        <xsl:value-of select="$sf_county_f"/>
      </xsl:when>
      <xsl:when test="$cid='G'">
        <xsl:value-of select="$sf_county_g"/>
      </xsl:when>
      <xsl:when test="$cid='H'">
        <xsl:value-of select="$sf_county_h"/>
      </xsl:when>
      <xsl:when test="$cid='I'">
        <xsl:value-of select="$sf_county_i"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$sf_county_default"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

Open in new window

Avatar of al4ddin

ASKER

What I need is to display ten records, then insert a row with some default text, display the next ten records and insert the row again and so on...
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
all of this is untested, since you gave me no XML to test and only a small portion of the XSLT
Avatar of al4ddin

ASKER

hmmm, doesn't seem to work!?

How/where would I add the extra row html?
in the named template for record

if it does not happen there, it might be that you ar enot getting them there in portions of ten,
if that is not the case, it will be difficult to get done
Avatar of al4ddin

ASKER

Hi Gertone,

Do you have an email address I can email you my full XSLT and XML?

Or does it have to be on here?

Thanks
my email address is in my profile (be it somewhat hidden), you can send it there