This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Any changes if two ancestor nodes instead of one


It's me again.Finally I found the answer for displaying every 2 elements in
one row.But I get the result only if there is one root element.If I have an
additional node other than the root node,I cant get the results in the right
way.

If my xml is 

<names>
	<name>1</name>
	<name>2</name>
	....
	....
	....
</names>

I get the output like

1 2
3 4
5

using this xsl

<xsl:template match="/">  
<TABLE>  
<xsl:variable name="newrow" select='2'/>  
<xsl:apply-templates select="//name[position() mod $newrow = 1]">  
<xsl:with-param name='newrow' select='$newrow'/>  
</xsl:apply-templates>   
</TABLE>  
</xsl:template>  
<xsl:template match="name">  
<xsl:param name="newrow"/>  
<TR>  
<TD><xsl:value-of select="."/></TD>   
<xsl:apply-templates select="following::name[position() < $newrow]"
mode='somemode'/>   
</TR> 
</xsl:template>  
<xsl:template match="name" mode='somemode'>  
<xsl:param name="newrow"/>  
<TD><xsl:value-of select="."/></TD>  
</xsl:template>  


But if I add one more node between names and name node like 

<names>
	<nameinfo>
		<name>1<name>
	</nameinfo>
	<nameinfo>
		<name>2<name>
	</nameinfo>
	(etc)

</names>

Im getting 
1 2
2 3
3 4
4 5
5

Im guessing that since I have a preceding nameinfo node for every other name
node,it's giving me this error.Am I right?.Any help is appreciated.

Thanx,
Francis

 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]