Re: createTextNode and special characters

This is correct operation.

The DOM API assumes you're already talking about the content of the
document, not its XML syntactic representation. If you create a text node
containing the & character using the DOM calls, it's assumed you really
mean the & character, _NOT_ the & introducing a numeric character reference
or entity reference.

To insert a special character, simply insert the character directly into
the text string, in its UTF-16 form. I don't know enough Javascript to tell
you how to code that, but it should be possible.

To insert an entity reference, you want to use the createEntityReference
call rather than the createTextNode call.
 var t = document.createEntityReference('forall');
This may not work if your  DOM doesn't know which DTD you're using and/or
hasn't retained a list of which entities are being defined (and thus
doesn't know what "forall" represents).

>How do I ask my parser to retain Entity Reference?
>How do I tell the DOM generator to "expand" entity references?

See the docs for your parser.



______________________________________
Joe Kesselman  / IBM Research

Received on Tuesday, 28 May 2002 14:55:20 UTC