Struggling to use XSL to format my results into 3 columns

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,
I have the following XSL which is displaying a number of news articles in a single column. I am really struggling to work out how to change the code to display just the top 6 articles in 2 rows/3 columns.
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <?<span style="color:#A31515; xml <span style="color:Red; version<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1.0<span style="color:Black; " <span style="color:Red; encoding<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; utf-8<span style="color:Black; " <span style="color:Red; standalone<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; yes<span style="color:Black; "<span style="color:Blue; ?>
<span style="color:Blue; <<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; stylesheet <span style="color:Red; version<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1.0<span style="color:Black; " <span style="color:Red; xmlns:xsl<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; http://www.w3.org/1999/XSL/Transform<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; output <span style="color:Red; indent<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; no<span style="color:Black; " <span style="color:Red; method<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; html<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; param <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; PageCapacity<span style="color:Black; " <span style="color:Red; select<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; param <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; CombineLists<span style="color:Black; " <span style="color:Red; select<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; true<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; template <span style="color:Red; match<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; /<span style="color:Black; " <span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; table <span style="color:Red; width<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 100%<span style="color:Black; " <span style="color:Red; border<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Red; cellspacing<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Red; cellpadding<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 3<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; for-each <span style="color:Red; select<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Root/Root/Rows/Row[Column[@fInternalName = Homepage]/@Value = Yes and Column[@fInternalName = _ModerationStatus]/@Value = Approved]<span style="color:Black; " <span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; sort <span style="color:Red; select<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Column[@fInternalName = PublishedDate]/@Value<span style="color:Black; " <span style="color:Red; order<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; descending<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; tr <span style="color:Red; valign<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; top<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; attribute <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; class<span style="color:Black; " <span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; choose<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; when <span style="color:Red; test<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; position() mod 2 = 1<span style="color:Black; " <span style="color:Blue; >odd<span style="color:Blue; </<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; when<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; otherwise<span style="color:Blue; >even<span style="color:Blue; </<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; otherwise<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; choose<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; attribute<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; td <span style="color:Red; align<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; left<span style="color:Black; " <span style="color:Red; style<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; padding-right: 5px;<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; for-each <span style="color:Red; select<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Column[@fInternalName = Title]<span style="color:Black; " <span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; choose<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; when <span style="color:Red; test<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; @Value != <span style="color:Black; " <span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; a <span style="color:Red; href<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; {../@Url}<span style="color:Black; " <span style="color:Red; class<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; newsbytes-link<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; value-of <span style="color:Red; select<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; @Value<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; a<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; br <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; when<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; otherwise<span style="color:Blue; >Untitled<span style="color:Blue; </<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; otherwise<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; choose<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; for-each<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; choose<span style="color:Blue; >
<span style="color:Green; <!--display summary if present-->
<span style="color:Blue; <<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; when <span style="color:Red; test<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Column[@fInternalName = Summary]/@Value != <span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; span <span style="color:Red; class<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; newsbytes-summary<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; value-of <span style="color:Red; select<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Column[@fInternalName = Summary]/@Value<span style="color:Black; "<span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; span<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; when<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; otherwise<span style="color:Blue; >

<span style="color:Blue; </<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; otherwise<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; choose<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; td<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; tr<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; for-each<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; table<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; template<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; xsl<span style="color:Blue; :<span style="color:#A31515; stylesheet<span style="color:Blue; >
[/code]
I have tried to use the following-sibling syntax but cannot seem to get it to work - I am hoping someone can point me in the right direction.
kind regards
Tony

View the full article
 
Back
Top