Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
XML
data.xmlanalysis
mappoint.webservice
msf
msxml-webrelease
netmyservices.sdk
passport.sdk
soap
soapsdk
uddi.general
uddi.programming
uddi.specification
xml
xmlsqlwebrelease
xsl
  
 
date: Sun, 13 Apr 2008 14:29:11 +1000,    group: microsoft.public.xsl        back       


Help? - xsl if statement   
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.
date: Sun, 13 Apr 2008 14:29:11 +1000   author:   Julie Smith

Re: Help? - xsl if statement   
"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
date: Sun, 13 Apr 2008 08:50:55 +0100   author:   Anthony Jones

Re: Help? - xsl if statement   
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
>
>
date: Sun, 13 Apr 2008 18:55:20 +1000   author:   Julie Smith

Re: Help? - xsl if statement   
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/
date: Sun, 13 Apr 2008 13:27:54 +0200   author:   Martin Honnen

Re: Help? - xsl if statement   
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/
date: Mon, 14 Apr 2008 19:23:17 +1000   author:   Julie Smith

Re: Help? - xsl if statement   
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/
date: Mon, 14 Apr 2008 13:10:54 +0200   author:   Martin Honnen

Re: Help? - xsl if statement   
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/
date: Tue, 15 Apr 2008 21:53:56 +1000   author:   Julie Smith

Re: Help? - xsl if statement   
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
date: Tue, 15 Apr 2008 09:07:46 -0700 (PDT)   author:   msbalaji

Re: Help? - xsl if statement   
"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
date: Tue, 15 Apr 2008 22:35:43 -0700   author:   Joe Fawcett am

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us