These forums are currently read-only due to receiving more spam than actual discussion. Sorry.

It is currently Sat Dec 02, 2017 4:16 pm Advanced search

document.write() for XML

Do you think the HTML spec should do something differently? You can discuss spec feedback here, but you should send it to the WHATWG mailing list or file a bug in the W3C bugzilla for it to be considered.

document.write() for XML

Postby PMB9 » Mon Mar 23, 2009 2:59 pm

Are there any reasons against document.write() for XML? Why don't do it like with innerHTML? May you can introduce document.XMLwrite().

Code: Select all
<h1>Example page</h1>
<script><![CDATA[
document.write("<p>Hello World</p>")
]]></script>

→ no XML problem

<p>Hello
<script><![CDATA[
document.write("World</p>")
]]></script>

→ document.write will return an error because of malformed XML code ("World</p>")
PMB9
<h3>
 
Posts: 50
Joined: Sat Jan 26, 2008 5:38 pm

Postby zcorpan » Fri Mar 27, 2009 4:48 am

What do you do when the script element is the root element?
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden

Postby JAB Creations » Fri Mar 27, 2009 5:14 am

document.write is proprietary JavaScript and has nothing to do with HTML5. It's time you spent some time reading about JavaScript nodes (which is software developer speak for elements).

Example...
http://www.w3schools.com/dom/dom_node.asp
User avatar
JAB Creations
<aside>
 
Posts: 566
Joined: Tue Mar 13, 2007 4:48 am
Location: Sarasota Florida, USA

Postby zcorpan » Mon Mar 30, 2009 7:53 am

JAB Creations wrote:document.write is proprietary

No
http://www.w3.org/TR/REC-DOM-Level-1/le ... thod-write
http://www.w3.org/TR/DOM-Level-2-HTML/h ... D-75233634
JAB Creations wrote:JavaScript
No, it's DOM
JAB Creations wrote:and has nothing to do with HTML5.

http://www.whatwg.org/specs/web-apps/cu ... ent.write()
JAB Creations wrote:It's time you spent some time reading about JavaScript nodes (which is software developer speak for elements).

Example...
http://www.w3schools.com/dom/dom_node.asp
JavaScript doesn't have nodes, it has objects. The DOM has nodes, but nodes are not the same thing as elements...
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden

Postby PMB9 » Fri Apr 17, 2009 9:25 am

zcorpan wrote:What do you do when the script element is the root element?


Let's see what firefox does with text/html:
Code: Select all
<!DOCTYPE HTML>
<script>
document.write('<title>Example page</title>')
document.write('<p>Hello World!</p>')
</script>

-->
Code: Select all
<html><head>
<script>
document.write('<title>Example page</title>')
document.write('<p>Hello World!</p>') 
</script><title>Example page</title></head><body><p>Hello World!</p></body></html>


So I propose for this XML example:
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<script xmlns="http://www.w3.org/1999/xhtml"><![CDATA[
document.write('<title>Example page</title>')
document.write('<p>Hello World!</p>')
]]></script>

-->
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<script><![CDATA[
document.write('<title>Example page</title>')
document.write('<p>Hello World!</p>')
]]></script><title>Example page</title></head><body><p>Hello World</p></body></html>
PMB9
<h3>
 
Posts: 50
Joined: Sat Jan 26, 2008 5:38 pm

Postby JAB Creations » Fri Apr 17, 2009 11:04 am

Learn real XHTML which is served as application/xhtml+xml which will not work with document.write. You're essentially proposing that HTML5 uses a hammer for a screw instead of a screwdriver.
User avatar
JAB Creations
<aside>
 
Posts: 566
Joined: Tue Mar 13, 2007 4:48 am
Location: Sarasota Florida, USA

Postby PMB9 » Fri Apr 17, 2009 12:43 pm

I actually do serve XHTML pages as application/xhtml+xml. I don't know your 'screwdriver' solution. Are you able to explain it to me?
PMB9
<h3>
 
Posts: 50
Joined: Sat Jan 26, 2008 5:38 pm


Return to Feedback on the Specs

Who is online

Users browsing this forum: No registered users and 0 guests