xsl-list
[Top] [All Lists]

[xsl] assigned variable value is changing

2009-08-01 03:58:53
Dear All,

input :

                                <tbody>
                                        <row>
                                                <entry namest="c1" nameend="c3" 
align="left" valign="top">Table
1 Title</entry>
                                        </row>
                                        <row>
                                                <entry namest="c1" nameend="c2" 
align="left" valign="top">Table
1 TH C1 R1 and TH C2 R1 merged</entry>
                                                <entry align="left" 
valign="top">Table 1 TH C3 R1</entry>
                                        </row>
                                        <row>
                                                <entry align="left" 
valign="top">Table 1 TH C1 R2</entry>
                                                <entry align="left" 
valign="top">Table 1 TH C2 R2</entry>
                                                <entry align="left" 
valign="top">Table 1 TH C3 R2</entry>
                                        </row>
                                        <row>
                                                <entry align="left" 
valign="top">Table 1 TB C1 R4</entry>
                                                <entry align="left" 
valign="top">Table 1 TB C2 R4</entry>
                                                <entry align="left" 
valign="top">Table 1 TB C3 R4</entry>
                                        </row>
                                        <row>
                                                <entry align="left" 
valign="top">Table 1 TB C1 R5</entry>
                                                <entry align="left" 
valign="top" morerows="1">Table 1 TB C2 R5
and TB C2 R6 are merged</entry>
                                                <entry align="left" 
valign="top">Table 1 TB C3 R5</entry>
                                        </row>
                                        <row>
                                                <entry align="left" 
valign="top">Table 1 TB C1 R6</entry>
                                                <entry align="left" 
valign="top">Table 1 TB C3 R6</entry>
                                        </row>
                                </tbody>


Output expected:

<table HeaderRowCount="0" FooterRowCount="0" BodyRowCount="6" ColumnCount="3">
   <cell Name="0:0" RowSpan="1" ColumnSpan="3">Table 1 Title</cell>
   <cell Name="0:1" RowSpan="1" ColumnSpan="2">Table 1 TH C1 R1 and TH
C2 R1 merged</cell>
   <cell Name="2:1" RowSpan="1" ColumnSpan="1">Table 1 TH C3 R1</cell>
   <cell Name="0:2" RowSpan="1" ColumnSpan="1">Table 1 TH C1 R2</cell>
   <cell Name="1:2" RowSpan="1" ColumnSpan="1">Table 1 TH C2 R2</cell>
   <cell Name="2:2" RowSpan="1" ColumnSpan="1">Table 1 TH C3 R2</cell>
   <cell Name="0:3" RowSpan="1" ColumnSpan="1">Table 1 TB C1 R4</cell>
   <cell Name="1:3" RowSpan="1" ColumnSpan="1">Table 1 TB C2 R4</cell>
   <cell Name="2:3" RowSpan="1" ColumnSpan="1">Table 1 TB C3 R4</cell>
   <cell Name="0:4" RowSpan="1" ColumnSpan="1">Table 1 TB C1 R5</cell>
   <cell Name="1:4" RowSpan="2" ColumnSpan="1">Table 1 TB C2 R5 and TB
C2 R6 are merged</cell>
   <cell Name="2:4" RowSpan="1" ColumnSpan="1">Table 1 TB C3 R5</cell>
   <cell Name="0:5" RowSpan="1" ColumnSpan="1">Table 1 TB C1 R6</cell>
   <cell Name="2:5" RowSpan="1" ColumnSpan="1">Table 1 TB C3 R6</cell>
</table>

Code tried:

        <xsl:template match="entry">
                <xsl:param name="colc">
                        <xsl:number level="single" count="entry"/>
                </xsl:param>
                <cell>
                        <xsl:attribute name="Name">
                                <xsl:variable name="rowc">
                                        <xsl:number level="any" count="row"/>
                                </xsl:variable>
                                <xsl:if 
test="contains(preceding-sibling::entry[1],@namest)">
                                        <xsl:value-of select="$colc - 1 +
number(substring-after(preceding-sibling::entry[1]/@nameend,'c')) -
number(substring-after(preceding-sibling::entry[1]/@namest,'c'))"/>
                                </xsl:if>
                                <xsl:if 
test="not(contains(preceding-sibling::entry[1],@namest))">
                                        <xsl:value-of select="$colc - 1"/>
                                </xsl:if>
                                <xsl:text>:</xsl:text>
                                <xsl:value-of select="$rowc - 1"/>
                        </xsl:attribute>
</xsl:template>


Output from the code:

<table HeaderRowCount="0" FooterRowCount="0" BodyRowCount="6" ColumnCount="3">
   <cell Name="0:0" RowSpan="1" ColumnSpan="3">Table 1 Title</cell>
   <cell Name="0:1" RowSpan="1" ColumnSpan="2">Table 1 TH C1 R1 and TH
C2 R1 merged</cell>
   <cell Name="2:1" RowSpan="1" ColumnSpan="1">Table 1 TH C3 R1</cell>
   <cell Name="NaN:2" RowSpan="1" ColumnSpan="1">Table 1 TH C1 R2</cell>
   <cell Name="NaN:2" RowSpan="1" ColumnSpan="1">Table 1 TH C2 R2</cell>
   <cell Name="NaN:2" RowSpan="1" ColumnSpan="1">Table 1 TH C3 R2</cell>
   <cell Name="NaN:3" RowSpan="1" ColumnSpan="1">Table 1 TB C1 R4</cell>
   <cell Name="NaN:3" RowSpan="1" ColumnSpan="1">Table 1 TB C2 R4</cell>
   <cell Name="NaN:3" RowSpan="1" ColumnSpan="1">Table 1 TB C3 R4</cell>
   <cell Name="NaN:4" RowSpan="1" ColumnSpan="1">Table 1 TB C1 R5</cell>
   <cell Name="NaN:4" RowSpan="2" ColumnSpan="1">Table 1 TB C2 R5 and
TB C2 R6 are merged</cell>
   <cell Name="NaN:4" RowSpan="1" ColumnSpan="1">Table 1 TB C3 R5</cell>
   <cell Name="NaN:5" RowSpan="1" ColumnSpan="1">Table 1 TB C1 R6</cell>
   <cell Name="NaN:5" RowSpan="1" ColumnSpan="1">Table 1 TB C3 R6</cell>
</table>


I have declared a param "colc" and i am manipulating according to the
condition. But when i use condition the value of "colc" is changing.

I am unable to understand why the value is changing and how to stop
this change.

Regards,
Ganesh

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--