Programmer's Reference

xml spy
Programmer's Reference

Basic concepts
The introduction of the COM based API makes the functionality of XMLSPY 5 available to other applications. It is now possible to automate a wide range of tasks from simple file validations to complex XML content modifications using the XMLData interface. The API is also the main requirement for the built-in scripting environment of XMLSPY 5. See the chapter "Scripting" in this manual for further documentation.

XMLSPY 5 and the XMLSPY 5 API, follow the common specifications for automation servers from Microsoft. It is possible to access the methods and properties from most development environments such as C, C++, VisualBasic, Delphi and from scripting languages like VBScript and JavaScript.

To support scripting, concessions had to be made to make all parameters compatible to the VARIANT structure and allow special handling of JavaScript out-parameters (see "How to handle an event" for an example).

The following limitations have to be considered in your client code:

1. Don't hold references to objects in memory longer than you need them, especially those from the XMLData interface. If the user interacts between two calls of your client, then there is no guarantee that these references are still valid.

2. Free references explicitly.

3. Be aware that if your client code crashes instances of XMLSPY 5 may still remain in the system.

4. Don't forget to disable dialogs if the user interface is not visible.

5. See "Error handling" to avoid annoying error messages.

6. Terminate XMLSPY 5 with the "Application.Quit" method.

Top Next

© 2002 Altova


Object model

Object model

The starting point for every application which uses the XMLSPY 5 API is the "Application" object. This object contains general methods like import/export support and references to the open documents and any open project.

To create an instance of the Application object, call CreateObject("XMLSpy.Application") from VisualBasic or a similar function from your preferred development environment to create a COM object. There is no need to create any other objects, to use the complete XMLSpy API (It is in fact not even possible). All other interfaces are accessed through other objects with the Application object as the starting point.

The picture below shows you the links between the main objects of the XMLSPY 5 API:

The application object consists of the following parts:

1. Document collection and reference to the active document.

2. Reference to current project and methods for creating and opening of projects.

3. Methods to support the export to and import from databases, text files and Word documents.

4. URL management.

5. Methods for macro menu items.

Once you have created an Application object you can start using the functionality of XMLSPY 5. Most of the times you either open a project and access the documents from there or you directly open a document via the "Documents" interface.

Previous Top Next


Simple document access

Simple document access

Create and open files
Use the methods of the "Documents" interface to create and open documents. This interface is accessible via the "Application.Documents" property.

Example:

   Dim objDoc As Document
   Set objDoc = objSpy.Documents.OpenFile("C:\xmlfiles\myfile.xml", False)

Sometimes it is necessary to show a file dialog to the user to select a file. This usually happens in the scripting environment and you only need to pass True as the second parameter to OpenFile().

To create a new file use "Documents.NewFile()". Any existing file with the same path will be overwritten during the next Document.Save() call.

Documents collection
All open documents are accessible via the "Documents" collection. All collection objects in the XMLSPY 5 API conform to the Microsoft specifications. So it is possible to use the For-Each loop in VisualBasic to iterate through the open documents.

Example:

   Dim objDocs As Documents
   Dim objDoc As Document

   Set objDocs = objSpy.Documents

   For Each objDoc In objDocs
      'do something useful with your document
      objDoc.AssignXSL "C:\myXSL.xsl", False
   Next

Another way to access a document is the "Documents.Item" method. The method takes an index as a parameter and gets the corresponding document object from the collection. Please note that 0 (zero) is the first index value. "Documents.Count" retrieves the total number of documents.

Example:

   Dim objDocs As Documents
   Dim objDoc As Document

   Set objDoc = objDocs.Item(1)      'gets the first document

Validation
One common task on documents is to validate them against an assigned schema or DTD. If the XML file has no schema or DTD already assigned, use "Document.AssignSchema" or "Document.AssignDTD" to add the necessary references to the document.

Examples:

   objSpy.ActiveDocument.AssignSchema "C:\mySchema.xsd", False

or

   objSpy.ActiveDocument.AssignDTD "C:\myDTD.dtd", False

If you want the user to select a schema or DTD, pass True as the second parameter to these functions to display a file-dialog. These methods only put the reference into the document and do not check the existence of the specified file. If the file path is not valid, the validation will fail.

After you have assigned a valid schema or DTD reference to your file, you are able to validate it with "Document.IsValid". IsValid needs some out-parameters that must be declared as VARIANTs to be accessible from script languages like VBScript and JavaScript.

Example:

   Dim bValid      As Boolean
   Dim strMsg      As Variant
   Dim nPos      As Variant
   Dim objBadXMLData As Variant

   bValid = objSpy.ActiveDocument.IsValid(strMsg, nPos, objBadXMLData)

   If bValid = False Then
      a = MsgBox("The document is not valid:" & Chr(13) &
            strMsg & Chr(13) & "position: " & nPos &
            Chr(13) & "XMLData name: " & objBadXMLData.Name)
   Else
      a = MsgBox("The document is valid")
   End If


Import and Export

Import and Export

Before you implement your import and export tasks with the XMLSPY 5 API, it is a good practice to test the connections, parameters, SLQ queries and so on in XMLSPY 5. This way, you are able to verify the results and to make quick adjustments to all import or export parameters.

Most of the methods for importing and exporting data are placed in the "Application" object, the remaining functions are accessible via the "Document" interface.

There is some preparatory work necessary, before the actual import or export can be started. Every import/export job consists of two parts. You need to define a connection to your data and the specific behaviour for the import/export process.

In case of an import, the connection is either a database, a text-file or a Word document. The behaviour is basically which data (columns) should be imported in XMLSPY 5.

In case of an export, the connection is either a database or a text file. Specify which data (elements of the XML file) and additional parameters (e.g. automatic key generation or number of sub-levels) to use from the XML-structure for the behaviour.

The properties in the DatabaseConnection, TextImportExportSettings and ExportSettings interfaces have default values. See the corresponding descriptions in the "Interfaces" chapter for further information.

Import from database
These are the steps to establish a connection to an existing database for import:

1. Use a "DatabaseConnection" object and set the properties:
The method "Application.GetDatabaseSettings" returns a new object for a database connection:

Dim objImpSettings As DatabaseConnection
Set objImpSettings = objSpy.GetDatabaseSettings

You have to set either a ADO connection string,

objImpSettings.ADOConnection = strADOConnection

or the path to an existing database file:

objImpSettings.File = "C:\myDatabase.mdb"

To complete the settings you create a SQL select statement to define the data to be queried:

objImpSettings.SQLSelect = "SELECT * FROM myTable"

2. Call "Application.GetDatabaseImportElementList" to get a collection of the resulting columns of the SQL query:

   Dim objElementList As ElementList
   Set objElementList = objSpy.GetDatabaseImportElementList(objImpSettings)

This collection gives you the opportunity to control which columns should be imported and what type the new elements will become. Each item of the collection represents one column to import. If you remove an item, the corresponding column will not be imported. You can additionally modify the "ElementListItem.ElementKind" property, to set the type of the created XML elements for each column.

Please consider that GetDatabaseImportElementList() executes the SQL query and could initiate a time consuming call. To avoid this, it is possible to pass a null-pointer (Nothing in VisualBasic) as the second parameter to ImportFromDatabase() to import all columns as plain XML elements.

3. Start the import with "Application.ImportFromDatabase":

   Dim objImpDoc As Document
   Set objImpDoc = objSpy.ImportFromDatabase(objImpSettings,objElementList)

Import from Text
Importing data from a text file is similar to the import from a database. You must use other interfaces (described in steps 1-3 below) with different methods and properties:

1. Use a "TextImportExportSettings" object and set the properties:
The method "Application.GetTextImportExportSettings" returns a new object to specify a text file for import.

   Dim objImpSettings As TextImportExportSettings
   Set objImpSettings = objSpy.GetTextImportExportSettings

You have to set at least the ImportFile property to the path of the file for the import. Another important property is HeaderRow. Set it to False, if the text file does not contain a leading line as a header row.

   objImpSettings.ImportFile = "C:\myFile.txt"
   objImpSettings.HeaderRow = False

2.   Call "Application.GetTextImportElementList" to get a collection of all columns inside the text file:

   Dim objElementList As ElementList
   Set objElementList = objSpy.GetTextImportElementList(objImpSettings)

3. Start the import with "Application.ImportFromText":

   Dim objImpDoc As Document
   Set objImpDoc = objSpy.ImportFromText(objImpSettings,objElementList)

Export to database

1. Use a "DatabaseConnection" object and set the necessary properties.
All properties except "SQLSelect" are important for the export. "ADOConnection" or "File" defines the target for the output. You need to set only one of them.

2. Fill an "ExportSettings" object with the required values.
These properties are the same options as those available in the export dialog of XMLSPY 5. Select the menu option Convert | Export to Text files/Database to see the options and try a combination of export settings. After that it is easy to transfer these settings to the properties of the interface.

Call "Application.GetExportSettings" to get a ExportSettings object:

   Dim objExpSettings As ExportSettings
   Set objExpSettings = objSpy.GetExportSettings

   objExpSettings.CreateKeys = False
   objExpSettings.ExportAllElements = False
   objExpSettings.SubLevelLimit = 2

3. Build an element list with "Document.GetExportElementList".
The element list enables you to eliminate XML elements from the export process. It also gives you information about the record and field count in the "RecordCount" and "FieldCount" properties. Set the "ExportSettings.ElementList" property to this collection. It is possible to set the element list to null/Nothing (default) to export all elements.

4. Call "Document.ExportToDatabase" to execute the export.
The description of the ExportToDatabase method contains also a code example for a database export.

Export to text

1. Use a "TextImportExportSettings" object and set the necessary properties.

2. Fill an "ExportSettings" object with the required values.
See item number 2 from "Export to database" earlier on this page.

3.   Build an element list with "Document.GetExportElementList".
See item number 3 from "Export to database" earlier on this page.

4.   Call "Document.ExportToText" to execute the export.
The description of the ExportToText method contains also a code example for a database export.


Using XMLData

Using XMLData

XMLData gives you access to the elements of an currently open XML file. It enables you to perform all necessary modifications to the elements of the XML structure. The main functionality of XMLData is:

1. Access to the names and values of all kinds of elements (e.g. elements, attributes)

2. Creation of new elements of all kinds.

3. Insertion and appending of new elements.

4. Erasing of existing child elements.

Structure of XMLData
Before you can use the XMLData interface, you have to know how an existing XML file is mapped into a XMLData structure. One major thing you must be aware of is, that XMLData has no seperate branch of objects for attributes.

The attributes of an element are also children of the element. The "XMLData.Kind" property, gives you the opportunity to distinguish between the different types of children of an element.

Example:

This XML code,

   <ParentElement>
      <FirstChild attr1="Red" attr2="Black">
         This is the value of FirstChild
      </FirstChild>
      <SecondChild>
         <!--Your Comment-->
         </DeepChild>
      </SecondChild>
      This is Text
   </ParentElement>

is mapped to the following XMLData object structure:

The parent of all XML elements inside of a document is the property "Document.RootElement". Use this XMLData object to get references to all other XML elements in the structure.

Name and value of elements
To get and to modify the name and value of all types of XML elements use the "XMLData.Name" and "XMLData.TextValue" properties. It is possible that several kinds of XMLData objects and empty elements do not have a text value associated.

Creation and insertion of new XMLData objects
The creation of a new XML language entity requires the following steps:

1. Create the new XMLData object:
Use the "Document.CreateChild" method to create a new XMLData object. Set name and value after you have inserted the new XML entity (see point 3).

2. Find the correct location for the new XMLData object:
To insert a new XMLData object you have to get a reference to the parent first. If the new child is to become the last child of the parent, use the "XMLData.AppendChild" method to insert the XMLData object.
If the new child should be located elsewhere in the sequence of child objects, use the "XMLData.GetFirstChild" and "XMLData.GetNextChild" to move the iterator to the child before which the new child should be inserted.

3. Insert the new child with "XMLData.InsertChild"
The new child will be inserted immediately before the current child.

The following example adds a third child between <FirstChild> and the <SecondChild> element:

   Dim objParent As XMLData
   Dim objChild As XMLData
   Dim objNewChild As XMLData

   Set objNewChild = objSpy.ActiveDocument.CreateChild(spyXMLDataElement)

   'objParent is set to <ParentElement>
   'GetFirstChild(-1) gets all children of the parent element
   'and move to <SecondChild>
   Set objChild = objParent.GetFirstChild(-1)
   Set objChild = objParent.GetNextChild

   objParent.InsertChild objNewChild
   objNewChild.Name = "OneAndAHalf"
   Set objNewChild = Nothing

Copying of existing XMLData objects
If you want to insert existing XMLData objects at a different place in the same document or into another document you can't use the XMLData.InsertChild and XMLData.AppendChild methods. These methods only work for new XMLData objects.

Instead of using InsertChild or AppendChild you have to copy the object hierarchy manually. The following function written in JavaScript is an example for recursively copying XMLData:

   // this function returns a complete copy of the XMLData object
   function GetCopy(objXMLData)
   {
      var objNew;
      objNew = Application.ActiveDocument.CreateChild(objXMLData.Kind);

      objNew.Name = objXMLData.Name;
      objNew.TextValue = objXMLData.TextValue;

      if(objXMLData.HasChildren)   {
         var objChild;
         objChild = objXMLData.GetFirstChild(-1);

         while(objChild)   {
            try {
               objNew.AppendChild(GetCopy(objChild));
               objChild = objXMLData.GetNextChild();
            }
            catch(e) {
               objChild = null;
            }
         }
      }

      return objNew;
   }

Erasing of XMLData objects
XMLData provides two methods for the deletion of child objects, "XMLData.EraseAllChildren" and "XMLData.EraseCurrentChild".

To erase XMLData objects you need access to the parent of the elements you want to remove. Use "XMLData.GetFirstChild" and "XMLData.GetNextChild" to get a reference to the parent XMLData object.

See the method descriptions of "EraseAllChildren" and "EraseCurrentChild" for examples how to erase XML elements.


Error handling

Error handling

The XMLSPY 5 API returns errors in two different ways. Every API method returns a HRESULT. This return value informs the caller about any malfunctions during the execution of the method. If the call was successful, the return value is equal to S_OK. C/C++ programmers generally use HRESULT to detect any errors.

VisualBasic, scripting languages and other high-level development environments, don't give the programmer access to the returning HRESULT of a COM call. They use the second error raising mechanism also supported by the XMLSPY 5 API, the IErrorInfo interface. If an error occurs the API creates a new object that implements the IErrorInfo interface. The development environment takes this interface, and fills its own error handling mechansim with the provided informations.

The next paragraphs describes how to deal with errors raised from the XMLSPY 5 API in different development environments.

VisualBasic
A common way to handle errors in VisualBasic is to define an error handler. This error handler can be set with the On Error statement. Usually the handler displays a error message and does some cleanup to avoid spare references and any kind of resource leaks. VisualBasic fills its own Err object with the information from the IErrorInfo interface.

Example:

   Sub Validate()
      'place variable declarations here

      'set error handler
      On Error GoTo ErrorHandler

      'if IsValid() fails, program execution continues
      'at ErrorHandler:
      bValid = objSpy.ActiveDocument.IsValid(strMsg,nPos,objBadXMLData)

      'additional code comes here

      'exit
      Exit Sub

      ErrorHandler:
      Set objBadXMLData = Nothing

      MsgBox("Error: " & (Err.Number - vbObjectError) & Chr(13) &
         "Description: " & Err.Description)
   End Sub

JavaScript
The Microsoft implementation of JavaScript (JScript) provides a try - catch mechanism to deal with errors raised from COM calls. It is very similar to the VisualBasic approach, because you also declare an error object containing the necessary informations.

Example:

   function Validate()
   {
      // please insert variable declarations here

      try   {
         bValid = objSpy.ActiveDocument.IsValid(sMsg,nPos,objBad);
      }
      catch(Error)   {
         objBad = null;
         sError = Error.description;
         nErrorCode = Error.number;
         return false;
      }

      return bValid;
   }

C/C++
C/C++ gives you easy access to the HRESULT of the COM call and to the IErrorInterface.

   HRESULT   hr;

   // call IsValid() from the XMLSpy API
   if(FAILED(hr = ipDoc->IsValid(&varMsg,&varPos,&varBadData)))   {
      IErrorInfo   *ipErrorInfo = NULL;

      if(SUCCEEDED(::GetErrorInfo(0,&ipErrorInfo)))   {
         BSTR   bstrDescr;
         ipErrorInfo->GetDescription(&bstrDescr);

         // handle error information
         wprintf(L"Error message:\t%s\n",bstrDescr);
         ::SysFreeString(bstrDescr);

         // release error info
         ipErrorInfo->Release();
      }
   }


DOM and XMLData

DOM and XMLData

The XMLData interface gives you full access to the XML structure behind the current document with less methods than DOM and is much simpler. The XMLData interface is a minimalist approach to reading and modifying existing, or newly created XML data. You might however, want to use a DOM tree because you can access one from an external source or you just prefer the MSXML DOM implementation.

The ProcessDOMNode() and ProcessXMLDataNode() functions provided below convert any segments of an XML structure between XMLData and DOM.

To use the ProcessDOMNode() function:
· pass the root element of the DOM segment you want to convert in objNode and
· pass the plugin object with the CreateChild() method in objCreator

To use the ProcessXMLDataNode() function:
· pass the root element of the XMLData segment in objXMLData and
· pass the DOMDocument object created with MSXML in xmlDoc

////////////////////////////////////////////////////////////////
// DOM to XMLData conversion
function ProcessDOMNode(objNode,objCreator)
{
   var objRoot;
   objRoot = CreateXMLDataFromDOMNode(objNode,objCreator);

   if(objRoot)   {
      if((objNode.nodeValue != null) && (objNode.nodeValue.length > 0))
         objRoot.TextValue = objNode.nodeValue;
         // add attributes
      if(objNode.attributes) {
         var Attribute;
         var oNodeList = objNode.attributes;

         for(var i = 0;i < oNodeList.length; i++) {
            Attribute = oNodeList.item(i);

            var newNode;
            newNode = ProcessDOMNode(Attribute,objCreator);

            objRoot.AppendChild(newNode);
         }
      }
      if(objNode.hasChildNodes)   {
         try {
            // add children
            var Item;
            oNodeList = objNode.childNodes;

            for(var i = 0;i < oNodeList.length; i++) {
                  Item = oNodeList.item(i);

               var newNode;
               newNode = ProcessDOMNode(Item,objCreator);

               objRoot.AppendChild(newNode);
            }
         }
         catch(err) {
         }
      }
   }
   return objRoot;
}

function CreateXMLDataFromDOMNode(objNode,objCreator)
{
   var bSetName = true;
   var bSetValue = true;

   var nKind = 4;

   switch(objNode.nodeType)   {
      case 2:nKind = 5;break;
      case 3:nKind = 6;bSetName = false;break;
      case 4:nKind = 7;bSetName = false;break;
      case 8:nKind = 8;bSetName = false;break;
      case 7:nKind = 9;break;
   }
   var objNew = null;
   objNew = objCreator.CreateChild(nKind);

   if(bSetName)
      objNew.Name = objNode.nodeName;

   if(bSetValue && (objNode.nodeValue != null))
      objNew.TextValue = objNode.nodeValue;

   return objNew;
}
////////////////////////////////////////////////////////////////
// XMLData to DOM conversion

function ProcessXMLDataNode(objXMLData,xmlDoc)
{
   var objRoot;
   objRoot = CreateDOMNodeFromXMLData(objXMLData,xmlDoc);

   if(objRoot)   {
      if(IsTextNodeEnabled(objRoot) && (objXMLData.TextValue.length > 0))
         objRoot.appendChild(xmlDoc.createTextNode(objXMLData.TextValue));

      if(objXMLData.HasChildren)   {
         try {
            var objChild;
            objChild = objXMLData.GetFirstChild(-1);

            while(true)   {
               if(objChild)   {
                  var newNode;
                  newNode = ProcessXMLDataNode(objChild,xmlDoc);

                  if(newNode.nodeType == 2)   {
                     // child node is an attribute
                     objRoot.attributes.setNamedItem(newNode);
                  }
                  else
                     objRoot.appendChild(newNode);
               }
               objChild = objXMLData.GetNextChild();
            }
         }
         catch(err) {
         }
      }
   }
   return objRoot;
}

function CreateDOMNodeFromXMLData(objXMLData,xmlDoc)
{
   switch(objXMLData.Kind)   {
      case 4:return xmlDoc.createElement(objXMLData.Name);
      case 5:return xmlDoc.createAttribute(objXMLData.Name);
      case 6:return xmlDoc.createTextNode(objXMLData.TextValue);
      case 7:return xmlDoc.createCDATASection(objXMLData.TextValue);
      case 8:return xmlDoc.createComment(objXMLData.TextValue);
      case 9:return xmlDoc.createProcessingInstruction(objXMLData.Name,objXMLData.TextValue);
   }

   return xmlDoc.createElement(objXMLData.Name);
}
function IsTextNodeEnabled(objNode)
{
   switch(objNode.nodeType) {
      case 1:
      case 2:
      case 5:
      case 6:
      case 11:return true;
   }
   return false;
}


Row operations

Row operations

Repeatable elements can be created within an XML Document. This is made possible by the specific schema file to which the XML file is assigned. The WYSIWIG environment allows you to manipulate rows and their data, individually.

An XML row may be implemented by an HTML table, but this need not always be the case. The Stylesheet Designer *.SPS file defines the HTML page layout. While editing XML data, an external script performs the row operations (on each row individually).

If an external script is to perform row operations then two steps must occur:
· The first step checks whether the cursor is currently in a row using a property. E.g. IsRowInsertEnabled, which returns a TRUE or FALSE value.
· If the return value is TRUE then the row method can be called. E.g. RowAppend, which has no parameters and returns no value.

The following is a list of properties and methods available that perform table operations. Each of the properties return a BOOL and each of the methods have no parameters.

IsRowInsertEnabled, RowInsert: Row insertion operation.
IsRowAppendEnabled, RowAppend: Append row operation.
IsRowDeleteEnabled, RowDelete: Delete row operation.
IsRowMoveUpEnabled, RowMoveUp: Move the XML data up one row location.
IsRowMoveDownEnabled, RowMoveDown: Move the XML data down one row location.
IsRowDuplicateEnabled, RowDuplicate: Duplicate the currently selected XML row.


Editing operations

Editing operations

When XML data is displayed as HTML data, it is possible to manipulate individual elements using standard editing operations cut, copy and paste.

Not all XML data elements can be edited however, and it is therefore necessary first to test if editing is possible. This is achieved in the same way as row operations, starting with a property to test editing capabilities and then calling the method to perform the editing operation.

The only method that does not have a test is the method EditSelectAll, which automatically selects all elements displayed in the document. The following is a list of properties and methods available that perform editing operations. Each of the properties returns a BOOL and each of the methods have no parameters.

IsEditUndoEnabled, EditUndo | Undo an editing operation
IsEditRedoEnabled, EditRedo: | Redo an editing operation
IsEditCopyEnabled, EditCopy | Copy the selected text to the Windows clipboard
IsEditCutEnabled, EditCut | Cut the selected text to the Windows clipboard
IsEditPasteEnabled, EditPaste | Paste the Windows clipboard text to the current cursor position
IsEditClearEnabled, EditClear | Clear the selected text from the XML document


Events

Events

The Authentic Document view view provides events which can be handled using the XMLSPY 5 scripting environment. All event handlers take no parameters and any returned value will be ignored. To retrieve information when a specific event is raised you have to read the according properties of the event object.

List of currently available events:

On_DocEditDragOver
On_DocEditDrop
On_DocEditKeyDown
On_DocEditKeyUp
On_DocEditKeyPressed
On_DocEditMouseMove
On_DocEditButtonUp
On_DocEditButtonDown
On_DocEditContextMenu
On_DocEditPaste
On_DocEditCut
On_DocEditCopy
On_DocEditClear
On_DocEditSelectionChanged

To add an event handler please see "How to handle an event".


Interfaces

Interfaces

Objects

Application
DatabaseConnection
Document
Documents
ElementList
ElementListItem
ExportSettings
GridView
SpyProject
SpyProjectItem
SpyProjectItems
TextImportExportSettings
XMLData

Enumerations

Description
This chapter contains the reference of the XMLSPY 5 1.2 Type Library.

Most of the given examples are written in VisualBasic. These code snippets assume that there is a variable defined and set called objSpy of type Application. There are also some code samples written in JavaScript.


Application

See also

Methods
GetDatabaseImportElementList
GetDatabaseSettings
GetDatabaseTables
ImportFromDatabase

GetTextImportElementList
GetTextImportExportSettings
ImportFromText

ImportFromWord

ImportFromSchema

GetExportSettings

NewProject
OpenProject

AddMacroMenuItem
ClearMacroMenu

ShowForm

ShowApplication

URLDelete
URLMakeDirectory

Quit

Properties
ActiveDocument
Documents

CurrentProject

WarningNumber
WarningText

Description
Application is the root for all other objects. It is the only object you can create by CreateObject (VisualBasic) or other similar COM related functions.

Example

   Dim objSpy As Application
   Set objSpy = CreateObject("XMLSpy.Application")


XMLSpyApplication.GetDatabaseImportElementList

Application.GetDatabaseImportElementList

Declaration: GetDatabaseImportElementList(pImportSettings as DatabaseConnection) as ElementList

Return Value
The function returns a collection of ElementListItems.

Description
GetDatabaseImportElementList retrieves information about the database as specified in pImportSettings to create the list of elements ppElementList. This list is used to exclude elements from import and to set the kind of the imported elements. See also ImportFromDatabase. The items of the collection are described in ElementListItem.

Example
See example at ImportFromDatabase.


XMLSpyApplication.GetDatabaseSettings

Application.GetDatabaseSettings

Declaration: GetDatabaseSettings as DatabaseConnection

Return Value
Returns a DatabaseConnection object.

Description
GetDatabaseSettings creates a new object of database settings. The object is used to define a connection to a database. See also ImportFromDatabase.

Example
See example of ImportFromDatabase.


XMLSpyApplication.GetDatabaseTables

Application.GetDatabaseTables

Declaration: GetDatabaseTables(pImportSettings as DatabaseConnection) as ElementList

Return Value
The function returns a collection of ElementListItems.

Description
GetDatabaseTables reads the table names from the database.

Example

Dim objImpSettings As DatabaseConnection
       Set objImpSettings = objSpy.GetDatabaseSettings
       objImpSettings.ADOConnection = TxtADO.Text

       'store table names in list box
       ListTables.Clear

       Dim objList As ElementList
       Dim objItem As ElementListItem
       On Error GoTo ErrorHandler
       Set objList = objSpy.GetDatabaseTables(objImpSettings)

   For Each objItem In objList
      ListTables.AddItem objItem.Name
   Next


XMLSpyApplication.ImportFromDatabase

Application.ImportFromDatabase

Declaration: ImportFromDatabase(pImportSettings as DatabaseConnection,pElementList as ElementList) as Document

Return Value
Creates a new document.

Description
ImportFromDatabase imports the database as specified in pImportSettings. pElementList declares the tables to import. See Application.GetDatabaseImportElementList for more information about the list of elements.

Example

   Dim objImpSettings As DatabaseConnection
   Set objImpSettings = objSpy.GetDatabaseSettings

   objImpSettings.ADOConnection = strADOConnection
   objImpSettings.SQLSelect = "SELECT * FROM MyTable"

   Dim objDoc As Document
   On Error Resume Next
   Set objDoc = objSpy.ImportFromDatabase(
                  objImpSettings,                   objSpy.GetDatabaseImportElementList(objImpSettings))
   CheckForError


XMLSpyApplication.GetTextImportElementList

Application.GetTextImportElementList

Declaration: GetTextImportElementList(pImportSettings as TextImportExportSettings) as
ElementList

Return Value
The method returns a collection of ElementListItems.

Description
GetTextImportElementList gets information about the text-file as specified in pImportSettings. See also ImportFromText.

Example

   Dim objImpSettings As TextImportExportSettings
   Set objImpSettings = objSpy.GetTextImportExportSettings

   objImpSettings.ImportFile = "C:\ImportMe.txt"
   objImpSettings.HeaderRow = False

   Dim objList As ElementList
   Set objList = objSpy.GetTextImportElementList(objImpSettings)

   'exclude first column
   objList.RemoveItem 1

   Dim objImpDoc As Document
   On Error Resume Next
   Set objImpDoc = objSpy.ImportFromText(objImpSettings, objList)
   CheckForError


XMLSpyApplication.GetTextImportExportSettings

Application.GetTextImportExportSettings

Declaration: GetTextImportExportSettings as TextImportExportSettings

Return Value

Description
GetTextImportExportSettings creates a new object of common import and export settings for text-files. See also the example for Application.GetTextImportElementList and Import and Export.


XMLSpyApplication.ImportFromText

Application.ImportFromText

Declaration: ImportFromText(pImportSettings as TextImportExportSettings,pElementList as ElementList) as Document

Return Value
Creates a new document.

Description
ImportFromText imports the text-file as specified in pImportSettings. pElementList declares the tables to import.

Example

   Dim objImpSettings As TextImportExportSettings
   Set objImpSettings = objSpy.GetTextImportExportSettings

   objImpSettings.ImportFile = strFileName
   objImpSettings.HeaderRow = False

   Dim objImpDoc As Document
   On Error Resume Next
   Set objImpDoc = objSpy.ImportFromText(objImpSettings,                   objSpy.GetTextImportElementList(objImpSettings))

   CheckForError


XMLSpyApplication.ImportFromWord

Application.ImportFromWord

Declaration: ImportFromWord(strFile as String) as Document

Return Value
The method creates a new document.

Description
ImportFromWord imports the Word-Document strFile.


Application.ImportFromSchema

Application.ImportFromSchema

Declaration: ImportFromSchema(pImportSettings as DatabaseConnection,strTable as String,pSchemaDoc as Document) as Document

Parameters

pImportSettings
Used to specify the database connection. See also Import and Export.

strTable
Sets the root table from the schema for import.

pSchemaDoc
Schema document for import.

Return Value
Creates a new document.

Description
ImportFromSchema imports the database as specified in pImportSettings.


XMLSpyApplication.GetExportSettings

Application.GetExportSettings

Declaration: GetExportSettings as ExportSettings

Return Value
The method returns a ExportSettings object.

Description
GetExportSettings creates a new object of common export settings. This object is used to pass the parameters to the export functions and defines the behaviour of the export calls. See also the export functions from Document and the examples at Import and Export.


XMLSpyApplication.NewProject

Application.NewProject

Declaration: NewProject(strPath as String,bDiscardCurrent as Boolean)

Return Value

Description
NewProject creates a new project.

If there is already a project open that has been modified and bDiscardCurrent is false, NewProject() fails.


XMLSpyApplication.OpenProject

Application.OpenProject

Declaration: OpenProject(strPath as String,bDiscardCurrent as Boolean,bDialog as Boolean)

Parameters

strPath
Path and file name of the project to open. Can be empty if bDialog is true.

bDiscardCurrent
Discard currently open project and possible lose changes.

bDialog
Show dialogs for user input.

Return Value
none

Description
OpenProject opens an existing project.

If there is already a project open that has been modified and bDiscardCurrent is false, OpenProject() fails.


Application.AddMacroMenuItem

Application.AddMacroMenuItem

Declaration: AddMacroMenuItem(strMacro as String, strDisplayText as String)

Return Value

Description
Adds an menu item to the Tools menu. This new menu item invokes the macro defined by strMacro. See also "Calling macros from XMLSPY 5".


Application.ClearMacroMenu

Application.ClearMacroMenu

Declaration: ClearMacroMenu

Return Value
none

Description
Removes all menu items from the Tools menu. See also "Calling macros from XMLSPY 5".


Application.ShowForm

Application.ShowForm

Declaration: ShowForm(strFormName as String) As Long

Return Value
Returns zero if the user pressed a cancel-button or the form calls TheView.Cancel().

Description
Displays the form strFormName.

Forms, event handlers and macros can be created with the Form Editor. Select "Switch to scripting environment" from the "Tools" menu to invoke the scripting environment.


Application.ShowApplication

Application.ShowApplication

Declaration: ShowApplication(bShow as Boolean)

Return Value
none

Description
The method shows (bShow = True) or hides (bShow = False) XMLSPY 5.


Application.URLDelete

Application.URLDelete

Declaration: URLDelete(strURL as String,strUser as String,strPassword as String)

Return Value
none

Description
The method deletes the file at the URL strURL.


Application.URLMakeDirectory

Application.URLMakeDirectory

Declaration: URLMakeDirectory(strURL as String,strUser as String,strPassword as String)

Return Value
none

Description
The method creates a new directory at the URL strURL.


Application.Quit

Application.Quit

Declaration: Quit

Return Value
none

Description
This method terminates XMLSPY 5. All modified documents will be closed without saving the changes. This is also true for an open project.


XMLSpyApplication.ActiveDocument

Application.ActiveDocument

Declaration: ActiveDocument as Document

Description
Reference to the active document. If no document is open, ActiveDocument is null (Nothing).


XMLSpyApplication.Documents

Application.Documents

Declaration: Documents as Documents

Description
Collection of all open documents. See also "Simple document access".


Application.CurrentProject

Application.CurrentProject

Declaration: CurrentProject as SpyProject

Description
Reference to the active document. If no project is open, CurrentProject is null (Nothing).


XMLSpyApplication.WarningNumber

Application.WarningNumber

Declaration: WarningNumber as integer

Description
Some methods fill the property WarningNumber with additional information if an error occurs.

Currently just Documents.OpenFile fills this property.


XMLSpyApplication.WarningText

Application.WarningText

Declaration: WarningText as String

Description
Some methods fill the property WarningText with additional information if an error occurs.

Currently just Documents.OpenFile fills this property.


Document

Methods
AssignDTD
AssignSchema
AssignXSL
TransformXSL

GenerateDTDOrSchema
ConvertDTDOrSchema
CreateSchemaDiagram

CreateChild

ExportToDatabase
ExportToText
GetExportElementList

IsValid
IsWellFormed

Save
SaveToURL
SaveInString

SetActiveDocument

SetEncoding

SetPathName
GetPathName

StartChanges
EndChanges

SwitchViewMode
UpdateViews

Close

Properties

GridView
DocEditView

CurrentViewMode

RootElement

Title

IsModified

Description
Document Class


XMLSpyDocument.AssignDTD

Document.AssignDTD

Declaration: AssignDTD(strDTDFile as String,bDialog as Boolean)

Description
The method places a reference to the DTD file "strDTDFile" into the document. Note that no error occures if the file does not exist or is not accessible.

If bDialog is true XMLSPY 5 presents a dialog to set the file.

See also "Simple document access".


XMLSpyDocument.AssignSchema

Document.AssignSchema

Declaration: AssignSchema(strSchemaFile as String,bDialog as Boolean)

Description
The method places a reference to the schema file "strSchemaFile" into the document. Note that no error occures if the file does not exist or is not accessible.

If bDialog is true XMLSPY 5 presents a dialog to set the file.

See also "Simple document access".


XMLSpyDocument.AssignXSL

Document.AssignXSL

Declaration: AssignXSL(strXSLFile as String,bDialog as Boolean)

Description
The method places a reference to the XSL file "strXSLFile" into the document. Note that no error occures if the file does not exist or is not accessible.

If bDialog is true XMLSPY 5 presents a dialog to set the file.


XMLSpyDocument.TransformXSL

Document.TransformXSL

Declaration: TransformXSL

Description
TransformXSL processes the XML document via the associated XSL file. See "Document.AssignXSL" to place a reference to a XSL file in the document.


XMLSpyDocument.GenerateDTDOrSchema

Document.GenerateDTDOrSchema

Declaration: GenerateDTDOrSchema(nFormat as SPYDTDSchemaFormat,nValuesList as integer,nDetection as SPYTypeDetection, nFrequentElements as SPYFrequentElements)

Parameters

nFormat
Sets the schema output format to DTD, DCD, XMLData, BizTalk or W3C.

nValuesList
Set to 0 (zero) for unlimited.

nDetection
Specifies attribute/element detection.

nFrequentElements
Create complex elements as elements or complex types.

Description
To generate a DTD or schema from the current document use the GenerateDTDOrSchema method.


XMLSpyDocument.ConvertDTDOrSchema

Document.ConvertDTDOrSchema

Declaration: ConvertDTDOrSchema(nFormat as SPYDTDSchemaFormat, nFrequentElements as SPYFrequentElements)

Parameters

nFormat
Sets the schema output format to DTD, DCD, XMLData, BizTalk or W3C.

nFrequentElements
Create complex elements as elements or complex types.

Description
ConvertDTDOrSchema takes an existing schema format and converts it into a different format.


Document.CreateSchemaDiagram

Document.CreateSchemaDiagram

Declaration: CreateSchemaDiagram(nKind as SPYSchemaDefKind,strName as String,strFile as String)

Return Value
none

Description
The method creates a diagram of the schema type strName of kind nKind and saves the output file into strFile.


XMLSpyDocument.CreateChild

Document.CreateChild

Declaration: CreateChild(nKind as SPYXMLDataKind) as XMLData

Return Value
The method returns the new XMLData object.

Description
To create a new XMLData object use the CreateChild() method. See also "Using XMLData".


XMLSpyDocument.ExportToDatabase

Document.ExportToDatabase

Declaration: ExportToDatabase(pFromChild as XMLData, pExportSettings as ExportSettings, pDatabase as DatabaseConnection)

Description
ExportToDatabase exports the xml-document starting with the element pFromChild. pExportSettings defines the behaviour of the export (see Application.GetExportSettings), pDatabase sets the destination of the export (see Application.GetDatabaseSettings).

Example

   Dim objDoc As Document
   Set objDoc = objSpy.ActiveDocument

   'set the behaviour of the export with ExportSettings
   Dim objExpSettings As ExportSettings
   Set objExpSettings = objSpy.GetExportSettings

   'set the destination with DatabaseConnection
   Dim objDB As DatabaseConnection
   Set objDB = objSpy.GetDatabaseSettings

   objDB.CreateMissingTables = True
   objDB.CreateNew = True
   objDB.File = "C:\Export.mdb"

   objDoc.ExportToDatabase objDoc.RootElement, objExpSettings, objDB
   If Err.Number <> 0 Then
      a = MsgBox("Error: " & (Err.Number - vbObjectError) & Chr(13) &
            "Description: " & Err.Description)
   End If


XMLSpyDocument.ExportToText

Document.ExportToText

Declaration: ExportToText(pFromChild as XMLData,pExportSettings as ExportSettings,pTextSettings as TextImportExportSettings)

Description
ExportToText exports the XML data structure into a text file.

Example

   Dim objDoc As Document
   Set objDoc = objSpy.ActiveDocument

   Dim objExpSettings As ExportSettings
   Set objExpSettings = objSpy.GetExportSettings
   objExpSettings.ElementList = objDoc.GetExportElementList(
                        objDoc.RootElement,
                        objExpSettings)

   Dim objTextExp As TextImportExportSettings
   Set objTextExp = objSpy.GetTextExportSettings
   objTextExp.HeaderRow = True
   objTextExp.DestinationFolder = "C:\Exports"

   On Error Resume Next
   objDoc.ExportToText objDoc.RootElement, objExpSettings, objTextExp

   If Err.Number <> 0 Then
      a = MsgBox("Error: " & (Err.Number - vbObjectError) & Chr(13) & "Description: "             & Err.Description)
   End If


XMLSpyDocument.GetExportElementList

Document.GetExportElementList

Declaration: GetExportElementList(pFromChild as XMLData,pExportSettings as ExportSettings) as ElementList

Return Value
Returns a collection of elements.

Description
GetExportElementList creates a collection of elements to export depending on the settings in pExportSettings and starting from the element pFromChild. See also "Import and Export".


XMLSpyDocument.IsValid

Document.IsValid

Declaration: IsValid(strError as Variant,nErrorPos as Variant,pBadData as Variant) as Boolean

Return Value
True if the document is valid, false if not.

Description
IsValid() validates the document against its associated schema or DTD. strError and nErrorPos give you the same information as XMLSPY 5 if you validate the file within the editor.


XMLSpyDocument.IsWellFormed

Document.IsWellFormed

Declaration: IsWellFormed(pData as XMLData,bWithChildren as Boolean,strError as Variant,nErrorPos as Variant,pBadXMLData as Variant) as Boolean

Return Value
True if the document is well formed.

Description
IsWellFormed checks the document for well-formedness starting at the element pData.

If the document is not well formed, strError contains a error message, nErrorPos the position in the file and pBadXMLData holds a reference to the element which breaks the well-formedness. These out-parameters are defined as VARIANTs to support scripting languages like VBScript.


XMLSpyDocument.Save

Document.Save

Declaration: Save

Description
The method writes any modifications of the document to the associated file. See also "Document.SetPathName".


Document.SaveToURL

Document.SaveToURL

Declaration: SaveToURL(strURL as String,strUser as String,strPassword as String)

Return Value

Description
SaveToURL() writes the document to the URL strURL. This method does not set the permanent file path of the document.


XMLSpyDocument.SaveInString

Document.SaveInString

Declaration: SaveInString(pData as XMLData,bMarked as Boolean) as String

Parameters

pData
XMLData element to start. Set pData to Document.RootElement if you want to copy the complete file.

bMarked
If bMarked is true, only the elements selected in the grid view are copied.

Return Value
Returns a string with the XML data.

Description
SaveInString starts at the element pData and converts the XMLData objects to a string representation.


XMLSpyDocument.SetActiveDocument

Document.SetActiveDocument

Declaration: SetActiveDocument

Description
The method sets the document as the active and brings it to the front.


XMLSpyDocument.SetEncoding

Document.SetEncoding

Declaration: SetEncoding(strEncoding as String)

Description
SetEncoding sets the encoding of the document like the menu item "File/Encoding..." in XMLSPY 5. Possible values for strEncoding are for example:

8859-1,
8859-2,
ASCII, ISO-646,
850,
1252,
1255,
SHIFT-JIS, MS-KANJI,
BIG5, FIVE,
UTF-7,
UTF-8,
UTF-16


XMLSpyDocument.SetPathName

Document.SetPathName

Declaration: SetPathName(strPath as String)

Description
The method SetPathName sets the path of the active document. SetPathName only copies the string and does not check if the path is valid.

All succeeding save operations are done into this file.


Document.GetPathName

Document.GetPathName

Declaration: GetPathName as String

Description
The method GetPathName gets the path of the active document.

See also Document.SetPathName.


XMLSpyDocument.StartChanges

Document.StartChanges

Declaration: StartChanges

Description
After StartChanges is executed XMLSPY 5 will not update its editor windows until "Document.EndChanges" is called. This increases performance of any complex tasks to the XML structure.


XMLSpyDocument.EndChanges

Document.EndChanges

Declaration: EndChanges

Description
Use the method EndChanges to display all changes since the call to "Document.StartChanges".


Document.SwitchViewMode

Document.SwitchViewMode

Declaration: SwitchViewMode(nMode as SPYViewModes) as Boolean

Return value
Returns true if view mode is switched.

Description
The method sets the current view mode of the document in XMLSPY 5. See also Document.CurrentViewMode.


XMLSpyDocument.UpdateViews

Document.UpdateViews

Declaration: UpdateViews

Description
To redraw the Enhanced Grid View and the Tree View call UpdateViews. This can be important after you changed the XMLData structure of a document.

This method does not redraw the text view of XMLSPY 5.


XMLSpyDocument.Close

Document.Close

Declaration: Close(bDiscardChanges as Boolean)

Description
To close the document call this method. If bDiscardChanges is true and the document is modified, the document will be closed but not saved.


XMLSpyDocument.GridView

Document.GridView

Declaration: GridView as GridView

Description
This property provides access to the grid view functionality of the document.


Document.DocEditView

Document.DocEditView

Declaration: DocEditView as DocEditView

Description

Holds a reference to the current Authentic Document view view object.


XMLSpyDocument.RootElement

Document.RootElement

Declaration: RootElement as XMLData

Description
The property RootElement provides access to the root element of the XML structure of the document.


XMLSpyDocument.Title

Document.Title

Declaration: Title as String

Description
Title is the file name of the document.

This property is read-only.

To get the path of the file use Document.GetPathName.


Document.CurrentViewMode

Document.CurrentViewMode

Declaration: CurrentViewMode as SPYViewModes

Description
The property holds the current view mode of the document. See also Document.SwitchViewMode.


Document.IsModified

Document.IsModified

Declaration: IsModified as Boolean

Description

True if the document is modified.


Documents

Methods
NewFile
OpenFile
OpenURL
OpenURLDialog
NewFileFromText

Properties
Count
Item

Description
Documents Class


XMLSpyDocuments.OpenFile

Documents.OpenFile

Declaration: OpenFile(strPath as String,bDialog as Boolean) as Document

Parameters

strPath
Path and file name of file to open.

bDialog
Show dialogs for user input.

Return Value
Returns the opened file on success.

Description
OpenFile opens the file strPath. If bDialog is TRUE, a file-dialog will be displayed.

Example

   Dim objDoc As Document
   Set objDoc = objSpy.Documents.OpenFile(strFile, False)


XMLSpyDocuments.NewFile

Documents.NewFile

Declaration: NewFile(strFile as String,strType as String) as Document

Parameters

strFile
Full path of new file.

strType
Type of new file as string (i.e. "xml", "xsd", ... )

Return Value
Returns the new file.

Description
NewFile creates a new file of type strType (i.e. "xml").

The just now created file is also the ActiveDocument.


Documents.OpenURL

Documents.OpenURL

Declaration: OpenURL(strURL as String,nURLType as SPYURLTypes,nLoading as SPYLoading,strUser as String,strPassword as String) as Document

Parameters

strURL
URL to open as document.

nURLType
Type of document to open. Set to -1 for auto detection.

nLoading
Set nLoading to 0 (zero) if you want to load it from cache or proxy. Otherwise set nLoading to 1.

strUser
Name of the user if required. Can be empty.

strPassword
Password for authentification. Can be empty.

Return Value
The method returns the opened document.

Description
OpenURL opens the URL strURL.


Documents.OpenURLDialog

Documents.OpenURLDialog

Declaration: OpenURLDialog(strURL as String,nURLType as SPYURLTypes,nLoading as SPYLoading,strUser as String,strPassword as String) as Document

Parameters

strURL
URL to open as document.

nURLType
Type of document to open. Set to -1 for auto detection.

nLoading
Set nLoading to 0 (zero) if you want to load it from cache or proxy. Otherwise set nLoading to 1.

strUser
Name of the user if required. Can be empty.

strPassword
Password for authentification. Can be empty.

Return Value
The method returns the opened document.

Description
OpenURLDialog displays the "open URL" dialog to the user and presets the input fields with the given parameters.


Documents.NewFileFromText

Documents.NewFileFromText

Declaration: NewFileFromText(strText as String,strType as String) as Document

Parameters

strText:
The content of the new document in plain text.

strType:
Type of the document to create (i.e. "xml").

Return Value
The method returns the new document.

Description
NewFileFromText creates a new document with strText as its content.


XMLSpyDocuments.Count

Documents.Count

Declaration: Count as long

Description
Count of open documents.


XMLSpyDocuments.Item

Documents.Item

Declaration: Item(n as long) as Document

Description
Gets the document with the index n in this collection. Index is 1-based.


GridView

Methods
Deselect
Select

SetFocus

Properties
CurrentFocus

IsVisible

Description
GridView Class


XMLSpyGridView.Deselect

GridView.Deselect

Declaration: Deselect(pData as XMLData)

Description
Deselects the element pData in the grid view.


XMLSpyGridView.Select

GridView.Select

Declaration: Select(pData as XMLData)

Description
Selects the XML element pData in the grid view.


XMLSpyGridView.SetFocus

GridView.SetFocus

Declaration: SetFocus(pFocusData as XMLData)

Description
Sets the focus to the element pFocusData in the grid view.


XMLSpyGridView.CurrentFocus

GridView.CurrentFocus

Declaration: CurrentFocus as XMLData

Description
Holds the XML element with the current focus.

This property is read-only.


XMLSpyGridView.IsVisible

GridView.IsVisible

Declaration: IsVisible as Boolean

Description
True if the grid view is the active view of the document.

This property is read-only.


DocEditView

Methods

LoadXML
SaveXML

EditClear
EditCopy
EditCut
EditPaste
EditRedo
EditSelectAll
EditUndo

RowAppend
RowDelete
RowDuplicate
RowInsert
RowMoveDown
RowMoveUp

ApplyTextState
IsTextStateApplied
IsTextStateEnabled

MarkUpView

SelectionSet
SelectionMoveTabOrder

GetNextVisible
GetPreviousVisible

GetAllowedElements

Properties

CurrentSelection

event

XMLRoot

IsEditClearEnabled
IsEditCopyEnabled
IsEditCutEnabled
IsEditPasteEnabled
IsEditRedoEnabled
IsEditUndoEnabled

IsRowAppendEnabled
IsRowDeleteEnabled
IsRowDuplicateEnabled
IsRowInsertEnabled
IsRowMoveDownEnabled
IsRowMoveUpEnabled

Description

Interface for Authentic Document view view.


ApplyTextState

ApplyTextState

Declaration: ApplyTextState(elementName as String)

Description

Applies or removes the text state defined by the parameter elementName. Common examples for the parameter elementName would be strong and italic.

In an XML document there are segments of data, which may contain sub-elements. For example consider the following HTML:

   <b>fragment</b>

The HTML tag <b> will cause the word fragment to be bolded. However, this only happens because the HTML parser knows that the tag <b> is bold. With XML there is much more flexibility. It is possible to define any XML tag to do anything you desire. The point is that it is possible to apply a Text state using XML. But the Text state that is applied must be part of the schema. For example in the OrgChart.xml OrgChart.sps, OrgChart.xsd example the tag <strong> is the same as bold. And to apply bold the method ApplyTextState() is called. But like the row and edit operations it is necessary to test if it is possible to apply the text state.

See also IsTextStateEnabled and IsTextStateApplied.


EditClear

EditClear

Declaration: EditClear

Description

Clears the current selection.


EditCopy

EditCopy

Declaration: EditCopy

Description

Copies the current selection to the clipboard.


EditCut

EditCut

Declaration: EditCut

Description

Cuts the current selection from the document and copies it to the clipboard.


EditPaste

EditPaste

Declaration: EditPaste

Description

Pastes the content from the clipboard into the document.


EditRedo

EditRedo

Declaration: EditRedo

Description

Redo the last undo step.


EditSelectAll

EditSelectAll

Declaration: EditSelectAll

Description

The method selects the complete document.


EditUndo

EditUndo

Declaration: EditUndo

Description

Undo the last action.


IsTextStateApplied

IsTextStateApplied

Declaration: IsTextStateApplied(elementName as String) as Boolean

Description

Checks to see if the it the text state has already been applied. Common examples for the parameter elementName would be strong and italic.


IsTextStateEnabled

IsTextStateEnabled

Declaration: IsTextStateEnabled(elementName as String) as Boolean

Description

Checks to see if it is possible to apply a text state. Common examples for the parameter elementName would be strong and italic.


LoadXML

LoadXML

Declaration: LoadXML(xmlString as String)

Description

Loads the current XML document with the XML string applied. The new content is displayed immediately.


MarkUpView

MarkUpView

Declaration: MarkUpView(kind as long)

Description

By default the document displayed is using HTML techniques. But sometimes it is desirable to show the editing tags. Using this method it is possible to display three different types of markup tags:

0 hide the markup tags
2 show the large markup tags
3 show the mixed markup tags.


RowAppend

RowAppend

Declaration: RowAppend

Description

Appends a row at the current position.

See also Row operations.


RowDelete

RowDelete

Declaration: RowDelete

Description

Deletes the currently selected row(s).

See also Row operations.


RowDuplicate

RowDuplicate

Declaration: RowDuplicate

Description

The method duplicates the currently selected rows.

See also Row operations.


RowInsert

RowInsert

Declaration: RowInsert

Description

Inserts a new row immediately above the current selection.

See also Row operations.


RowMoveDown

RowMoveDown

Declaration: RowMoveDown

Description

Moves the current row one position down.

See also Row operations.


RowMoveUp

RowMoveUp

Declaration: RowMoveUp

Description

Moves the current row one position up.

See also Row operations.


SaveXML

SaveXML

Declaration: SaveXML as String

Return Value
XML structure as string

Description

Saves the current XML data to a string that is returned to the caller.


IsEditClearEnabled

IsEditClearEnabled

Declaration: IsEditClearEnabled as Boolean

Description

True if EditClear is possible.

See also Editing operations.


IsEditCopyEnabled

IsEditCopyEnabled

Declaration: IsEditCopyEnabled as Boolean

Description

True if copy to clipboard is possible.

See also EditCopy and Editing operations.


IsEditCutEnabled

IsEditCutEnabled

Declaration: IsEditCutEnabled as Boolean

Description

True if EditCut is currently possible.

See also Editing operations.


IsEditPasteEnabled

IsEditPasteEnabled

Declaration: IsEditPasteEnabled as Boolean

Description

True if EditPaste is possible.

See also Editing operations.


IsEditRedoEnabled

IsEditRedoEnabled

Declaration: IsEditRedoEnabled as Boolean

Description

True if EditRedo is currently possible.

See also Editing operations.


IsEditUndoEnabled

IsEditUndoEnabled

Declaration: IsEditUndoEnabled as Boolean

Description

True if EditUndo is possible.

See also Editing operations.


IsRowAppendEnabled

IsRowAppendEnabled

Declaration: IsRowAppendEnabled as Boolean

Description

True if RowAppend is possible.

See also Row operations.


IsRowDeleteEnabled

IsRowDeleteEnabled

Declaration: IsRowDeleteEnabled as Boolean

Description

True if RowDelete is possible.

See also Row operations.


IsRowDuplicateEnabled

IsRowDuplicateEnabled

Declaration: IsRowDuplicateEnabled as Boolean

Description

True if RowDuplicate is currently possible.

See also Row operations.


IsRowInsertEnabled

IsRowInsertEnabled

Declaration: IsRowInsertEnabled as Boolean

Description

True if RowInsert is possible.

See also Row operations.


IsRowMoveDownEnabled

IsRowMoveDownEnabled

Declaration: IsRowMoveDownEnabled as Boolean

Description

True if RowMoveDown is currently possible.

See also Row operations.


IsRowMoveUpEnabled

IsRowMoveUpEnabled

Declaration: IsRowMoveUpEnabled as Boolean

Description

True if RowMoveUp is possible.

See also Row operations.


XMLRoot

XMLRoot

Declaration: XMLRoot as XMLData

Description

XMLRoot is the parent element of the currently displayed XML structure. Using the XMLData interface you have full access to the complete content of the file.

See also Using XMLData for more informations.


DocEditView.event

DocEditView.event

Declaration: event as DocEditEvent

Description

The event property holds a DocEditEvent object which contains informations about the current event.


DocEditView.GetPreviousVisible

DocEditView.GetPreviousVisible

Declaration: GetPreviousVisible(pElement as XMLData) as XMLData

Description

The method gets the previous visible XML element in the document.


DocEditView.GetNextVisible

DocEditView.GetNextVisible

Declaration: GetNextVisible(pElement as XMLData) as XMLData

Description

The method gets the next visible XML element in the document.


DocEditView.SelectionMoveTabOrder

DocEditView.SelectionMoveTabOrder

Declaration: SelectionMoveTabOrder(bForward as Boolean,bTag as Boolean)

Description

SelectionMoveTabOrder() moves the current selection forwards or backwards.

If bTag is false and the current selection is at the last cell of a table a new line will be added.


DocEditView.SelectionSet

DocEditView.SelectionSet

Declaration: SelectionSet(pStartElement as XMLData,nStartPos as long,pEndElement as XMLData,nEndPos as long) as Boolean

Description

Use SelectionSet() to set a new selection in the Authentic Document view view. Its possible to set pEndElement to null (nothing) if the selection should be just over one (pStartElement) XML element.


DocEditView.CurrentSelection

DocEditView.CurrentSelection

Declaration: CurrentSelection as DocEditSelection

Description

The property provides access to the current selection in the Authentic Document view view.


DocEditView.GetAllowedElements

DocEditView.GetAllowedElements

Declaration: GetAllowedElements(nAction as DOCEDElementActions,pStartElement as XMLData,pEndElement as XMLData,pElements as Variant)

Description

GetAllowedElements() returns the allowed elements for the various actions specified by nAction.

JavaScript example:

   function GetAllowed()
   {
      var objView = Application.ActiveDocument.DocEditView;

      var arrElements = new Array(1);

      var objStart = objView.CurrentSelection.Start;
      var objEnd = objView.CurrentSelection.End;

      var strText;
      strText = "valid elements at current selection:\n\n";

      for(var i = 1;i <= 4;i++)   {
         objPlugIn.GetAllowedElements(i,objStart,objEnd,arrElements);
         strText = strText + ListArray(arrElements) + "------------------\n";
      }

      return strText;
   }

   function ListArray(arrIn)
   {
      var strText = "";

      if(typeof(arrIn) == "object")   {
         for(var i = 0;i <= (arrIn.length - 1);i++)
            strText = strText + arrIn[i] + "\n";
      }

      return strText;
   }

VBScript example:

   Sub DisplayAllowed
      dim objView
      set objView = Application.ActiveDocument.DocEditView

      dim arrElements()

      dim objStart
      dim objEnd
      set objStart = objView.CurrentSelection.Start
      set objEnd = objView.CurrentSelection.End

      dim strText
      strText = "valid elements at current selection:" & chr(13) & chr(13)

      dim i

      For i = 1 To 4
         objView.GetAllowedElements i,objStart,objEnd,arrElements
         strText = strText & ListArray(arrElements) & "---------------" & chr(13)
      Next

      msgbox strText
   End Sub

   Function ListArray(arrIn)
      dim strText

      If IsArray(arrIn) Then
         dim i

         For i = 0 To UBound(arrIn)
            strText = strText & arrIn(i) & chr(13)
         Next
      End If

      ListArray = strText
   End Function


DocEditDataTransfer

Methods

getData

Properties

dropEffect
ownDrag
type

Description

DocEditDataTransfer interface.


DocEditDataTransfer.getData

DocEditDataTransfer.getData

Declaration: getData as Variant

Description

getData gets the actual data associated with this dataTransfer object. See also DocEditDataTransfer.type for more informations.


DocEditDataTransfer.dropEffect

DocEditDataTransfer.dropEffect

Declaration: dropEffect as long

Description

The property stores the drop effect from the default event handler. You can set the drop effect if you change this value and set DocEditEvent.cancelBubble to TRUE.


DocEditDataTransfer.ownDrag

DocEditDataTransfer.ownDrag

Declaration: ownDrag as Boolean

Description

The property is TRUE if the current dragging source comes from inside of the Authentic Document view view.


DocEditDataTransfer.type

DocEditDataTransfer.type

Declaration: type as String

Description

Holds the type of the data you get with the DocEditDataTransfer.getData method.

Currently supported data types are:

OWN data from Authentic Document view view itself
TEXT plain text
UNICODETEXT plain text as UNICODE


DocEditEvent

Properties

altKey
altLeft
ctrlKey
ctrlLeft
shiftKey
shiftLeft

keyCode
repeat

button

clientX
clientY

dataTransfer

srcElement
fromElement

propertyName

cancelBubble
returnValue

type

Description

DocEditEvent interface.


DocEditEvent.altKey

DocEditEvent.altKey

Declaration: altKey as Boolean

Description

True if the right ALT key is pressed.


DocEditEvent.altLeft

DocEditEvent.altLeft

Declaration: altLeft as Boolean

Description

True if the left ALT key is pressed.


DocEditEvent.ctrlKey

DocEditEvent.ctrlKey

Declaration: ctrlKey as Boolean

Description

True if the right CTRL key is pressed.


DocEditEvent.ctrlLeft

DocEditEvent.ctrlLeft

Declaration: ctrlLeft as Boolean

Description

True if the left CTRL key is pressed.


DocEditEvent.shiftKey

DocEditEvent.shiftKey

Declaration: shiftKey as Boolean

Description

True if the right SHIFT key is pressed.


DocEditEvent.shiftLeft

DocEditEvent.shiftLeft

Declaration: shiftLeft as Boolean

Description

True if the left SHIFT key is pressed.


DocEditEvent.keyCode

DocEditEvent.keyCode

Declaration: keyCode as long

Description

Keycode of the currently pressed key.

This property is read-write.


DocEditEvent.repeat

DocEditEvent.repeat

Declaration: repeat as Boolean

Description

True if the onkeydown event is repeated.


DocEditEvent.button

DocEditEvent.button

Declaration: button as long

Description

Specifies which mouse button is pressed:

0 No button is pressed.
1 Left button is pressed.
2 Right button is pressed.
3 Left and right buttons are both pressed.
4 Middle button is pressed.
5 Left and middle buttons both are pressed.
6 Right and middle buttons are both pressed.
7 All three buttons are pressed.


DocEditEvent.clientX

DocEditEvent.clientX

Declaration: clientX as long

Description

X value of the current mouse position in client coordinates.


DocEditEvent.clientY

DocEditEvent.clientY

Declaration: clientY as long

Description

Y value of the current mouse position in client coordinates.


DocEditEvent.dataTransfer

DocEditEvent.dataTransfer

Declaration: dataTransfer as Variant

Description

property dataTransfer


DocEditEvent.srcElement

DocEditEvent.srcElement

Declaration: srcElement as Variant

Description

Element which fires the current event.

This is usually an XMLData object.


DocEditEvent.fromElement

DocEditEvent.fromElement

Declaration: fromElement as Variant

Description

Currently no event sets this property.


DocEditEvent.propertyName

DocEditEvent.propertyName

Declaration: propertyName as String

Description

Currently no event sets this property.


DocEditEvent.cancelBubble

DocEditEvent.cancelBubble

Declaration: cancelBubble as Boolean

Description

Set cancelBubble to TRUE if the default event handler should not be called.


DocEditEvent.returnValue

DocEditEvent.returnValue

Declaration: returnValue as Variant

Description

Use returnValue to set a return value for your event handler.


DocEditEvent.type

DocEditEvent.type

Declaration: type as String

Description

Currently no event sets this property.


DocEditSelection

DocEditSelection

Properties

Start
StartTextPosition
End
EndTextPosition


DocEditSelection.Start

DocEditSelection.Start

Declaration: Start as XMLData

Description

XML element where the current selection starts.


DocEditSelection.StartTextPosition

DocEditSelection.StartTextPosition

Declaration: StartTextPosition as long

Description

Position in DocEditSelection.Start.TextValue where the selection starts.


DocEditSelection.End

DocEditSelection.End

Declaration: End as XMLData

Description

XML element where the current selection ends.


DocEditSelection.EndTextPosition

DocEditSelection.EndTextPosition

Declaration: EndTextPosition as long

Description

Position in DocEditSelection.End.TextValue where the selection ends.


SpyProject

Methods
CloseProject
SaveProject
SaveProjectAs

Properties
RootItems
ProjectFile

Description
SpyProject Class


XMLSpyPrj.CloseProject

SpyProject.CloseProject

Declaration: CloseProject(bDiscardChanges as Boolean,bCloseFiles as Boolean,bDialog as Boolean)

Parameters

bDiscardChanges:
Set bDiscardChanges to FALSE if you want to save the changes of the open project files and the project.

bCloseFiles:
Set bCloseFiles to TRUE to close all open project files.

bDialog
Show dialogs for user input.

Description
CloseProject closes the current project.


XMLSpyPrj.SaveProject

SpyProject.SaveProject

Declaration: SaveProject

Description
SaveProject saves the current project


XMLSpyPrj.SaveProjectAs

SpyProject.SaveProjectAs

Declaration: SaveProjectAs(strPath as String,bDialog as Boolean)

Parameters

strPath
Full path with file name of new project file.

bDialog
If bDialog is TRUE, a file-dialog will be displayed.

Description
SaveProjectAs stores the project data into a new location.


XMLSpyPrj.RootItems

SpyProject.RootItems

Declaration: RootItems as SpyProjectItems

Description
Root level of collection of project items.


SpyProject.ProjectFile

SpyProject.ProjectFile

Declaration: ProjectFile as String

Description
Path and filename of the project.


SpyProjectItem

Methods
Open

Properties
ChildItems
ParentItem
FileExtensions
ItemType
Name
Path
ValidateWith
XMLForXSLTransformation
XSLForXMLTransformation
XSLTransformationFileExtension
XSLTransformationFolder

Description
SpyProjectItem Class


XMLSpyPrjItem.Open

SpyProjectItem.Open

Declaration: Open as Document

Return Value
The project item opened as document.

Description
Opens the project item.


XMLSpyPrjItem.ChildItems

SpyProjectItem.ChildItems

Declaration: ChildItems as SpyProjectItems

Description
If the item is a folder, ChildItems is the collection of the folder content.


SpyProjectItem.ParentItem

SpyProjectItem.ParentItem

Declaration: ParentItem as SpyProjectItem

Description
Parent item of the current project item. Can be NULL (Nothing) if the project item is a top-level item.


XMLSpyPrjItem.FileExtensions

SpyProjectItem.FileExtensions

Declaration: FileExtensions as String

Description
Used to set the file extensions if the project item is a folder.


XMLSpyPrjItem.ItemType

SpyProjectItem.ItemType

Declaration: ItemType as SPYProjectItemTypes

Description
This property is read-only.


XMLSpyPrjItem.Name

SpyProjectItem.Name

Declaration: Name as String

Description
Name of the project item.

This property is read-only.


XMLSpyPrjItem.Path

SpyProjectItem.Path

Declaration: Path as String

Description
Path of project item.

This property is read-only.


XMLSpyPrjItem.ValidateWith

SpyProjectItem.ValidateWith

Declaration: ValidateWith as String

Description
Used to set the schema/DTD for validation.


XMLSpyPrjItem.XMLForXSLTransformation

SpyProjectItem.XMLForXSLTransformation

Declaration: XMLForXSLTransformation as String

Description
Used to set the XML for XSL transformation.


XMLSpyPrjItem.XSLForXMLTransformation

SpyProjectItem.XSLForXMLTransformation

Declaration: XSLForXMLTransformation as String

Description
Used to set the XSL for XML transformation.


XMLSpyPrjItem.XSLTransformationFileExtension

SpyProjectItem.XSLTransformationFileExtension

Declaration: XSLTransformationFileExtension as String

Description
Used to set the file extension for XSL transformation output files.


XMLSpyPrjItem.XSLTransformationFolder

SpyProjectItem.XSLTransformationFolder

Declaration: XSLTransformationFolder as String

Description
Used to set the destination folder for XSL transformation output files.


SpyProjectItems

Methods
AddFile
AddFolder
AddURL
RemoveItem

Properties
Count
Item

Description
SpyProjectItems Class


XMLSpyPrjItems.AddFile

SpyProjectItems.AddFile

Declaration: AddFile(strPath as String)

Parameters

strPath
Full path with file name of new project item

Description
The method adds a new file to the collection of project items.


XMLSpyPrjItems.AddFolder

SpyProjectItems.AddFolder

Declaration: AddFolder(strName as String)

Parameters

strName
Name of the new folder.

Description
The method AddFolder adds a folder with the name strName to the collection of project items.


XMLSpyPrjItems.AddURL

SpyProjectItems.AddURL

Declaration: AddURL(strURL as String,nURLType as SPYURLTypes,strUser as String,strPassword as String,bSave as Boolean)

Description

strURL
URL to open as document.

nURLType
Type of document to open. Set to -1 for auto detection.

nLoading
Set nLoading to 0 (zero) if you want to load it from cache or proxy. Otherwise set nLoading to 1.

strUser
Name of the user if required. Can be empty.

strPassword
Password for authentification. Can be empty.

bSave
Save user and password information.

Description
The method adds an URL item to the project collection.


XMLSpyPrjItems.RemoveItem

SpyProjectItems.RemoveItem

Declaration: RemoveItem(pItem as SpyProjectItem)

Description
RemoveItem deletes the item pItem from collection of project items.


XMLSpyPrjItems.Count

SpyProjectItems.Count

Declaration: Count as long

Description
This property gets the count of project items in the collection.

The property is read-only.


XMLSpyPrjItems.Item

SpyProjectItems.Item

Declaration: Item(n as long) as SpyProjectItem

Description
Retrieves the n-th element of the collection of project items.


XMLData

Methods
InsertChild
AppendChild

EraseAllChildren
EraseCurrentChild

GetCurrentChild
GetFirstChild
GetNextChild

IsSameNode

Properties
Name
TextValue

HasChildren
MayHaveChildren

Kind
Parent

Description
XMLData Class


XMLSpyXMLData.InsertChild

XMLData.InsertChild

Declaration: InsertChild(pNewData as XMLData)

Description
InsertChild inserts the new child before the current child (see also XMLData.GetFirstChild, XMLData.GetNextChild to set the current child).


XMLSpyXMLData.AppendChild

XMLData.AppendChild

Declaration: AppendChild(pNewData as XMLData)

Description
AppendChild appends pNewData as last child to the XMLData object. See also "Using XMLData".

Example

   Dim objCurrentParent As XMLData
   Dim objNewChild As XMLData

   Set objNewChild = objSpy.ActiveDocument.CreateChild(spyXMLDataElement)
   Set objCurrentParent = objSpy.ActiveDocument.RootElement

   objCurrentParent.AppendChild objNewChild

   Set objNewChild = Nothing


XMLSpyXMLData.EraseAllChildren

XMLData.EraseAllChildren

Declaration: EraseAllChildren

Description
EraseAllChildren deletes all associated children of the XMLData object.

Example

The sample erases all elements of the active document.

   Dim objCurrentParent As XMLData

   Set objCurrentParent = objSpy.ActiveDocument.RootElement
   objCurrentParent.EraseAllChildren


XMLSpyXMLData.EraseCurrentChild

XMLData.EraseCurrentChild

Declaration: EraseCurrentChild

Description
EraseCurrentChild deletes the current XMLData child object. Before you call EraseCurrentChild you must initialize an internal iterator with XMLData.GetFirstChild.

Example

This JavaScript example deletes all elements with the name "EraseMe". The code shows you, that it is possible to call EraseCurrentChild and GetNextChild inside the same loop to continue stepping through the child elements.

   function DeleteXMLElements(objXMLData)
   {
      if(objXMLData == null)
         return;

      if(objXMLData.HasChildren)   {
         var objChild;
         objChild = objXMLData.GetFirstChild(-1);

         while(objChild)   {
            DeleteXMLElements(objChild);

            try   {
               if(objChild.Name == "EraseMe")
                  objXMLData.EraseCurrentChild();

               objChild = objXMLData.GetNextChild();
            }
            catch(Err)   {
               objChild = null;
            }
         }
      }
   }


XMLSpyXMLData.GetCurrentChild

XMLData.GetCurrentChild

Declaration: GetCurrentChild as XMLData

Return Value
Returns a xml element as XMLData object.

Description
GetCurrentChild gets the current child. Before you call GetCurrentChild you must initialize an internal iterator with XMLData.GetFirstChild.


XMLSpyXMLData.GetFirstChild

XMLData.GetFirstChild

Declaration: GetFirstChild(nKind as SPYXMLDataKind) as XMLData

Return Value
Returns a xml element as XMLData object.

Description
GetFirstChild initializes a new iterator and returns the first child. Set nKind = -1 to get an iterator for all kinds of children.

Example
See the example at XMLData.GetNextChild.


XMLSpyXMLData.GetNextChild

XMLData.GetNextChild

Declaration: GetNextChild as XMLData

Return Value
Returns a xml element as XMLData object.

Description
GetNextChild steps to the next child of this element. Before you call GetNextChild you must initialize an internal iterator with XMLData.GetFirstChild.

Check for the last child of the element as shown in the sample below.

Example

   On Error Resume Next
   Set objParent = objSpy.ActiveDocument.RootElement

   'get elements of all kinds
   Set objCurrentChild = objParent.GetFirstChild(-1)

   Do
      'do something useful with the child

      'step to next child
      Set objCurrentChild = objParent.GetNextChild
   Loop Until (Err.Number - vbObjectError = 1503)


XMLSpyXMLData.Name

XMLData.Name

Declaration: Name as String

Description
Used to modify and to get the name of the XMLData object.


XMLSpyXMLData.TextValue

XMLData.TextValue

Declaration: TextValue as String

Description
Used to modify and to get the text value of this XMLData object. See also "Using XMLData".


XMLSpyXMLData.HasChildren

XMLData.HasChildren

Declaration: HasChildren as Boolean

Description
The property is true, if the object is parent of other XMLData objects.

This property is read-only.


XMLSpyXMLData.MayHaveChildren

XMLData.MayHaveChildren

Declaration: MayHaveChildren as Boolean

Description
Tells if it is allowed to add children to this XMLData object.

This property is read-only.


XMLSpyXMLData.Kind

XMLData.Kind

Declaration: Kind as SPYXMLDataKind

Description
Kind of this XMLData object.

This property is read-only.


XMLData.IsSameNode

XMLData.IsSameNode

Declaration: IsSameNode(pNodeToCompare as XMLData) as Boolean

Description

Returns true if pNodeToCompare references to the same node as the object itself.


XMLSpyXMLData.Parent

XMLData.Parent

Declaration: Parent as XMLData

Return value
Parent as XMLData object.
Nothing (or NULL) if there is no parent element.

Description
Parent of this element.

This property is read-only.


DatabaseConnection

Properties
ADOConnection
ODBCConnection
File

CreateMissingTables
CreateNew

SQLSelect

NumberDateTimeFormat
TextFieldLen
AsAttributes
ExcludeKeys
IncludeEmptyElements

Description
DatabaseConnection specifies a database connection.

Please note that the properties of the DatabaseConnection interface are referring to the settings of the import and export dialogs of XMLSPY 5.


XMLSpyDatabaseConnection.ADOConnection

DatabaseConnection.ADOConnection

Declaration: ADOConnection as String

Description
The property ADOConnection contains a connection string.

Example

   Dim objSpyConn As DatabaseConnection
   Set objSpyConn = objSpy.GetDatabaseSettings

   Dim objADO As DataLinks
   Set objADO = CreateObject("DataLinks")

   If Not (objADO Is Nothing) Then
      Dim objConn As Connection
      Set objConn = objADO.PromptNew
      objSpyConn.ADOConnection = objConn.ConnectionString
   End If


DatabaseConnection.ODBCConnection

DatabaseConnection.ODBCConnection

Declaration: ODBCConnection as String

Description
The property ODBCConnection contains a ODBC connection string.


XMLSpyDatabaseConnection.File

DatabaseConnection.File

Declaration: File as String

Description
The property File sets the path for the database during export or import. See also "Import and Export".


XMLSpyDatabaseConnection.CreateMissingTables

DatabaseConnection.CreateMissingTables

Declaration: CreateMissingTables as Boolean

Description
If CreateMissingTables is true, tables which are not already defined in the export database will be created during export.

Default is true.


XMLSpyDatabaseConnection.CreateNew

DatabaseConnection.CreateNew

Declaration: CreateNew as Boolean

Description
Set CreateNew true if you want to create a new database on export. Any existing database will be overwritten. See also "DatabaseConnection.File".

Default is false.


XMLSpyDatabaseConnection.SQLSelect

DatabaseConnection.SQLSelect

Declaration: SQLSelect as String

Description
The SQL query for the import is stored in the property SQLSelect. See also "Import and Export".


XMLSpyDatabaseConnection.NumberDateTimeFormat

DatabaseConnection.NumberDateTimeFormat

Declaration: NumberDateTimeFormat as SPYNumberDateTimeFormat

Description
The property NumberDateTimeFormat sets the format of numbers and date- and time-values.

Default is spySystemLocale.


XMLSpyDatabaseConnection.TextFieldLen

DatabaseConnection.TextFieldLen

Declaration: TextFieldLen as long

Description
The property TextFieldLen sets the length for created text fields during the export.

Default is 255.


DatabaseConnection.AsAttributes

DatabaseConnection.AsAttributes

Declaration: AsAttributes as Boolean

Description
Set AsAttributes to true if you want to create all data as attributes.

Default is false.


DatabaseConnection.ExcludeKeys

DatabaseConnection.ExcludeKeys

Declaration: ExcludeKeys as Boolean

Description
Set ExcludeKeys to true if you want to exclude all key rows from the import data.

Default is false.


DatabaseConnection.IncludeEmptyElements

DatabaseConnection.IncludeEmptyElements

Declaration: IncludeEmptyElements as Boolean

Description
Set IncludeEmptyElements to false if you want to exclude all empty elements.

Default is true.


ExportSettings

Properties

ElementList

EntitiesToText

ExportAllElements
SubLevelLimit

FromAttributes
FromSingleSubElements
FromTextValues

CreateKeys
IndependentPrimaryKey

Namespace

Description
ExportSettings Class


XMLSpyExportSettings.ElementList

ExportSettings.ElementList

Declaration: ElementList as ElementList

Description
Default is empty list.

This list of elements defines the rows for the export. It is possible to remove elements from export with ElementList.RemoveElement.


XMLSpyExportSettings.EntitiesToText

ExportSettings.EntitiesToText

Declaration: EntitiesToText as Boolean

Description
Default is True.


XMLSpyExportSettings.ExportAllElements

ExportSettings.ExportAllElements

Declaration: ExportAllElements as Boolean

Description
Default is True.

If ExportAllElements is False, then ExportSettings.SubLevelLimit is used to restrict the number of sub levels to export.


XMLSpyExportSettings.SubLevelLimit

ExportSettings.SubLevelLimit

Declaration: SubLevelLimit as Integer

Description
Default is 0.

Defines the number of sub levels to include for the export.
This property is ignored if ExportSettings.ExportAllElements is True.


XMLSpyExportSettings.FromAttributes

ExportSettings.FromAttributes

Declaration: FromAttributes as Boolean

Description
Set FromAttributes to false if no export data should be created from attributes.

Default is True.


XMLSpyExportSettings.FromSingleSubElements

ExportSettings.FromSingleSubElements

Declaration: FromSingleSubElements as Boolean

Description
Default is True.


XMLSpyExportSettings.FromTextValues

ExportSettings.FromTextValues

Declaration: FromTextValues as Boolean

Description
Default is True.


XMLSpyExportSettings.CreateKeys

ExportSettings.CreateKeys

Declaration: CreateKeys as Boolean

Description
Default is True.

This property turns creation of keys on or off.


XMLSpyExportSettings.IndependentPrimaryKey

ExportSettings.IndependentPrimaryKey

Declaration: IndependentPrimaryKey as Boolean

Description
Default is True.

Turns creation of independent primary key counter for every element on or off. If ExportSettings.CreateKeys is False, this property will be ignored.


ExportSettings.Namespace

ExportSettings.Namespace

Declaration: Namespace as SPYExportNamespace

Description
Default is spyNoNamespace.

The default setting removes all namespace prefixes from the element names. In some database formats the colon is not a legal character.


TextImportExportSettings

Properties
HeaderRow

FieldDelimiter
EnclosingCharacter

Encoding
EncodingByteOrder

ImportFile
FileExtension
DestinationFolder

Description
TextImportExportSettings Class


XMLSpyTextImportExportSettings.HeaderRow

TextImportExportSettings.HeaderRow

Declaration: HeaderRow as Boolean

Description
The property HeaderRow is used during import and export.

Set HeaderRow true on import, if the first line of the text file contains the names of the columns.
Set HeaderRow true on export, if the first line in the created text files should contain the name of the columns.

Default value is true.


XMLSpyTextImportExportSettings.FieldDelimiter

TextImportExportSettings.FieldDelimiter

Declaration: FieldDelimiter as SPYTextDelimiters

Description
The property FieldDelimiter defines the delimiter between the fields during import and export.

Default is spyTabulator.


XMLSpyTextImportExportSettings.EnclosingCharacter

TextImportExportSettings.EnclosingCharacter

Declaration: EnclosingCharacter as SPYTextEnclosing

Description
This property defines the character that encloses all field values for import and export.

Default is spyNoEnclosing.


XMLSpyTextImportExportSettings.Encoding

TextImportExportSettings.Encoding

Declaration: Encoding as String

Description
The property Encoding sets the character encoding for the text files for importing and exporting.


XMLSpyTextImportExportSettings.EncodingByteOrder

TextImportExportSettings.EncodingByteOrder

Declaration: EncodingByteOrder as SPYEncodingByteOrder

Description
The property EncodingByteOrder sets the byte order for UNICODE characters.

Default is spyNONE.


XMLSpyTextImportExportSettings.ImportFile

TextImportExportSettings.ImportFile

Declaration: ImportFile as String

Description
This property is used to set the text file for import. The string has to be a full qualified path.

See also "Import and Export".


XMLSpyTextImportExportSettings.FileExtension

TextImportExportSettings.FileExtension

Declaration: FileExtension as String

Description
This property sets the file extension of the text files created on export.


XMLSpyTextImportExportSettings.DestinationFolder

TextImportExportSettings.DestinationFolder

Declaration: DestinationFolder as String

Description
The property DestinationFolder sets the folder where the created files are saved during export.


ElementListItem

Properties
ElementKind
Name

FieldCount
RecordCount

Description
ElementListItem Class


XMLSpyElementListItem.ElementKind

ElementListItem.ElementKind

Declaration: ElementKind as SPYXMLDataKind

Description
Kind of element.


XMLSpyElementListItem.Name

ElementListItem.Name

Declaration: Name as String

Description
Name of the element.


XMLSpyElementListItem.FieldCount

ElementListItem.FieldCount

Declaration: FieldCount as long

Description
Count of fields for this element. The actual value depends on the current export settings.


XMLSpyElementListItem.RecordCount

ElementListItem.RecordCount

Declaration: RecordCount as long

Description
Count of records for this element. The actual value depends on the current export settings.


ElementList

Methods
RemoveElement

Properties
Count
Item

Description
ElementList Class


XMLSpyElementList.RemoveElement

ElementList.RemoveElement

Declaration: RemoveElement(Index as long)

Description
RemoveElement removes the element Index from the collection.


XMLSpyElementList.Count

ElementList.Count

Declaration: Count as long

Description
Count of elements in this collection.


XMLSpyElementList.Item

ElementList.Item

Declaration: Item(n as long) as ElementListItem

Description
Gets the element with the index n from this collection.


Enumerations

Enumerations

This is a list of all enumerations used by the XMLSPY 5 API. Some API methods take them as an input parameter. If your scripting environment does not support enumerations use the number-values instead.

SPYProjectItemTypes:

spyUnknownItem = 0
spyFileItem = 1
spyFolderItem = 2
spyURLItem = 3

SPYURLTypes:

spyURLTypeAuto = -1
spyURLTypeXML = 0
spyURLTypeDTD = 1

SPYXMLDataKind:

spyXMLDataXMLDocStruct = 0
spyXMLDataXMLEntityDocStruct = 1
spyXMLDataDTDDocStruct = 2
spyXMLDataXML = 3
spyXMLDataElement = 4
spyXMLDataAttr = 5
spyXMLDataText = 6
spyXMLDataCData = 7
spyXMLDataComment = 8
spyXMLDataPI = 9
spyXMLDataDefDoctype = 10
spyXMLDataDefExternalID = 11
spyXMLDataDefElement = 12
spyXMLDataDefAttlist = 13
spyXMLDataDefEntity = 14
spyXMLDataDefNotation = 15
spyXMLDataKindsCount = 16

SPYDTDSchemaFormat:

spyDTD = 0
spyDCD = 1
spyXMLData = 2
spyBizTalk = 3
spyW3C = 4

SPYTypeDetection:

spyBestPossible = 0
spyNumbersOnly = 1
spyNoDetection = 2

SPYFrequentElements:

spyGlobalElements = 0
spyGlobalComplexType = 1

SPYNumberDateTimeFormat:

spySystemLocale = 0
spySchemaCompatible = 1

SPYEncodingByteOrder:

spyNONE = 0
spyLITTLE_ENDIAN = 1
spyBIG_ENDIAN = 2

SPYTextDelimiters:

spyTabulator = 0
spySemicolon = 1
spyComma = 2
spySpace = 3

SPYTextEnclosing:

spyNoEnclosing = 0
spySingleQuote = 1
spyDoubleQuote= 2

SPYLoading:

spyUseCacheProxy = 0
spyReload = 1

SPYViewModes:

spyViewGrid = 0
spyViewText = 1
spyViewBrowser = 2
spyViewSchema = 3
spyViewContent = 4

SPYSchemaDefKind:

spyKindElement = 0
spyKindComplexType = 1
spyKindSimpleType = 2
spyKindGroup = 3
spyKindModel = 4
spyKindAny = 5

spyKindAttr = 6
spyKindAttrGroup = 7
spyKindAttrAny = 8

spyKindIdentityUnique = 9
spyKindIdentityKey = 10
spyKindIdentityKeyRef = 11
spyKindIdentitySelector = 12
spyKindIdentityField = 13

spyKindNotation = 14

spyKindInclude = 15
spyKindImport = 16
spyKindRedefine = 17

spyKindFacet = 18

spyKindSchema = 19

spyKindCount = 20

SPYExportNamespace:

spyNoNamespace = 0
spyReplaceColonWithUnderscore = 1

DOCEDElementActions:

k_ActionInsertAt = 0
k_ActionApply = 1
k_ActionRemoveSurr = 2
k_ActionAppend = 3
k_ActionInsertBefore = 4

Previous Top