You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Ronnachai Chinowutthichai <ro...@embrace.com> on 2001/02/16 12:11:18 UTC

problem inserting doctype and ProcessingInstruction

Hi Guys,

Forgive me if this question has been asked.. I had looked around in the
archive but still hasn't found any info..

Ok. What do I need to do to generate an XML output with document type
and other processing instructions in it? I have created and added those
nodes in DOM but when it serialize, nothing seems to come out...

e.g.
    Document doc= new DocumentImpl();
    DocumentType documentType =
((DocumentImpl)doc).createDocumentType("person", "person.dtd",
"SYSTEM");
    doc.appendChild(documentType);

    ProcessingInstruction pi =
doc.createProcessingInstruction("cocoon-process", "type=\"xslt\"");
    doc.appendChild(pi);

and XML output is
    STRXML = <?xml version="1.0" encoding="UTF-8"?>
    <person><name>Jeff</name><age>28</age><height>1.80</height></person>

when it should be..
    STRXML = <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE person SYSTEM "person.dtd">
    <?cocoon-process type="xslt"?>
    <person><name>Jeff</name><age>28</age><height>1.80</height></person>



rOnn c.
PS: the attach file is a test file I modified from the DOMGenerate.java
sample file.