Adding Processing Instructions

Problem

It is sometimes necessary to add in custom Processing Instructions to the start of the XML file you are writing out. Common examples of this are the addition of style sheet directives.
i.e.

<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="simple.xsl"?> <breakfast_menu/>

Resolution

The XmlSerializationContext object controls the details of how XML is read and written from the generated libraries.
The ProcessingInstructions collection allows new processing instructions to be added to the output XML.

Samples

  C++

LtXmlLib16::CXmlSerializationContext::GetDefaultContext().GetProcessingInstructions().push_back( _T("<?xml-stylesheet type=\"text/xsl\" href=\"simple.xsl\"?>"));

  C#

using LiquidTechnologies.Runtime.Net40; ... XmlSerializationContext.Default.ProcessingInstructions.Add( "<?xml-stylesheet type=\"text/xsl\" href=\"simple.xsl\"?>");

  Java

import com.liquid_technologies.ltxmllib16; ... XmlSerializationContext.Default.getProcessingInstructions.add( "<?xml-stylesheet type=\"text/xsl\" href=\"simple.xsl\"?>");

  Visual Basic

DefaultXmlSerializationContext.ProcessingInstructions.Add _ "<?xml-stylesheet type="text/xsl" href="simple.xsl"?>"

Sample Output

<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="simple.xsl"?> <ElmDerivedType1 ...


Notes

Description Value
Article Created 5/2/2006
Applies to Liquid XML 2005 and greater
Also See Controlling the Output XML
  Using the libraries in a multithreaded environment