Search code examples
c++xmlstylesheetxerces-cxml-declaration

Adding a stylesheet declaration in my xml using Xerces-C


I have an application in c++ using Xerces-C as main xml manipulation library.

I have my DOMDocument* and my parser and I want to set declarations.

I do the following:

parser->setValidationScheme(xercesc::XercesDOMParser::Val_Never);
parser->setDoSchema(false);
parser->setLoadExternalDTD(false);

I want to add:

<?xml-stylesheet type="text/xsl" href="my_xslt.xsl"?>

How can I do it?


Solution

  • You'll need to use the createProcessingInstruction on the DOMDocument http://xerces.apache.org/xerces-c/apiDocs-3/classDOMDocument.html#ce898787ba20c00c85be63f28a358507

    Once you've created it, append it to the DocumentElement.