Share via


IMXWriter (Compact 2013)

3/26/2014

The IMXWriter interface is a complementary application programming interface (API) to the latest version of the Simple API for XML (SAX2) implementation of the Microsoft® XML Parser (MSXML). It is implemented by the following coclasses:

  • MXXMLWriter (version-independent)
  • MXXMLWriter30 (version-dependent)

When implemented, MXXMLWriter automatically handles the details of building an XML document or document fragment. For example, when connected to SAXXMLReader, MXXMLWriter accumulates data passed by events thrown by the reader and stores the data in an output string. MXXMLWriter also automatically handles the details of inserting special characters, such as the less than character (<) at the beginning of an element.

In addition, MXXMLWriter enables you to perform the following tasks:

  • Control the output of a document by setting such properties as omitXMLDeclaration, indent, and encoding.
  • Manually build an XML document by invoking methods of the ISAXContentHandler, ISAXDTDHandler, ISAXDeclHandler, and ISAXLexicalHandler interfaces.

Important

The IMXWriter interface implements the ISAXContentHandler, ISAXDTDHandler, ISAXErrorHandler, ISAXDeclHandler, and ISAXLexicalHandler interfaces. However, to enable MXXMLWriter to catch handler events passed by SAXXMLReader, you must register MXXMLWriter as the content handler, and optionally as any of the other handlers.

Ideally, MXXMLWriter connected to SAXXMLReader produces the same document as provided on the input. However, MXXMLWriter might miss content deemed ignorable by XML 1.0 specifications or may output in a different encoding. For example, national/regional encoding can be replaced with Unicode Transformation Format (UTF-8 or UTF-16). Replacing the encoding becomes useful if you use a custom SAXXMLFilter between SAXXMLReader and MXXMLWriter. Thus, you are able to perform powerful conversions on XML documents without forfeiting performance, as in the case of the Document Object Model (DOM).

The MXXMLWriter and MXXMLWriter30 coclasses output XML and match the method="xml" attribute of the XSL Transformations (XSLT) xsl:output element.

MXXMLWriter uses the generous input approach, which means it outputs what is entered. The application ensures that SAX events and parameters match those of a well-formed or valid XML document.

MXXMLWriter resets the internal state on the startDocument event of the ISAXContentHandler/IVBSAXContentHandler interface.

The following table shows the methods for this interface.

Method

Description

flush Method

This method flushes the object's internal buffer to its destination IStream/String.

The following table shows the properties for this interface.

Property

Description

byteOrderMark Property

Determines whether or not to write the Byte Order Mark (BOM).

disableOutputEscaping Property

Matches the disable-output-escaping attribute of <xsl:text> and <xsl:value-of> elements.

encoding Property

Sets encoding for the output.

indent Property

Sets whether or not to indent output.

omitXMLDeclaration Property

Forces the MXXMLWriter to skip the XML declaration.

output Property (XML SAX)

Determines the output for the MXXMLWriter.

standalone Property

Causes the MXXMLWriter to include the standalone attribute in the XML header.

version Property

Specifies the version to include in XML declarations.

Requirements

Header

msxml2.h,
msxml2.idl

Library

uuid.lib

See Also

Reference

XML SAX Interfaces