startPrefixMapping Method

MSXML 5.0 SDK

Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - SAX2 Reference

startPrefixMapping Method

Begins the scope of the prefix-URI namespace mapping.

[Visual Basic]

This method is always invoked before the corresponding startElement method.

Implementation Syntax

Sub startPrefixMapping(strPrefix As String, strURI As String)

Parameters

strPrefix
The namespace prefix being declared.
strURI
The namespace URI to which the prefix is mapped.

Return Values

If failed, the ContentHandler raises a trappable error.

Example

The following example shows how to use the startPrefixMapping method to indicate each time a namespace prefix occurs in the document.

Private Sub IVBSAXContentHandler_startPrefixMapping(strPrefix As _
String, strURI As String)
    Dim msg As String
    msg = "Start prefix mapping." & vbCrLf & _
          "strPrefix: " & strPrefix & vbCrLf & _
          "strURI: " & strURI & vbCrLf
    Form1.TextBox1.Text = Form1.TextBox1.Text & msg
End Sub
[C/C++]

This method is always invoked before the corresponding startElement event, but the order of the startPrefixMapping events is not otherwise guaranteed.

Syntax

HRESULT startPrefixMapping(
   [in] const wchar_t * pwchPrefix, 
   [in] int cchPrefix, 
   [in] const wchar_t * pwchUri
   [in] int cchUri);

Parameters

pwchPrefix [in]
The prefix being mapped.
cchPrefix [in]
The length of the prefix string, or –1 (if zero-terminated).
pwchUri [in]
The namespace URI to which the prefix is mapped.
cchUri [in]
The length of the namespace URI string.

Return Values

S_OK
The value returned if no errors occur.
E_FAIL
The value returned if the parse operation should be aborted.

Remarks

The information from this event is not necessary for normal namespace processing. The reader automatically replaces prefixes for element and attribute names when the "http://xml.org/sax/features/namespaces" feature is set to True (the default).

There are cases, however, when applications need to use prefixes in character data or in attribute values and they cannot safely be expanded automatically. In these cases, the startPrefixMapping and endPrefixMapping methods can supply the information needed to expand prefixes.

There is no guarantee that the startPrefixMapping and endPrefixMapping events are properly nested relative to each other. All startPrefixMapping events occur before the corresponding startElement event, and all endPrefixMapping events occur after the corresponding endElement event, but their order is not otherwise guaranteed.

To view reference information for Visual Basic or C/C++ only, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

endElement Method | endPrefixMapping Method | startElement Method

Applies to: ISAXContentHandler/IVBSAXContentHandler Interface