#39299 [Opn->Bgs]: Using a xsl variable in a xsl:key macth attribute does not work

From: Date: Tue, 31 Oct 2006 06:21:09 +0000
Subject: #39299 [Opn->Bgs]: Using a xsl variable in a xsl:key macth attribute does not work
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-104209@lists.php.net to get a copy of this message
ID: 39299 Updated by: chregu@php.net Reported By: pascal dot heus at gmail dot com -Status: Open +Status: Bogus Bug Type: XSLT related Operating System: GNU/Linux PHP Version: 5.1.6 New Comment: I close this bug for now, as it doesn't look like a php issue. Previous Comments: ------------------------------------------------------------------------ [2006-10-30 12:17:30] pascal dot heus at gmail dot com I guess we're both individuals with little time and varying moods. Agree it's actually likely to be a libxslt problem, I may try to report it there. If someone else ever reports something like this not working: <xsl:key name="my-key" match="$my-var" use="my-element"/> you know where it comes from: can't use a $variable in the match="" attribute. Have a nice day/night and thanks for making pHp such great product. ------------------------------------------------------------------------ [2006-10-30 08:13:04] chregu@php.net I don't even know, what's your expected output and I'm not in the mood (nor do i have the time) to analyse your xslt. Please provide a as small as possible script/xslts and tell me, what your expected output is and what you get. But at the end, I doubt it's a php issue, but a libxslt one, so you may better go there directly (try with the commandline tool xsltproc, if you get the wrong result there as well, it's defintively not a php issue...) ------------------------------------------------------------------------ [2006-10-30 02:23:46] pascal dot heus at gmail dot com <?php // Code to illustrate bug #39299 // Differences in XSLT's are at lines 56/57 echo 'pHp '.phpversion(); $xmlDom = new DomDocument(); $xmlDom->load('http://scs.gmu.edu/~rgomez/qc/xml/gmu.xml'); $xslDom = new DomDocument(); // Comment/uncomment lines below to select XSLT file $xsl = 'http://scs.gmu.edu/~rgomez/qc/xml/gmu_program_schedule_bug_fails.xslt'; //$xsl = 'http://scs.gmu.edu/~rgomez/qc/xml/gmu_program_schedule_bug_works.xslt'; echo "<p>Using $xsl</p>"; $xslDom->load($xsl); $proc = new XsltProcessor(); $xslDom = $proc->importStylesheet($xslDom); $outputDom = $proc->transformToDoc($xmlDom); echo $outputDom->saveHTML(); ?> ------------------------------------------------------------------------ [2006-10-29 17:18:46] chregu@php.net Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. ------------------------------------------------------------------------ [2006-10-29 15:24:51] pascal dot heus at gmail dot com Description: ------------ The following xsl code works fine with the Sablotron engine under pHp4 or with XMLSpy: <xsl:key name="course-key" match="/gmu/programs/program[@id=$program-id]//courseRef" use="concat(@subject,@course,@subcourse)"/> When using libxslt under pHp 5, it fails to execute. The problem comes form the $program-id variable used in the match= attribute. If I replace it with a hard coded value, the XSLT works fine: <xsl:key name="course-key" match="/gmu/programs/program[@id='csi-phd-qis']//courseRef" use="concat(@subject,@course,@subcourse)"/> This is under pHp 5.0.4 running on an institutional server, I don't have the authority to upgrade that system for further testing. Reproduce code: --------------- You can retrieve the xslt and xml file at: http://scs.gmu.edu/~rgomez/qc/xml/gmu_program_schedule_bug.xslt http://scs.gmu.edu/~rgomez/qc/xml/gmu.xml ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39299&edit=1

« previous php.bugs (#104209) next »