Hi:
   I want to get a xml such as following:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pap PUBLIC "-//WAPFORUM//DTD PAP
2.0//EN"                  
"http://www.wapforum.org/DTD/pap_2.0.dtd";
[<?wap-pap-ver supported-version="1.0,2.0"?>]>
<pap /> 

   Result get by using my own code:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pap PUBLIC "-//WAPFORUM//DTD PAP
2.0//EN"                    
"http://www.wapforum.org/DTD/pap_2.0.dtd";>
<pap />
<?wap-pap-ver supported-version="1.0,2.0"?>


Source code:

OutputFormat format = new OutputFormat("xml", "UTF-8",
true);
format.setOmitXMLDeclaration(false);
format.setOmitDocumentType(false);
XMLSerializer xmlSer = new XMLSerializer(format);

try {
  DocumentBuilder builder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
  DOMImplementation domImpl =
builder.getDOMImplementation();

  DocumentType doctype = domImpl.createDocumentType("pap",
        "-//WAPFORUM//DTD PAP 2.0//EN",
        "http://www.wapforum.org/DTD/pap_2.0.dtd";);

  Document doc = domImpl.createDocument(null, "pap",
doctype); 
  ProcessingInstruction pin =
doc.createProcessingInstruction("wap-pap-ver",
            "supported-version=\"1.0,2.0\"");
  doc.appendChild(pin);
      
   synchronized(xmlSer) {
     xmlSer.reset();
     xmlSer.setOutputByteStream(out);
     xmlSer.serialize(doc);
   }
} catch(Exception e) {
  e.printStackTrace();
}



How should I do to move the processing instruction into the
document type ?

Thanks for help!


XiaoLing Zhen
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to