Mombu the Php Forum sponsored links

Go Back   Mombu the Php Forum > Php > #31130 : DomDo***ent::saveHTML() produces outdated HTML
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 29th February 18:14
php-bugs
External User
 
Posts: 1
Default #31130 : DomDo***ent::saveHTML() produces outdated HTML



From: tom at whyscream dot net
Operating system: Linux (gentoo)
PHP version: 5.0.3
PHP Bug Type: DOM XML related
Bug description: DomDo***ent::saveHTML() produces outdated HTML

Description:
------------
The HTML that is generated by DomDo***ent::saveHTML() (and probably
saveHTMLFile() too) does not validate as XHTML (as in '1.0 Transitional').
In stead it follows common practice for HTML4.
Since some time, it's Good Practice (TM) to use simple rules like:
- always give a value to an attribute
- close single-tag elements with a '/>' instead of '>'
etc.

All common browsers understand this syntax, even when a HTML 4.0 DTD is
specified.

With the current implementation, it's impossible to create valid XHTML
(snippets) using the php5 DOM extension.

Reproduce code:
---------------
$doc = new DomDo***ent();
$input = $doc->createElement('input');
$input->setAttribute('type', 'checkbox');
$input->setAttribute('checked', 'checked');
$doc->appendChild($input);
echo $doc->saveHTML();

Expected result:
----------------
This should generate a string like:
<input type="checkbox" checked="checked" />
which is valid XHTML.

Actual result:
--------------
The generated string looks like this:
<input type="checkbox" checked>
This code gives 2 parse errors:
- no value for attribute 'checked'
- end tag for 'input' omitted (i,e, missing the forward slash)

--
Edit bug report at http://bugs.php.net/?id=31130&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31130&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31130&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31130&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=31130&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=31130&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=31130&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=31130&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=31130&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=31130&r=support
Expected behavior: http://bugs.php.net/fix.php?id=31130&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=31130&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=31130&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=31130&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31130&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=31130&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=31130&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=31130&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=31130&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=31130&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=31130&r=mysqlcfg
  Reply With Quote


  sponsored links


2 29th February 18:15
External User
 
Posts: 1
Default #31130 : DomDo***ent::saveHTML() produces outdated HTML



ID: 31130
Updated by: derick@php.net
Reported By: tom at whyscream dot net
-Status: Open
+Status: Feedback
Bug Type: DOM XML related
Operating System: Linux (gentoo)
PHP Version: 5.0.3
New Comment:

Tried ->saveXML() ?


Previous Comments:
------------------------------------------------------------------------

[2004-12-16 18:36:03] tom at whyscream dot net

Description:
------------
The HTML that is generated by DomDo***ent::saveHTML() (and probably
saveHTMLFile() too) does not validate as XHTML (as in '1.0
Transitional'). In stead it follows common practice for HTML4.
Since some time, it's Good Practice (TM) to use simple rules like:
- always give a value to an attribute
- close single-tag elements with a '/>' instead of '>'
etc.

All common browsers understand this syntax, even when a HTML 4.0 DTD is
specified.

With the current implementation, it's impossible to create valid XHTML
(snippets) using the php5 DOM extension.

Reproduce code:
---------------
$doc = new DomDo***ent();
$input = $doc->createElement('input');
$input->setAttribute('type', 'checkbox');
$input->setAttribute('checked', 'checked');
$doc->appendChild($input);
echo $doc->saveHTML();

Expected result:
----------------
This should generate a string like:
<input type="checkbox" checked="checked" />
which is valid XHTML.

Actual result:
--------------
The generated string looks like this:
<input type="checkbox" checked>
This code gives 2 parse errors:
- no value for attribute 'checked'
- end tag for 'input' omitted (i,e, missing the forward slash)


------------------------------------------------------------------------


--
Edit this bug report at http://bugs.php.net/?id=31130&edit=1
  Reply With Quote
3 29th February 21:45
External User
 
Posts: 1
Default #31130 : DomDo***ent::saveHTML() produces outdated HTML


ID: 31130
Updated by: chregu@php.net
Reported By: tom at whyscream dot net
-Status: Feedback
+Status: Wont fix
Bug Type: DOM XML related
Operating System: Linux (gentoo)
PHP Version: 5.0.3
New Comment:

It's called saveHTML and not saveXHTML for a reason saveHTML
produces HTML 4.0 and as Derick pointed out, you have to use saveXML
(which works perfectly fine for me).

If you really want to have changed that, complain to the libxml2
people. We just use their function.


Previous Comments:
------------------------------------------------------------------------

[2004-12-16 20:03:37] derick@php.net

Tried ->saveXML() ?

------------------------------------------------------------------------

[2004-12-16 18:36:03] tom at whyscream dot net

Description:
------------
The HTML that is generated by DomDo***ent::saveHTML() (and probably
saveHTMLFile() too) does not validate as XHTML (as in '1.0
Transitional'). In stead it follows common practice for HTML4.
Since some time, it's Good Practice (TM) to use simple rules like:
- always give a value to an attribute
- close single-tag elements with a '/>' instead of '>'
etc.

All common browsers understand this syntax, even when a HTML 4.0 DTD is
specified.

With the current implementation, it's impossible to create valid XHTML
(snippets) using the php5 DOM extension.

Reproduce code:
---------------
$doc = new DomDo***ent();
$input = $doc->createElement('input');
$input->setAttribute('type', 'checkbox');
$input->setAttribute('checked', 'checked');
$doc->appendChild($input);
echo $doc->saveHTML();

Expected result:
----------------
This should generate a string like:
<input type="checkbox" checked="checked" />
which is valid XHTML.

Actual result:
--------------
The generated string looks like this:
<input type="checkbox" checked>
This code gives 2 parse errors:
- no value for attribute 'checked'
- end tag for 'input' omitted (i,e, missing the forward slash)


------------------------------------------------------------------------


--
Edit this bug report at http://bugs.php.net/?id=31130&edit=1
  Reply With Quote
4 1st March 11:42
php-bugs
External User
 
Posts: 1
Default #31130 : DomDo***ent::saveHTML() produces outdated HTML


ID: 31130
User updated by: tom at whyscream dot net
Reported By: tom at whyscream dot net
Status: Wont fix
Bug Type: DOM XML related
Operating System: Linux (gentoo)
PHP Version: 5.0.3
New Comment:

When I submitted the bug, I had some problems with saveXML() that
prevented me from producing usable XHTML with it. I found out how to
work around these issues the next day, and of course I was wrong (it
was there all the time, but I missed it while checking the manual).
Sorry for bothering you


Previous Comments:
------------------------------------------------------------------------

[2004-12-17 07:47:42] chregu@php.net

It's called saveHTML and not saveXHTML for a reason saveHTML
produces HTML 4.0 and as Derick pointed out, you have to use saveXML
(which works perfectly fine for me).

If you really want to have changed that, complain to the libxml2
people. We just use their function.

------------------------------------------------------------------------

[2004-12-16 20:03:37] derick@php.net

Tried ->saveXML() ?

------------------------------------------------------------------------

[2004-12-16 18:36:03] tom at whyscream dot net

Description:
------------
The HTML that is generated by DomDo***ent::saveHTML() (and probably
saveHTMLFile() too) does not validate as XHTML (as in '1.0
Transitional'). In stead it follows common practice for HTML4.
Since some time, it's Good Practice (TM) to use simple rules like:
- always give a value to an attribute
- close single-tag elements with a '/>' instead of '>'
etc.

All common browsers understand this syntax, even when a HTML 4.0 DTD is
specified.

With the current implementation, it's impossible to create valid XHTML
(snippets) using the php5 DOM extension.

Reproduce code:
---------------
$doc = new DomDo***ent();
$input = $doc->createElement('input');
$input->setAttribute('type', 'checkbox');
$input->setAttribute('checked', 'checked');
$doc->appendChild($input);
echo $doc->saveHTML();

Expected result:
----------------
This should generate a string like:
<input type="checkbox" checked="checked" />
which is valid XHTML.

Actual result:
--------------
The generated string looks like this:
<input type="checkbox" checked>
This code gives 2 parse errors:
- no value for attribute 'checked'
- end tag for 'input' omitted (i,e, missing the forward slash)


------------------------------------------------------------------------


--
Edit this bug report at http://bugs.php.net/?id=31130&edit=1
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666