Altova Mailing List Archives


Re: [xsl] assigned variable value is changing

From: Ganesh Babu N <nbabuganesh@-----.--->
To: xsl-list@-----.------------.---
Date: 8/3/2009 7:47:00 AM
Hai,

In the Name attribute i am capturing column number: row number.

Check the row[2]. In that we are having only 2 <entry>s instead of 3
because of the colspan.
So in my output i am increasing the column number of the 2nd <entry>
by the colspan value.

so for 2nd entry the value of @Name  is 2:1

Up to here the code is working correctly. after that in the column
number i am getting NaN. Even though i have included test conditions.

Regards,
Ganesh

On Sat, Aug 1, 2009 at 6:25 PM, Martin Honnen<Martin.Honnen@g...> wrote:
> Ganesh Babu N wrote:
>
>> 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>
>>
>
>> 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>
>
>> 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.
>
> Can you explain in plain English what you want to check? You have a template
> matching 'entry' elements and then you have an expression
>
>  contains(preceding-sibling::entry[1],@namest)
>
> In your posted input there are only two 'entry' elements at all that have a
> 'namest' attribute, the first 'entry' element in the first 'row' element and
> the first 'entry' element in the second 'row' element. Both do not have any
> preceding-sibling::entry so even for the 'entry' elements having 'namest'
> attribute I am not sure what you want to check.
>
> The behaviour of contains is defined for such cases
> (http://www.w3.org/TR/xpath-functions/#func-contains) but it is rather
> difficult to understand what you want to check for if all evaluations of the
> expressions against the sample XML result in such edge cases of one or two
> arguments being the empty sequence.
>
>
> --
>
>        Martin Honnen
>        http://msmvps.com/blogs/martin_honnen/
>
> --~------------------------------------------------------------------
> 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@l...>
> --~--
>
>

--~------------------------------------------------------------------
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@l...>
--~--

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.