ID: 34103
User updated by: upstaked at yahoo dot com
-Summary: saxon:line-number() returns 0
Reported By: upstaked at yahoo dot com
Status: Assigned
-Bug Type: XSLT related
+Bug Type: DOM XML related
Operating System: *
PHP Version: 5CVS-2005-08-12
Assigned To: chregu
New Comment:
Fixed with a quick hack:
Added in ext/dom/document.c under
static xmlDocPtr dom_document_parser(), line 1515
#endif
+ ctxt->linenumbers = 1;
ctxt->recovery = recover;
So I'll move this to DOM, and wait for some sort of a writable
DomDocument::$maintainLineNumbers that's properly coded.
Previous Comments:
------------------------------------------------------------------------
[2005-08-13 03:09:43] upstaked at yahoo dot com
If my debugging so far might be of any help:
Tracking down the implementation in libexslt,
http://cvs.gnome.org/viewcvs/libxslt/libexslt/saxon.c?r1=1.6&r2=1.7
in command line this requires(required) -l.
It used to work like this in xsltproc, but now it's implemented by
default:
http://cvs.gnome.org/viewcvs/libxslt/xsltproc/xsltproc.c?r1=1.2&r2=1.3
doing xmlLineNumbersDefault(1);
This is trackable right down to libxml2, in parserInternals.c, that
sets ctxt->linenumbers = xmlLineNumbersDefaultValue and the actual
value being set in SAX2.c: if (ctxt->linenumbers) { ... ret->line =
(short) ctxt->input->line; ... }
Given my limited C skills, this is all I could find out. I guess it
might actually be an issue in the dom extension.
------------------------------------------------------------------------
[2005-08-12 22:38:07] [EMAIL PROTECTED]
Christian, check it out please. (I can reproduce too)
------------------------------------------------------------------------
[2005-08-12 19:44:42] upstaked at yahoo dot com
It doesn't work; it's not fixed in latest, as of this time.
------------------------------------------------------------------------
[2005-08-12 17:05:02] [EMAIL PROTECTED]
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
------------------------------------------------------------------------
[2005-08-12 16:57:54] upstaked at yahoo dot com
Description:
------------
The saxon:line-number() function existing in EXSLT returns 0.
Reproduce code:
---------------
<?php
header('Content-type: text/plain');
$xmlStr = '<root>
<node1/>
<node2/>
</root>';
$xslStr = <<<XSL
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:saxon="http://icl.com/saxon">
<xsl:output omit-xml-declaration="yes" method="text" />
<xsl:template match="*">
<xsl:for-each select="*">
Elem <xsl:value-of select="name()" />, line number <xsl:value-of
select="saxon:line-number()" />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
XSL;
$xsl = new XSLTProcessor();
$xsl->importStyleSheet(DOMDocument::loadXML($xslStr));
echo $xsl->transformToXML(DOMDocument::loadXML($xmlStr));
?>
Expected result:
----------------
Elem node1, line number 2
Elem node2, line number 3
Actual result:
--------------
Elem node1, line number 0
Elem node2, line number 0
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34103&edit=1