Re: [xslt] ?Bug/Mystery - Xpath last() function - libxml2 2.6.16 r2

I have installed latest versions on FC2.
Problem still persists - short self-contained example files attached.

[miket www BUGS]$ xsltproc -V
Using libxml 20618, libxslt 10113 and libexslt 811
xsltproc was compiled against libxml 20618, libxslt 10113 and libexslt 811
libxslt 10113 was compiled against libxml 20618
libexslt 811 was compiled against libxml 20618
[miket www BUGS]$ rpm -q libxml2 libxslt
[miket www BUGS]$ ls -l
total 12
-rw-rw-r--  1 miket miket  165 Mar 20 17:49 error_output.xml
-rw-rw-r--  1 miket miket 1499 Mar 20 17:45 tab-idx.xml
-rwxr-xr-x  1 miket miket 1635 Mar 20 17:48 xpath.xsl

Attached files show the error.

xsltproc xpath.xsl tab-idx.xml
     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <output>
     3 <span>Previous Table (ID=3)</span>
     4 <span>Previous TABLE (ID=2)</span>
     5 <span>Previous TABLE (ID=2)</span>
     6 </output>

Changing line #20 in xpath.xsl from:
20 <xsl:variable name='TabPrev1' select='( ($XTAB/preceding-sibling::TABLE[1]) | ($XIDX/TABLE[last()]) )[1]'/>
20 <xsl:variable name='TabPrev1' select='( ($XTAB/preceding-sibling::TABLE[1]) | ($XIDX/TABLE[$TOT]) )[1]'/>
and then running
xsltproc xpath.xsl tab-idx.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <output>
3 <span>Previous Table (ID=3)</span>
4 <span>Previous TABLE (ID=3)</span>
5 <span>Previous TABLE (ID=3)</span>
6 </output>

Let me know if further info required.


Daniel Veillard wrote:

On Sun, Mar 20, 2005 at 01:59:54PM +0000, Mike Trotman wrote:


I have a strange (=incorrect+weird) behaviour when using libxml2 via xsltproc (and Perl XML:::LibXML/LibXSLT/AxKit)
It looks like using the 'last()' positional function corrupts a nodeset - or something more subtle
- which also affect a subsequent Xpath match!!
(and I don't think I'm doing anything stupid.)


I haven't managed to find an FC2 version of the latest libxml2 yet - but don't see this listed in any bug fixes.

1/ use the latest version, 2.6.18 and libxslt-1.1.13 . To use them on
FC2 grab the src.rpm from and use rpm --rebuild libxml2-2.6.18-1.src.rpm and similar for libxslt.
2/ if the problem persists provide full reproductible test case using
xsltproc, as mail or bugzilla attachements of the stylesheet and
the xml input showing the problem. Debugging partial stylesheets
is not possible,



<xsl:stylesheet version="1.0" xmlns:xsl="";
<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration='no' media-type='text/html' indent='yes'/>

<xsl:template match="/">
	<xsl:apply-templates                select='/XMLTABS/SECTIONS/SECTION/TABLES/TABLE[4]'>
		<xsl:with-param name='XIDX' select='/XMLTABS/SECTIONS/SECTION/TABLES'/>
<!-- ============================================================ -->
<xsl:template match='TABLE' >
<xsl:param name='XIDX' select='/..'/>

<xsl:variable name='TOT' select='count($XIDX/TABLE)'/>
<xsl:variable name='XTAB' select='$XIDX/TABLE[ ID = current()/@ID]'/>
<xsl:variable name='TIDX' select='count($XTAB/preceding-sibling::TABLE)+1'/>
<xsl:variable name='TabPrev' select='( $XIDX/TABLE[$TIDX - 1] | $XIDX/TABLE[$TOT] )[1]'/>
<xsl:variable name='TabPrev1' select='( ($XTAB/preceding-sibling::TABLE[1]) | ($XIDX/TABLE[$TOT]) )[1]'/>
<xsl:variable name='TabPrev2' select='( $XTAB/preceding-sibling::TABLE[1] | $XIDX/TABLE[$TOT] )[1]'/> 

<xsl:variable name='IDPrev' select='$TabPrev/@ID'/>
<xsl:variable name='IDPrev1' select='$TabPrev1/@ID'/>
<xsl:variable name='IDPrev2' select='$TabPrev1/@ID'/> 

<span>Previous Table (ID=<xsl:value-of select='$IDPrev'/>)</span><xsl:text>
<span>Previous TABLE (ID=<xsl:value-of select='$IDPrev1'/>)</span><xsl:text> 
<span>Previous TABLE (ID=<xsl:value-of select='$IDPrev2'/>)</span><xsl:text> 
<!-- ============================================================ -->
<?xml version="1.0" encoding="UTF-8"?>
<span>Previous Table (ID=3)</span>
<span>Previous TABLE (ID=2)</span> 
<span>Previous TABLE (ID=2)</span> 
<?xml version="1.0" encoding="UTF-8"?>
<XMLTABS version="0.1">
        <TABLE ID="1" tableno="0001"> </TABLE>
        <TABLE ID="2" tableno="0002"> </TABLE>
        <TABLE ID="3" tableno="0003"> </TABLE>
        <TABLE ID="4" tableno="0004"> </TABLE>
        <TABLE ID="5" tableno="0005"> </TABLE>
        <TABLE ID="6" tableno="0006"> </TABLE>
        <TABLE ID="7" tableno="0007"> </TABLE>
        <TABLE ID="8" tableno="0008"> </TABLE>
        <TABLE ID="8M" tableno="0009"> </TABLE>
        <TABLE ID="9M" tableno="0010"> </TABLE>
        <TABLE ID="10" tableno="0011"> </TABLE>
        <TABLE ID="11" tableno="0012"> </TABLE>
        <TABLE ID="12M" tableno="0013"> </TABLE>
        <TABLE ID="13M" tableno="0014"> </TABLE>
        <TABLE ID="14" tableno="0015"> </TABLE>
        <TABLE ID="15" tableno="0016"> </TABLE>
        <TABLE ID="16" tableno="0017"> </TABLE>
        <TABLE ID="17" tableno="0018"> </TABLE>
        <TABLE ID="18" tableno="0019"> </TABLE>
        <TABLE ID="19" tableno="0020"> </TABLE>
        <TABLE ID="20" tableno="0021"> </TABLE>
        <TABLE ID="21" tableno="0022"> </TABLE>
        <TABLE ID="22" tableno="0023"> </TABLE>
        <TABLE ID="23" tableno="0024"> </TABLE>
        <TABLE ID="24" tableno="0025"> </TABLE>
        <TABLE ID="25" tableno="0026"> </TABLE>
        <TABLE ID="26" tableno="0027"> </TABLE>
        <TABLE ID="27" tableno="0028"> </TABLE>
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.7.4 - Release Date: 18/03/2005

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]