xsl-list
[Top] [All Lists]

[xsl] Limiting a row to four items

2020-08-28 03:44:18
This is likely in the archives but I have forgotten how to use them. Among the other things I have forgotten since I turned 80 is how to a put set of elements into rows for HTML output. I want to put what four <plate> elements conjure into each row; the number of< plate> elements in each <stamp> element varies. The <plate> element references the identity of a jpeg that will be put on the page. I want four jpegs in each row.

my css is:

.row {
  width: 100%;
  display: flex;
  flex-direction: row;
  justify-content: center;
}

My input XML is a long list of <stamp> elements with <plate> children.
....
<stamp >
                <plate number="1"/>
                <plate number="2"/>
                <plate number="3"/>
                <plate number="4"/>
                <plate number="5"/>
                <plate number="6"/>
                <plate number="7"/>
                <plate number="8"/>
</stamp>
....

and my XSLT dealing with this within  <xsl:template match="stamp"> is:
<div class="row">
       <xsl:for-each select="plate">
              <div class="block">
                            <a  href="{concat('plates/', @number, '.jpg')}">                                  <img class="large" src="{concat('plates/',@number, 't.jpg')}"/>
                              </a>
               </div>
         </xsl:for-each>
  </div>

Works fine for four or fewer <plate> elements, but more than that makes a mess
Any help appreciated,
Mark
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>