Because building an XML application is likely to involve many files of varying types, XMLSPY includes a Project window to help you effectively organize and work with multiple files in a team environment. The benefits of using the XMLSPY Project window include the capability to organize files into folders and the capability to set folder properties that specify a certain behavior to be applied to all files within the folder. Examples of folder properties include specifying that a particular XSLT stylesheet or XML Schema be used on all files in a particular folder, or performing a document validation or well-formedness check on all files in a folder as a batch operation. In this section, you learn the important aspects of working with XMLSPY projects, including creating projects and folders, adding files to projects, specifying folder or project properties, and configuring XMLSPY for use with external source code version control systems.
The special version of XMLSPY included on the accompanying CD opens the XMLSPY Handbook project by default. This project is also accessible from the Project window located at the top-left corner of the XMLSPY editing environment. If you did not install XMLSPY from the accompanying CD, make a local copy of the XMLSPY Handbook.spp file from the CD, along with all subdirectories (Ch2, Ch3, Ch4, and so on). You handle all project operations, including opening, closing, saving, and creating new XMLSPY projects, from the Project menu (see Figure 2-37).
Figure 2-37: The XMLSPY Project menu.
To create a new project, choose Project → New Project. A new Project window (shown in Figure 2-38) automatically appears. The Project window, like most other XMLSPY windows, is a completely dockable window that you can move anywhere within in the XMLSPY editing environment. You can also toggle its visibility on or off by choosing Window → Project Window. All project settings are stored in an XMLSPY project file (.spp), which is an XML-based configuration file that normally you should not edit manually.
Figure 2-38: A new XMLSPY project displayed in the Project window.
After you create a new XMLSPY project, that project becomes the current project. By default, the project includes some basic project folders. You can easily delete folders that you don’t need by clicking the folder and pressing the Delete key.
To add files to a project, right-click the project folder to which you want to add files and choose Project → Add Files. A file explorer appears. Choose the file that you want to add and click OK. XMLSPY also supports adding files located on an external server, provided that the server supports access through HTTP, WebDAV, or FTP (most servers do this, of course). To add files from an external server, choose Project → Add URL to Project, and type the file URL in the resulting dialog box. You can also add the active document (the document that you are working on) from the main editing window to the current project by choosing Project → Add Active File to Project. Remember that you must save your work to a file before you can add it to a project.
XMLSPY’s Project window allows you to create three different types of folders: Project folders, External folders, and Web folders. You can insert or nest them anywhere within an XMLSPY project. These folders are described in more detail in the following list:
Project folders: Internal to XMLSPY only, they do not exist or have any meaning anywhere outside of the XMLSPY Project window.
External folders: Correspond to a Microsoft Windows operating system folder on either the local file system (such as the My Documents directory) or on the local area network.
Web folders: Folder located on an external server, accessible via HTTP, FTP, or WebDAV file access protocols. In the case of HTTP, you will most likely be editing a copy of the file. Upon saving, XMLSPY attempts to save the file back to the Web server, but it likely will fail. You are then prompted to save the file to the local file system. In the case of FTP or WebDAV access, however, your edits are saved back to the server from which the document originated.
To add any of the preceding types of folders to a project, open the Project menu and choose the Add Folder option that corresponds to the type of folder you want to add to your project. In the case of a Web folder, you must specify the URL, as well as a username and password, to access the remote server (see Figure 2-39).
Figure 2-39: Add a Web folder to the Project window.
WebDAV stands for Web-based Distributed Authoring and Versioning. It is a connectionless distributed file-sharing protocol developed by the Internet Engineering Task Force (IETF) that is intended to be a replacement for FTP. Using a WebDAV-enabled editor such as XMLSPY, however, you can access and edit files located on external (WebDAV-compliant) Web servers, databases, or file systems and make changes to the documents as though they reside on the local file system. Upon saving, the updated files are sent back to the server from which they originated.
Files residing on the local file system, as well as external file URLs can be grouped into folders by common file extensions or by any other criteria you choose. After arranging your files, you can perform batch processing on specific folders or on the project as a whole. Here are some examples:
You can assign DTD or XML Schemas to specific folders allowing any XML file within the folder to be validated with a single click.
You can assign an XSLT stylesheet to specific folders, allowing for any XML file within the folder to be transformed with a single click.
You can specify the output directory of an XSL transformation.
You can define the settings for a project by choosing Project → Project Properties to open the Properties dialog box. Alternatively, you can apply settings to a single folder by right-clicking the folder and choosing Properties from the drop-down list. The Properties dialog box is the same for both projects and folders (see Figure 2-40).
Figure 2-40: A Properties window for either a project folder or the entire project.
A source code repository and versioning system is a centralized server for storing all of a company’s source code files, including both the most current version and a history of all previous changes made to the source code files. Using a repository and versioning system, a company’s software engineering group can collectively store all source code files in such a manner that multiple developers can safely work together on the same project. To understand the value of a source code and versioning system, consider the potential problems of developing a large software project in a team environment:
Two developers may accidentally work on the same file simultaneously and when they save back their work to a regular file server, one developer’s work is over-written.
Changes to one file may cause adverse side effects to other parts of the software program.
Repository and versioning systems such as Microsoft Visual SourceSafe (VSS) overcome these problems by disallowing concurrent access to files. If you want to make a change to a file, you must first check out the file from VSS. While you are working on the files, VSS places a lock on the files that blocks any attempt to access them. When you are finished editing the file, you must check the file back in to VSS. VSS maintains a change log that shows the differences of the file before and after your edits.
XML files edited using XMLSPY can be edited in conjunction with an external source code repository and version control system, such as Microsoft VSS. In this section, I cover how to configure XMLSPY to work with Microsoft VSS.
Be sure that you have installed the Microsoft VSS client software on your local computer. Then make sure that you have a username and password that enables you to access a Microsoft VSS database installation from your computer. To obtain a copy of Visual SourceSafe, ask your IT department if they have a Microsoft Developers Network (MSDN) Universal Subscription or visit http://msdn.microsoft.com/ ssafe/.
XMLSPY projects differ from VSS projects and should not be confused with one another. Consider that XMLSPY projects support three different types of folders: Project, External, and Web folders. VSS supports only one type of folder, which also happens to be named Projects, and which is essentially Microsoft Windows directories on a file system. One immediate consequence is that Web folders cannot be used in conjunction with Microsoft VSS. Follow these steps to integrate XMLSPY with Microsoft VSS:
Open the XMLSPY project file (.spp) that you would like to use in conjunction with Microsoft VSS. In this example, I have created a hypothetical project called myproject and have added two files as previously explained. Click the .spp project file that appears at the top of the Project View window, as shown in Figure 2-41.
Figure 2-41: A project to be used in conjunction with Microsoft Visual SourceSafe.
Choose Project → Source Control → Add to Source Control. The Microsoft VSS Client Software Login dialog box appears, prompting you to log in to a VSS database.
Type your username and password and click OK. The Microsoft VSS client software’s Add to SourceSafe Project dialog box appears.
Select an existing VSS project to add the file(s) to or create a new VSS project by typing a project name. Click OK. In Figure 2-42, there are no existing projects in the VSS Database, therefore, you simply type the new project name in the Project field. When you click OK, VSS asks Project $/myproject Does Not Exist. Would You Like to Create It? Select Yes.
Figure 2-42: The Add to Microsoft SourceSafe Project window.
Microsoft VSS prompts you to select which files you want to add to the project. In this example, I have the option to add data.xml and web.xsl, in addition to the myproject.spp file (see Figure 2-43). Those files happen to be in the same folder as the .spp file. Select the files you want to add and then click OK. (Note: You can add more files to Microsoft VSS at any later time.)
Figure 2-43: The Microsoft VSS Add File(s) window.
You have now configured your XMLSPY project to work in conjunction with Microsoft VSS. Note that the file icons in the Project window should now have tiny little locks on the top-right corner, as shown in Figure 2-44. These locks indicate that the files are read-only because they are checked into Microsoft VSS.
Figure 2-44: XMLSPY’s Project window, integrated with Microsoft VSS.
In order to edit a file in your project, you must first check out the file from the Microsoft VSS database, thus placing an exclusive lock on the file and preventing other people from working on the file while you are making edits. Right-click the file that you would like to edit and choose Check Out from the menu.
Notice that when a file is checked out from Microsoft VSS (that is, you have locked the file and have exclusive write-access to it), the file icon displays a little red check-mark on the top-right corner, as shown in Figure 2-45.
Figure 2-45: XMLSPY’s Project window indicates when a file has been checked out.
When your edits are complete, right-click the file icon and choose Check-In from the menu.
In addition to Microsoft Visual SourceSafe, XMLSPY can work with other repository and version control systems—in particular, Concurrent Versioning System (CVS), a widely used open-source product. Connectivity with CVS and other version control systems is achieved through a third-party driver called Jalindi Igloo. For more information, see the Web page for the product at www.jalindi.com/igloo/.