|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34103 line numbering not maintained in dom document
Submitted: 2005-08-12 16:57 UTC Modified: 2005-08-15 19:17 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: upstaked at yahoo dot com Assigned: chregu (profile)
Status: Closed Package: DOM XML related
PHP Version: 5CVS-2005-08-12 OS: *
Private report: No CVE-ID: None
 [2005-08-12 16:57 UTC] upstaked at yahoo dot com
The saxon:line-number() function existing in EXSLT returns 0.

Reproduce code:
header('Content-type: text/plain');
$xmlStr = '<root>
$xslStr = <<<XSL
<xsl:stylesheet version="1.0" xmlns:xsl="" xmlns: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 = new XSLTProcessor();
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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-12 17:05 UTC]
Please try using this CVS snapshot:
For Windows:

 [2005-08-12 19:44 UTC] upstaked at yahoo dot com
It doesn't work; it's not fixed in latest, as of this time.
 [2005-08-12 22:38 UTC]
Christian, check it out please. (I can reproduce too)

 [2005-08-13 03:09 UTC] upstaked at yahoo dot com
If my debugging so far might be of any help:

Tracking down the implementation in libexslt,
in command line this requires(required) -l.

It used to work like this in xsltproc, but now it's implemented by default:
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-13 14:26 UTC] upstaked at yahoo dot com
Fixed with a quick hack:
Added in ext/dom/document.c under 
static xmlDocPtr dom_document_parser(), line 1515

+	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.
 [2005-08-15 19:17 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jul 13 08:01:29 2024 UTC