W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2002

createTextNode and special characters

From: Immanuel Normann <normann@dfki.de>
Date: Fri, 24 May 2002 06:36:47 -0400 (EDT)
Message-Id: <200205241035.MAA22779@corp-200.dfki.uni-sb.de>
To: www-dom@w3.org
hello,

the question how to handle special characters within createTextNode() seems to 
be sufficiently discussed in this thread. Nevertheless, I didn't understand 
the solutions of the problem. Therefore I want to state the problem again as 
simple as possible. Consider the following sample code and focus on 
'createTextNode':

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
<script type="text/javascript">
function showForall() {
 var t = document.createTextNode('&forall;');
 document.body.appendChild(t);
}
</script>
  </head>
  <body onload='showForall()'>
  </body>
</html>

What I want to see after load is the respective 'forall' Symbol.
But what I actually get is '&forall;' as a (8 character long) text.

Also so 
  document.createTextNode('&#8704;') 
doesn't yield the 'forall' Symbol. And 
  document.createEntityReference('&#8704;')
is an javaScript error: "Object cannot be created in this context"


I didn't understand the following hints:
>>I'm German, so I use a lot of special characters like &auml; in my
>>pages. Are all these characters single nodes in the DOM?
>This depends on whether you've asked your parser to retain Entity Reference
>nodes or not.
How do I ask my parser to retain Entity Reference?

>If you've told the DOM generator (parser or other code) to "expand" the
>entity references, then the Text node would appear...
How do I tell the DOM generator to "expand" entity references?


Perhaps I should mention some additional information for an appropriate 
answer:
1) I am not an DOM-expert. So an answer with simple sample code would help me 
much.
2) I am using Mozilla (more precisley: Mozilla/5.0 (X11; U; Linux i686; en-US; 
rv:1.0rc2) Gecko/20020510)

Thanks for any help!

Immanuel
Received on Tuesday, 28 May 2002 14:33:45 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:56 GMT