SAX2 C++ Common Notices
A version of this page is also available for
4/8/2010
This topic discusses the following:
- Strings
- Declaration conflicts
- Skipped entities
- XML Features
- Properties
- Return values
Strings
In the XML SAX (XMLSAX) for Windows CE 5.0 operating system (OS) implementation, all strings returned to handler callbacks consist of two parts: a pointer to the wchar buffer and the length of the string. This includes strings passed either directly, such as the element name for the startElement method, or indirectly, such as strings provided by the ISAXAttributes and ISAXLocator classes. Strings returned from these implementations are owned by the implementations, not the calling process. Therefore, their memory should not be released, freed, or deleted. Strings, represented as a pointer to the character buffer and length, may not be zero terminated.
When a string consists of both a pointer to the buffer and a length, the length always contains the correct length of the string; either it is zero-terminated or not. For input parameters, the representation of strings follows traditional zero-terminated Unicode string format, for example, rdr.putBase(L"https://microsoft.com/"). It is not guaranteed that the content of the string will still keep the value at the next call to a handler.
After any successful getProperty call, the caller should free the memory.
Note
The XMLSAX property strings are the exception to the general COM rule that system-allocated objects are allocated by the data source and freed by the consumer.
Declaration Conflicts
The XMLSAX implementation of SAX2 is nonvalidating. As a result, a validation error does not occur if the same element is declared twice, with different definitions, in an internal DTD. When element/entity declaration conflicts occur, the first declaration takes precedence.
Skipped Entities
In an entity is declared in an external DTD, XMLSAX reports them as skipped entities and the value of the non-declared (skipped) entity is defaulted to empty. However, XMLSAX does not report entities in attributes. They are quietly skipped.
XML Features
The following XML features are handled and recognized by SAXXMLReader:
"https://xml.org/sax/features/namespaces"
"https://xml.org/sax/features/namespace-prefixes"
"https://xml.org/sax/features/external-general-entities"
"https://xml.org/sax/features/external-parameter-entities"
"normalize-line-breaks"
"server-http-request"
Properties
The following properties are handled and recognized by SAXXMLReader:
"https://xml.org/sax/properties/lexical-handler"
"https://xml.org/sax/properties/declaration-handler"
"xmldecl-encoding"
"xmldecl-version"
"xmldecl-standalone"
Return Values
All handlers may return either S_OK to continue or any other non-S_OK error code. For non-S_OK error codes, parsing is aborted and the return value is returned by the parse, parseURL, or resume method.
The following table shows the general error codes most parser methods can return.
Error code | Description |
---|---|
E_POINTER |
NULL instead of the pointer to parameter. |
E_OUTOFMEMORY |
Out of memory. |
E_INVALIDARG |
Input parameter is invalid. |
E_FAIL |
General failure. |