VFPXMLProgID Property

References a COM component you can use to override the internal functionality of the CURSORTOXML( ), XMLTOCURSOR( ), and XMLUPDATEGRAM( ) functions.

You can create the COM component in Visual FoxPro, Visual C/C++, Visual Basic or any developer tool that creates COM components with the ability to implement interfaces.

_VFP.VFPXMLProgID [=cValue]

Property Value

  • cValue
    Specifies the ProgID of the COM component class whose functions override the functionality of the listed Visual FoxPro XML functions. Setting cValue to the default empty string ("") value resets use to the internal implementations of these functions.

Remarks

The class you use must implement the IVFPXML interface from the Visual FoxPro type library. To provide methods to overwrite, open the Object Browser from the Tools menu. From the Microsoft Visual FoxPro 8.0 Type Library, drag the IVFPXML interface to a program (.prg) file.

Example

The following example creates a classes that replace the CURSORTOXML( ), XMLTOCURSOR( ), and XMLUPDATEGRAM( ) functions. Create a project for these classes and add custom XML function handler code to the three methods.

DEFINE CLASS MyXMLClass AS session OLEPUBLIC
   IMPLEMENTS IVFPXML8 IN "VisualFoxPro.Application.8"

   * Replaces CURSORTOXML( ). 
   PROCEDURE IVFPXML8_CursorToXML(bstrAlias AS STRING, ; 
      nOutputFormat AS Number, nFlags AS Number, ; 
      nRecords AS Number, bstrOutputFile AS STRING, ; 
      bstrSchema AS STRING, bstrSchemaLocation AS STRING, ; 
      bstrNameSpace AS STRING, pVFP AS VARIANT) AS VARIANT ; 
      HELPSTRING "Converts from a Cursor to XML"
      * Add user code here.
   ENDPROC

   * Replaces XMLTOCURSOR( ).
   PROCEDURE IVFPXML8_XMLToCursor(pvarXMLSource AS VARIANT, ; 
      bstrCursorName AS STRING, nFlags AS Number, pVFP AS VARIANT) ; 
      AS Number HELPSTRING "Converts from XML to a Cursor"
      * Add user code here. 
   ENDPROC

   * Replaces XMLUPDATEGRAM( ).
   PROCEDURE IVFPXML8_XMLUpdateGram8( nFlags AS Number, ; 
      bstrCursorList AS STRING, pVFP AS VARIANT , ; 
      bstrSchemaLocation AS STRING ) AS VARIANT; 
      HELPSTRING "Generates an XML UpdateGram"
      * Add user code here. 
   ENDPROC

   * Included for backward compatibility with previous 
   * versions of this interface.
   PROCEDURE IVFPXML8_XMLUpdateGram(nFlags AS Number, ; 
      bstrCursorList AS STRING, pVFP AS VARIANT) AS VARIANT; 
      HELPSTRING "Generates an XML UpdateGram"
      * Add user code here.
   ENDPROC

ENDDEFINE

When you are finished, build the project into a dynamic-link library (.dll) or executable (.exe) file. Set the VFPXMLProgID property to the correct ProgID for your class. For example, if your project name is MyXMLProj, you would set VFPXMLProgID using the following line of code:

_VFP.VFPXMLProgID = "MyXMLProj.MyXMLClass"

With _VFP VFPXMLProgID set to a specific ProgID, calls to CURSORTOXML( ), XMLTOCURSOR( ), or XMLUPDATEGRAM( ) are redirected to the corresponding method in the class specified by that ProgID. A reference to _VFP is also passed to the method, providing a way to access and manipulate data cursors and memory variables. For more information, see _VFP System Variable Properties, Methods, and Events.

Prior to Visual FoxPro 8.0, XMLUPDATEGRAM( ) did not have the cSchemaLocation parameter; therefore, the interface was different. Visual Foxpro supports both interfaces and looks for the current interface first. If unsuccessful, Visual FoxPro then looks for the earlier interface.

The following is a sample class definition for the earlier interface without the cSchemaLocation parameter:

DEFINE CLASS MyXMLClass AS session OLEPUBLIC
   IMPLEMENTS IVFPXML IN "VisualFoxPro.Application.8"

   * Replaces CURSORTOXML( ). 
   PROCEDURE IVFPXML_CursorToXML(bstrAlias AS STRING, ; 
      nOutputFormat AS Number, nFlags AS Number, ; 
      nRecords AS Number, bstrOutputFile AS STRING, ; 
      bstrSchema AS STRING, bstrSchemaLocation AS STRING, ; 
      bstrNameSpace AS STRING, pVFP AS VARIANT) AS VARIANT ; 
      HELPSTRING "Converts from a Cursor to XML"
      * Add user code here. 
   ENDPROC

   * Replaces XMLTOCURSOR( ).
   PROCEDURE IVFPXML_XMLToCursor(pvarXMLSource AS VARIANT, ; 
      bstrCursorName AS STRING, nFlags AS Number, pVFP AS VARIANT) ; 
      AS Number HELPSTRING "Converts from XML to a Cursor"
      * Add user code here. 
   ENDPROC

   * Replaces XMLUPDATEGRAM( ).
   PROCEDURE IVFPXML_XMLUpdateGram(nFlags AS Number, ; 
      bstrCursorList AS STRING, pVFP AS VARIANT) AS VARIANT;
      HELPSTRING "Generates an XML UpdateGram"
      * Add user code here.
   ENDPROC

ENDDEFINE

See Also

_VFP System Variable | Viewing Type Library Information | XML Functions | CURSORTOXML( ) Function | XMLTOCURSOR( ) | XMLUPDATEGRAM( )