function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jamz_2010Jamz_2010 

XMLStreamWriter Doctype

Hi,

 

I'm just using the XMLStreamWriter to generate an XML String which I am then passing to a web service. I need to generate a string that starts:

 

 

<?xml version="1.0" standalone="no"?>
<!DOCTYPE PRICEREQUEST SYSTEM  \'http://164.39.41.88:81/PriceCheckerDTD1.0/PriceRequestIN.dtd\'>

So far I have:

 

 

XmlStreamWriter w = new XmlStreamWriter();
w.writeStartDocument(null, '1.0');

But I can't see anyway of adding the standalone attribute to the document start or the DOCTYPE tag to the next line.

 

Does anyone know how this can be achieved using the XMLStreamWriter?

 

Cheers

 

James

 

 

 

Sulabh KapoorSulabh Kapoor

Hi,

 

Did you get any answer to your below query? Even I am facing the same concern

Jamz_2010Jamz_2010

Hi,

 

Sadly not, the only way I could get this to work was to insert the plain text directly into the XML generator...

 

Sorry about that

 

James

Shashank RunthalaShashank Runthala
I know its too late but just in case someone in the future face the same issue then I am suggesting a workaround here:
XmlStreamWriter w = new XmlStreamWriter();
w.writeStartDocument('utf-8', '1.0');
w.writeStartElement(null, '!DOCTYPE DATASET SYSTEM "gdpdu-01-09-2004.dtd"', null);
Sytem.debug(w.getXmlString());

This will give you the output as:
 

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE DATASET SYSTEM "gdpdu-01-09-2004.dtd">

So this might will get your work done.