You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Holger Schmidt <hs...@chronolabs.de> on 2000/06/19 14:20:19 UTC

conditional generation ???

Hi,
I have a xml file with several items called <group>
now i want to build table with 4 <group> items in a row

I open a table and start the first row, then i insert the TD's  within
a <xsl:for-each select="group"> loop
after every 4th TD i want to close the row and then start a new one.

However for some reason the parser has a problem with inserting the </tr> <tr>
every 4th row. but when i use text instead of tags " <tr> -> '[' and <td> 
-> '('  "
everyting looks like it should be.

The parser thinks i don't close the <xsl:if> tag.
Probably im doing something i shouldn't, but what other way could i go?

this is my sample code which is not working

<table>
   <tr>
     <xsl:for-each select="group">
     <td> blablabla </td>
     <xsl:if test="not(position() mod 4)">
       </tr> <tr>
     </xsl:if>
   </tr>
</table>

and this the one that is working (but not usefull)

<table>
   <xsl:text>[</xsl:text>
     <xsl:for-each select="group">
     <xsl:text>(</xsl:text> blablabla <xsl:text>)</xsl:text>
     <xsl:if test="not(position() mod 4)">
       <xsl:text>] [ </xsl:text>
     </xsl:if>
    <xsl:text>]</xsl:text>
</table>


H.

--
Holger Schmidt  - email: hschmidt@chronolabs.de
phone: ++4989 55869988  -  fax: ++4989 55869966
Chronolabs GmbH - Landwehrstr. 5 - 80336 Munich


Re: conditional generation ???

Posted by Eric SCHAEFFER <es...@posterconseil.com>.
It won't work.
Your XSP page is an XML document, and therefore it must conform to XML
syntax.

For what you want, you need to generate the resulting XML document manually,
using XSP core API / DOM API (xspCurrentNode.appendChild(...),
document.createElement(...), etc.).

Eric.

----- Original Message -----
From: Zvi <th...@ifrance.com>
To: <co...@xml.apache.org>
Sent: Tuesday, June 20, 2000 3:17 PM
Subject: Re: conditional </tr><tr> generation ???


> try this:
>
> <table>
>      <xsl:for-each select="group">
>          <xsl:if test="position() mod 4 = 0">
>              <tr>
>         </xsl:if>
>          <td> blablabla </td>
>          <xsl:if test="position() mod 4 =0">
>              </tr>
>          </xsl:if>
>      </xsl:for>
> </table>
>
> Holger Schmidt wrote:
>
> > Hi,
> > I have a xml file with several items called <group>
> > now i want to build table with 4 <group> items in a row
> >
> > I open a table and start the first row, then i insert the TD's  within
> > a <xsl:for-each select="group"> loop
> > after every 4th TD i want to close the row and then start a new one.
> >
> > However for some reason the parser has a problem with inserting the
</tr> <tr>
> > every 4th row. but when i use text instead of tags " <tr> -> '[' and
<td>
> > -> '('  "
> > everyting looks like it should be.
> >
> > The parser thinks i don't close the <xsl:if> tag.
> > Probably im doing something i shouldn't, but what other way could i go?
> >
> > this is my sample code which is not working
> >
> > <table>
> >    <tr>
> >      <xsl:for-each select="group">
> >      <td> blablabla </td>
> >      <xsl:if test="not(position() mod 4)">
> >        </tr> <tr>
> >      </xsl:if>
> >    </tr>
> > </table>
> >
> > and this the one that is working (but not usefull)
> >
> > <table>
> >    <xsl:text>[</xsl:text>
> >      <xsl:for-each select="group">
> >      <xsl:text>(</xsl:text> blablabla <xsl:text>)</xsl:text>
> >      <xsl:if test="not(position() mod 4)">
> >        <xsl:text>] [ </xsl:text>
> >      </xsl:if>
> >     <xsl:text>]</xsl:text>
> > </table>
> >
> > H.
> >
> > --
> > Holger Schmidt  - email: hschmidt@chronolabs.de
> > phone: ++4989 55869988  -  fax: ++4989 55869966
> > Chronolabs GmbH - Landwehrstr. 5 - 80336 Munich
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> > For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>


Re: conditional generation ???

Posted by Ulrich Mayring <ul...@denic.de>.
Zvi wrote:
> 
> try this:
> 
> <table>
>      <xsl:for-each select="group">
>          <xsl:if test="position() mod 4 = 0">
>              <tr>
>         </xsl:if>
>          <td> blablabla </td>
>          <xsl:if test="position() mod 4 =0">
>              </tr>
>          </xsl:if>
>      </xsl:for>
> </table>

Have you actually tried that? I don't think it will work, because the
issue with tags, that are not closed, is the same here.

Ulrich

-- 
Ulrich Mayring
DENIC eG, Systementwicklung

Re: conditional generation ???

Posted by John EM Mitchell <jo...@cs.stir.ac.uk>.
> <table>
>   <xsl:for-each select="group">
>     <xsl:if test="position() mod 4 = 0">
>       <tr>
>         <xsl:apply-templates select="."/>
>         <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
>         <xsl:apply-templates select="following-sibling::*[position() = 2]"/>
>         <xsl:apply-templates select="following-sibling::*[position() = 3]"/>
>       </tr>
>     </xsl:if>
>   </xsl:for>
> </table>
> 
> <xsl:template match="element">
>   <td>
>      ...
>   </td>
> </xsl:template>
> 
> assuming:
> <group>
>   <element/>
>   <element/>
>   ...
>   <element/>
> </group>

I've only just joined the list, so apologies if this is
off-topic, but I guess the original poster wanted to 
generate a table on the fly.
Bouncing 
www.hcrc.ed.ac.uk/~dmck/xslt-tutorial.html
off 
http://metalab.unc.edu/xml/books/bible/examples/14/index.html

I cobbled together the following .xsl , which produces a html
table with table headings and righthand-headings if applied to
http://metalab.unc.edu/xml/books/bible/examples/14/14-1.xml ,
for example.

It's not beautiful, but it does work :-)
cheers,
john

<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XML Spy v3.0 NT (http://www.xmlspy.com) by John 
EM Mitchell  -->
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="PERIODIC_TABLE">
	<HTML>
		<h2>
			<xsl:value-of select="local-name()"/>
		</h2>
		<table bgcolor="GREEN">
			<xsl:call-template name="ATOMTH"/>
			<xsl:apply-templates select="ATOM"/>
		</table>
	</HTML>
</xsl:template>
<xsl:template match="ATOM">
	<tr>
		<xsl:apply-templates select="DENSITY">
			<!--really need this to be variablised....  Also nd to stop its
duplication downstairs - presumably by making the test down in the
choose suit the level.  but that will mean it won't be proc first! 
arrgh variablisation must be the answer-->
		</xsl:apply-templates>
		<xsl:for-each select="*">
			<!--I think all this is eq2 to just apply-templates!  hey ho.  But of
course the apply-temps wd bh2b outwith a for-each, in order to be at the
right level.  an apply-templates here wd be all wrong, for anything but
DENSITY-->
			<xsl:choose>
			<xsl:when test="local-name()='ATOMIC_WEIGHT'">
				<xsl:call-template name="WEIGHT_CELL"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="OTHER_CELL"/>
			</xsl:otherwise>			  
			</xsl:choose>
		</xsl:for-each>
	</tr>
</xsl:template>
	<xsl:template name="ATOMTH">
		<tr>
			<!--This one's trying to do the THs. as opp to the TRs, so has to be
a name template in order that it be called only once. WORKS ok, as long
as the final ATOM in the table has all the ATTS- conforms to the DTD, in
other words.  Next is to get proper blank cells in for Jobinium, so
everythings' in the right colm.  That'll be in template match = ATOM, I
sd think-->
		<xsl:for-each select="ATOM">
			<xsl:if test="position()=last()">
				<xsl:for-each select="*">
					<th>
					<xsl:value-of select="local-name()"/>
					</th>
				</xsl:for-each>
			</xsl:if>
		</xsl:for-each>
	</tr>
</xsl:template>
<xsl:template name="WEIGHT_CELL">
	<td>
		<font size="20" color="blue">
			<i>
				<xsl:value-of select="."/>
			</i>
		</font>
	</td>
	<xsl:text/>
</xsl:template>
<xsl:template name="OTHER_CELL">
	<td>
		<center>
			<font size="2" color="yellow">
				<i>
					<xsl:value-of select="."/>
				</i>
			</font>
		</center>
	</td>
	<xsl:text/>
</xsl:template>

<xsl:template name="RH">
	<th align="right" width="20%">
		<font size="34" color="black">
			<xsl:value-of select="."/>
		</font>
	</th>

</xsl:template>
<xsl:template match="DENSITY">
	<th width="50%">
		<xsl:value-of select="."/>
	</th>
</xsl:template>

	<!--- ?how 2 match on this-->
	<xsl:variable name="rh">NAME</xsl:variable>
</xsl:stylesheet>

Re: conditional generation ???

Posted by Giacomo Pati <Gi...@pwr.ch>.
Klaus Malorny wrote:
> 
> <table>
>   <xsl:for-each select="group">
>     <xsl:if test="position() mod 4 = 0">
                                      ^^^ use a 1 here and it will work
correctly

>       <tr>
>         <xsl:apply-templates select="."/>
>         <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
>         <xsl:apply-templates select="following-sibling::*[position() = 2]"/>
>         <xsl:apply-templates select="following-sibling::*[position() = 3]"/>
>       </tr>
>     </xsl:if>
>   </xsl:for>
> </table>

Giacomo 

-- 
PWR GmbH, Organisation & Entwicklung      Tel:   +41 (0)1 856 2202
Giacomo Pati, CTO/CEO                     Fax:   +41 (0)1 856 2201
Hintereichenstrasse 7                     Mailto:Giacomo.Pati@pwr.ch
CH-8166 Niederweningen                    Web:   http://www.pwr.ch

Re: conditional generation ???

Posted by Donald Ball <ba...@webslingerZ.com>.
On Tue, 20 Jun 2000, Klaus Malorny wrote:

> I have nearly no experience with XSLT, nevertheless I would like to make a
> suggestion for solving the problem. Please forgive me if this is totally
> stupid ;-)
> 
> 
> <table>
>   <xsl:for-each select="group">
>     <xsl:if test="position() mod 4 = 0">
>       <tr>
>         <xsl:apply-templates select="."/>
>         <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
>         <xsl:apply-templates select="following-sibling::*[position() = 2]"/>
>         <xsl:apply-templates select="following-sibling::*[position() = 3]"/>
>       </tr>
>     </xsl:if>
>   </xsl:for>
> </table>
> 
> <xsl:template match="element">
>   <td>
>      ...
>   </td>
> </xsl:template>
> 
> 
> assuming:
> <group>
>   <element/>
>   <element/>
>   ...
>   <element/>
> </group>

I think that's the only correct implementation we've seen so far - but
this question (and thread) is best taken to the XSL users list at
mulberrytech.

- donald


Re: conditional generation ???

Posted by Klaus Malorny <Kl...@knipp.de>.
Zvi wrote:
> 
> sorry again,
> 
> this one wrong too,
> you need to use nested loops, or use one loop and actually generate each table raw...
> again sorry for wrong answers...
> 
> Zvi wrote:
> 
> > sorry :))
> >
> > I was thinking about something like this, not tried, but u need to think in this
> > direction...
> >
> > <table>
> >      <xsl:for-each select="group">
> >         <xsl:case>
> >              <xsl:when test="position() mod 4 = 0">
> >                  <tr>
> >                      <td> blablabla </td>
> >                   </tr>
> >              </xsl:when>
> >             <xsl:otherwise>
> >                    <td> blablabla </td>
> >             </xsl:otherwise>
> >         </xsl:case>
> >      </xsl:for>
> > </table>
> >


Hi,

I have nearly no experience with XSLT, nevertheless I would like to make a
suggestion for solving the problem. Please forgive me if this is totally
stupid ;-)


<table>
  <xsl:for-each select="group">
    <xsl:if test="position() mod 4 = 0">
      <tr>
        <xsl:apply-templates select="."/>
        <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
        <xsl:apply-templates select="following-sibling::*[position() = 2]"/>
        <xsl:apply-templates select="following-sibling::*[position() = 3]"/>
      </tr>
    </xsl:if>
  </xsl:for>
</table>

<xsl:template match="element">
  <td>
     ...
  </td>
</xsl:template>


assuming:
<group>
  <element/>
  <element/>
  ...
  <element/>
</group>



regards,
Klaus Malorny

Re: conditional generation ???

Posted by Holger Schmidt <hs...@openical.org>.
I will try this one,
I actually thought about it, but was not quite informed about how to use 
<xsl:text>
so that the nested tags won't be tags for the parser, but will be tags in 
the html file

a funny thing is that when I do the logically incorrect

    <xsl:if test="not(position() mod 4)">
       <tr> </tr>
     </xsl:if>

instead of the logically (at least in my way) correct

    <xsl:if test="not(position() mod 4)">
       </tr> <tr>
     </xsl:if>

it will work.

although it will generate wrong html code, but the wrong html code will be 
displayed correctly in both IE and NS

Holger

At 15:50 20.06.00 +0300, you wrote:
>Just had a problem like this, did a dirty, xml-rule-violating hack for it :)
>
>      <xsl:for-each select="item">
>       <xsl:if test="position() mod 2 = 1">
>        <xsl:text disable-output-escaping="yes"><![CDATA[<tr>]]></xsl:text>
>       </xsl:if>
>     ...


Re: conditional generation ???

Posted by Jari Aarniala <ja...@ioboxgroup.com>.
Just had a problem like this, did a dirty, xml-rule-violating hack for it :)

     <xsl:for-each select="item">
      <xsl:if test="position() mod 2 = 1">
       <xsl:text disable-output-escaping="yes"><![CDATA[<tr>]]></xsl:text>
      </xsl:if>
    ...

----- Original Message -----
From: Zvi <th...@ifrance.com>
To: <co...@xml.apache.org>
Sent: Tuesday, June 20, 2000 4:45 PM
Subject: Re: conditional </tr><tr> generation ???


: sorry again,
:
: this one wrong too,
: you need to use nested loops, or use one loop and actually generate each
table raw...
: again sorry for wrong answers...
:
:
: Zvi wrote:
:
: > sorry :))
: >
: > I was thinking about something like this, not tried, but u need to think
in this
: > direction...
: >
: > <table>
: >      <xsl:for-each select="group">
: >         <xsl:case>
: >              <xsl:when test="position() mod 4 = 0">
: >                  <tr>
: >                      <td> blablabla </td>
: >                   </tr>
: >              </xsl:when>
: >             <xsl:otherwise>
: >                    <td> blablabla </td>
: >             </xsl:otherwise>
: >         </xsl:case>
: >      </xsl:for>
: > </table>
: >
: > Zvi wrote:
: >
: > > try this:
: > >
: > > <table>
: > >      <xsl:for-each select="group">
: > >          <xsl:if test="position() mod 4 = 0">
: > >              <tr>
: > >         </xsl:if>
: > >          <td> blablabla </td>
: > >          <xsl:if test="position() mod 4 =0">
: > >              </tr>
: > >          </xsl:if>
: > >      </xsl:for>
: > > </table>
: > >
: > > Holger Schmidt wrote:
: > >
: > > > Hi,
: > > > I have a xml file with several items called <group>
: > > > now i want to build table with 4 <group> items in a row
: > > >
: > > > I open a table and start the first row, then i insert the TD's
within
: > > > a <xsl:for-each select="group"> loop
: > > > after every 4th TD i want to close the row and then start a new one.
: > > >
: > > > However for some reason the parser has a problem with inserting the
</tr> <tr>
: > > > every 4th row. but when i use text instead of tags " <tr> -> '[' and
<td>
: > > > -> '('  "
: > > > everyting looks like it should be.
: > > >
: > > > The parser thinks i don't close the <xsl:if> tag.
: > > > Probably im doing something i shouldn't, but what other way could i
go?
: > > >
: > > > this is my sample code which is not working
: > > >
: > > > <table>
: > > >    <tr>
: > > >      <xsl:for-each select="group">
: > > >      <td> blablabla </td>
: > > >      <xsl:if test="not(position() mod 4)">
: > > >        </tr> <tr>
: > > >      </xsl:if>
: > > >    </tr>
: > > > </table>
: > > >
: > > > and this the one that is working (but not usefull)
: > > >
: > > > <table>
: > > >    <xsl:text>[</xsl:text>
: > > >      <xsl:for-each select="group">
: > > >      <xsl:text>(</xsl:text> blablabla <xsl:text>)</xsl:text>
: > > >      <xsl:if test="not(position() mod 4)">
: > > >        <xsl:text>] [ </xsl:text>
: > > >      </xsl:if>
: > > >     <xsl:text>]</xsl:text>
: > > > </table>
: > > >
: > > > H.
: > > >
: > > > --
: > > > Holger Schmidt  - email: hschmidt@chronolabs.de
: > > > phone: ++4989 55869988  -  fax: ++4989 55869966
: > > > Chronolabs GmbH - Landwehrstr. 5 - 80336 Munich
: > > >
: > >
> ---------------------------------------------------------------------
: > > > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
: > > > For additional commands, e-mail: cocoon-users-help@xml.apache.org
: > >
: > > ---------------------------------------------------------------------
: > > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
: > > For additional commands, e-mail: cocoon-users-help@xml.apache.org
: >
: > ---------------------------------------------------------------------
: > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
: > For additional commands, e-mail: cocoon-users-help@xml.apache.org
:
:
: ---------------------------------------------------------------------
: To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
: For additional commands, e-mail: cocoon-users-help@xml.apache.org
:


Re: conditional generation ???

Posted by Zvi <th...@ifrance.com>.
sorry again,

this one wrong too,
you need to use nested loops, or use one loop and actually generate each table raw...
again sorry for wrong answers...


Zvi wrote:

> sorry :))
>
> I was thinking about something like this, not tried, but u need to think in this
> direction...
>
> <table>
>      <xsl:for-each select="group">
>         <xsl:case>
>              <xsl:when test="position() mod 4 = 0">
>                  <tr>
>                      <td> blablabla </td>
>                   </tr>
>              </xsl:when>
>             <xsl:otherwise>
>                    <td> blablabla </td>
>             </xsl:otherwise>
>         </xsl:case>
>      </xsl:for>
> </table>
>
> Zvi wrote:
>
> > try this:
> >
> > <table>
> >      <xsl:for-each select="group">
> >          <xsl:if test="position() mod 4 = 0">
> >              <tr>
> >         </xsl:if>
> >          <td> blablabla </td>
> >          <xsl:if test="position() mod 4 =0">
> >              </tr>
> >          </xsl:if>
> >      </xsl:for>
> > </table>
> >
> > Holger Schmidt wrote:
> >
> > > Hi,
> > > I have a xml file with several items called <group>
> > > now i want to build table with 4 <group> items in a row
> > >
> > > I open a table and start the first row, then i insert the TD's  within
> > > a <xsl:for-each select="group"> loop
> > > after every 4th TD i want to close the row and then start a new one.
> > >
> > > However for some reason the parser has a problem with inserting the </tr> <tr>
> > > every 4th row. but when i use text instead of tags " <tr> -> '[' and <td>
> > > -> '('  "
> > > everyting looks like it should be.
> > >
> > > The parser thinks i don't close the <xsl:if> tag.
> > > Probably im doing something i shouldn't, but what other way could i go?
> > >
> > > this is my sample code which is not working
> > >
> > > <table>
> > >    <tr>
> > >      <xsl:for-each select="group">
> > >      <td> blablabla </td>
> > >      <xsl:if test="not(position() mod 4)">
> > >        </tr> <tr>
> > >      </xsl:if>
> > >    </tr>
> > > </table>
> > >
> > > and this the one that is working (but not usefull)
> > >
> > > <table>
> > >    <xsl:text>[</xsl:text>
> > >      <xsl:for-each select="group">
> > >      <xsl:text>(</xsl:text> blablabla <xsl:text>)</xsl:text>
> > >      <xsl:if test="not(position() mod 4)">
> > >        <xsl:text>] [ </xsl:text>
> > >      </xsl:if>
> > >     <xsl:text>]</xsl:text>
> > > </table>
> > >
> > > H.
> > >
> > > --
> > > Holger Schmidt  - email: hschmidt@chronolabs.de
> > > phone: ++4989 55869988  -  fax: ++4989 55869966
> > > Chronolabs GmbH - Landwehrstr. 5 - 80336 Munich
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> > > For additional commands, e-mail: cocoon-users-help@xml.apache.org
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> > For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org


Re: conditional generation ???

Posted by Zvi <th...@ifrance.com>.
sorry :))

I was thinking about something like this, not tried, but u need to think in this
direction...

<table>
     <xsl:for-each select="group">
        <xsl:case>
             <xsl:when test="position() mod 4 = 0">
                 <tr>
                     <td> blablabla </td>
                  </tr>
             </xsl:when>
            <xsl:otherwise>
                   <td> blablabla </td>
            </xsl:otherwise>
        </xsl:case>
     </xsl:for>
</table>


Zvi wrote:

> try this:
>
> <table>
>      <xsl:for-each select="group">
>          <xsl:if test="position() mod 4 = 0">
>              <tr>
>         </xsl:if>
>          <td> blablabla </td>
>          <xsl:if test="position() mod 4 =0">
>              </tr>
>          </xsl:if>
>      </xsl:for>
> </table>
>
> Holger Schmidt wrote:
>
> > Hi,
> > I have a xml file with several items called <group>
> > now i want to build table with 4 <group> items in a row
> >
> > I open a table and start the first row, then i insert the TD's  within
> > a <xsl:for-each select="group"> loop
> > after every 4th TD i want to close the row and then start a new one.
> >
> > However for some reason the parser has a problem with inserting the </tr> <tr>
> > every 4th row. but when i use text instead of tags " <tr> -> '[' and <td>
> > -> '('  "
> > everyting looks like it should be.
> >
> > The parser thinks i don't close the <xsl:if> tag.
> > Probably im doing something i shouldn't, but what other way could i go?
> >
> > this is my sample code which is not working
> >
> > <table>
> >    <tr>
> >      <xsl:for-each select="group">
> >      <td> blablabla </td>
> >      <xsl:if test="not(position() mod 4)">
> >        </tr> <tr>
> >      </xsl:if>
> >    </tr>
> > </table>
> >
> > and this the one that is working (but not usefull)
> >
> > <table>
> >    <xsl:text>[</xsl:text>
> >      <xsl:for-each select="group">
> >      <xsl:text>(</xsl:text> blablabla <xsl:text>)</xsl:text>
> >      <xsl:if test="not(position() mod 4)">
> >        <xsl:text>] [ </xsl:text>
> >      </xsl:if>
> >     <xsl:text>]</xsl:text>
> > </table>
> >
> > H.
> >
> > --
> > Holger Schmidt  - email: hschmidt@chronolabs.de
> > phone: ++4989 55869988  -  fax: ++4989 55869966
> > Chronolabs GmbH - Landwehrstr. 5 - 80336 Munich
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> > For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org


Re: conditional generation ???

Posted by Zvi <th...@ifrance.com>.
try this:

<table>
     <xsl:for-each select="group">
         <xsl:if test="position() mod 4 = 0">
             <tr>
        </xsl:if>
         <td> blablabla </td>
         <xsl:if test="position() mod 4 =0">
             </tr>
         </xsl:if>
     </xsl:for>
</table>

Holger Schmidt wrote:

> Hi,
> I have a xml file with several items called <group>
> now i want to build table with 4 <group> items in a row
>
> I open a table and start the first row, then i insert the TD's  within
> a <xsl:for-each select="group"> loop
> after every 4th TD i want to close the row and then start a new one.
>
> However for some reason the parser has a problem with inserting the </tr> <tr>
> every 4th row. but when i use text instead of tags " <tr> -> '[' and <td>
> -> '('  "
> everyting looks like it should be.
>
> The parser thinks i don't close the <xsl:if> tag.
> Probably im doing something i shouldn't, but what other way could i go?
>
> this is my sample code which is not working
>
> <table>
>    <tr>
>      <xsl:for-each select="group">
>      <td> blablabla </td>
>      <xsl:if test="not(position() mod 4)">
>        </tr> <tr>
>      </xsl:if>
>    </tr>
> </table>
>
> and this the one that is working (but not usefull)
>
> <table>
>    <xsl:text>[</xsl:text>
>      <xsl:for-each select="group">
>      <xsl:text>(</xsl:text> blablabla <xsl:text>)</xsl:text>
>      <xsl:if test="not(position() mod 4)">
>        <xsl:text>] [ </xsl:text>
>      </xsl:if>
>     <xsl:text>]</xsl:text>
> </table>
>
> H.
>
> --
> Holger Schmidt  - email: hschmidt@chronolabs.de
> phone: ++4989 55869988  -  fax: ++4989 55869966
> Chronolabs GmbH - Landwehrstr. 5 - 80336 Munich
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org