You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by PATEL Ashish /FTR&D <as...@rd.francetelecom.com> on 2001/05/09 19:24:00 UTC
How to change default encoding of Document object?
Hi Everybody,
I am new to this group and Xerces-J. I am working on a Java Class which
creates a new Document object using available Java Beans (Data Objects).
The class creates a new org.w3c.dom.Document object using
org.w3c.dom.DocumentType object. The created document object has default
encoding UTF-8.
I have a requirement to support unicode and for that I need to change the
encoding type of the document object.
Is there any way by which I can change the encoding type of created document
object to a desired one?
Here is the partial code for your reference:
..........
//create a document type
DOMImplementationImpl domImpl = new DOMImplementationImpl();
String dtdPath = sBuilderProperties.getProperty("DTD_PATH")+SEPARATOR_CHAR+
dtdName;
DocumentType docType =
domImpl.createDocumentType(ROOT_ELEMENT,null,dtdPath);
//define document with a doctype
Document preferenceDoc= new DocumentImpl(docType);
// create Root Element
Element root = preferenceDoc.createElement(ROOT_ELEMENT);
// create other elements
........
Thanking you in anticipation,
Ashish Patel
France Telecom R&D