php.net |  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
Votes:1
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
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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-12 17:05 UTC] sniper@php.net
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 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] sniper@php.net
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,
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-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

#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.
 [2005-08-15 19:17 UTC] rrichards@php.net
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
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 24 05:01:32 2024 UTC