Hi, I want to do this: <xsl:if test="true"></tr></xsl:if> However, I keep getting an error about the </tr>. How can i do this? Thanks in advance.
"Julie Smith" wrote in message news:%23DxAu7RnIHA.3940@TK2MSFTNGP05.phx.gbl... > Hi, > I want to do this: > <xsl:if test="true"></tr></xsl:if> > > However, I keep getting an error about the </tr>. How can i do this? > Since XSL is XML it needs to be well formed. You can't therefore end an element conditionally in the way above. Can you provide more detail of the problem you want to solve? -- Anthony Jones - MVP ASP/ASP.NET
I'm trying to iterate through a collection and list them in a table going horizontally, not vertically. Example of what i've currently got, but not working: <xsl:variable name="columns" select="5"/> <table> <xsl:for-each select="//People"> <xsl:if test="(position() mod $columns) = 0"><tr></xsl:if> <td> <xsl:value-of select="@name"/> </td> <xsl:if test="(position() mod $columns) = 0"></tr></xsl:if> </xsl:for-each> </table> Does that make sense? "Anthony Jones" wrote in message news:uJQEcsTnIHA.4372@TK2MSFTNGP05.phx.gbl... > > "Julie Smith" wrote in message > news:%23DxAu7RnIHA.3940@TK2MSFTNGP05.phx.gbl... >> Hi, >> I want to do this: >> <xsl:if test="true"></tr></xsl:if> >> >> However, I keep getting an error about the </tr>. How can i do this? >> > > > Since XSL is XML it needs to be well formed. You can't therefore end an > element conditionally in the way above. Can you provide more detail of > the > problem you want to solve? > > > -- > Anthony Jones - MVP ASP/ASP.NET > >
Julie Smith wrote: > I'm trying to iterate through a collection and list them in a table > going horizontally, not vertically. > Example of what i've currently got, but not working: > > <xsl:variable name="columns" select="5"/> > <table> > <xsl:for-each select="//People"> > <xsl:if test="(position() mod $columns) = 0"><tr></xsl:if> > <td> > <xsl:value-of select="@name"/> > </td> > <xsl:if test="(position() mod $columns) = 0"></tr></xsl:if> > </xsl:for-each> > </table> You need to use a different approach, like this: <table> <xsl:for-each select="//People[position() mod $columns = 0]"> <tr> <xsl:for-each select=". | following-sibling::People[position() < $colums]"> <td> <xsl:value-of select="@name"/> </td> </xsl:for-each> </tr> </xsl:for-each> </table> -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/
Thank you soooo much! I go it to work. But i have another question. What if i have a second level in the xml data? As in, //Animals/People? I tried: select="//Animals/People[position() mod $columns = 0]"> But that didn't work. Any ideas? Thank you again, Julie. "Martin Honnen" wrote in message news:%23UxXtlVnIHA.3780@TK2MSFTNGP06.phx.gbl... > Julie Smith wrote: >> I'm trying to iterate through a collection and list them in a table going >> horizontally, not vertically. >> Example of what i've currently got, but not working: >> >> <xsl:variable name="columns" select="5"/> >> <table> >> <xsl:for-each select="//People"> >> <xsl:if test="(position() mod $columns) = 0"><tr></xsl:if> >> <td> >> <xsl:value-of select="@name"/> >> </td> >> <xsl:if test="(position() mod $columns) = 0"></tr></xsl:if> >> </xsl:for-each> >> </table> > > > You need to use a different approach, like this: > <table> > <xsl:for-each select="//People[position() mod $columns = 0]"> > <tr> > <xsl:for-each select=". | following-sibling::People[position() < > $colums]"> > <td> > <xsl:value-of select="@name"/> > </td> > </xsl:for-each> > </tr> > </xsl:for-each> > </table> > > -- > > Martin Honnen --- MVP XML > http://JavaScript.FAQTs.com/
Julie Smith wrote: > Thank you soooo much! I go it to work. But i have another question. What > if i have a second level in the xml data? As in, //Animals/People? I tried: > select="//Animals/People[position() mod $columns = 0]"> > > But that didn't work. Any ideas? Provide a meaningful sample of your XML input document and tell us exactly what does not work. Do you get an error? Or do you simply not get the result you want? Which result exactly do you expect? And which result do you get? -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/
I got it working. Thank you soo much! "Martin Honnen" wrote in message news:eHA83AinIHA.4292@TK2MSFTNGP04.phx.gbl... > Julie Smith wrote: >> Thank you soooo much! I go it to work. But i have another question. What >> if i have a second level in the xml data? As in, //Animals/People? I >> tried: >> select="//Animals/People[position() mod $columns = 0]"> >> >> But that didn't work. Any ideas? > > Provide a meaningful sample of your XML input document and tell us exactly > what does not work. Do you get an error? Or do you simply not get the > result you want? Which result exactly do you expect? And which result do > you get? > > -- > > Martin Honnen --- MVP XML > http://JavaScript.FAQTs.com/
On Apr 13, 9:29 am, "Julie Smith" wrote: > Hi, > I want to do this: > <xsl:if test="true"></tr></xsl:if> > > However, I keep getting an error about the </tr>. How can i do this? > > Thanks in advance. Hi, <xsl:if test="true"><xsl:text disable-output-escaping="yes"></ tr><xsl:text></xsl:if> Regards, Balaji. M
"msbalaji" wrote in message news:0cf5b034-6a3c-4117-b5b6-1051a8f26c46@n1g2000prb.googlegroups.com... > On Apr 13, 9:29 am, "Julie Smith" wrote: >> Hi, >> I want to do this: >> <xsl:if test="true"></tr></xsl:if> >> >> However, I keep getting an error about the </tr>. How can i do this? >> >> Thanks in advance. > > Hi, > > > <xsl:if test="true"><xsl:text disable-output-escaping="yes"></ > tr><xsl:text></xsl:if> > > Regards, > Balaji. M An abomination that won't work in many scenarios, e.g. Firefox. Martin already gave the correct solution. -- Joe Fawcett (MVP - XML) http://joe.fawcett.name