How do i add entities to the entitycollection of my XML document?

Viewed 162

I need to add a "!ENTITY" field to my document but I can't seem to find the right way to do it. Basically my code currently produces the following result :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg/>

While the result I want is this one :

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
    <!ENTITY ns_svg "http://www.w3.org/2000/svg">
    <!ENTITY ns_xlink "http://www.w3.org/1999/xlink">
]>
</svg>

My current code is this :

procedure TSVGContainer.SaveToFile(Filename: String);
var XMLDoc: IXMLDocument;
    DomImpl: IDOMImplementation;
    DocType : IDOMDocumentType;
begin
  XMLDoc := NewXMLDocument;
  DomImpl := GetDOM(sAdom4XmlVendor);
  XMLDoc.Encoding := 'utf-8';
  DocType := DomImpl.createDocumentType('svg', '-//W3C//DTD SVG 1.1//EN', 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd');
  XMLDoc.DOMDocument := DomImpl.createDocument('http://www.w3.org/2000/svg', 'svg', DocType);
  XMLDoc.Options := XMLDoc.Options+[doNodeAutoIndent];
  XMLDoc.SaveToFile(Filename);
end;
0 Answers
Related