XMLSpy® 2005 includes a built-in code generator that generates program code bindings of XML Schema components in Java, C++, or Microsoft C#.
Code Generator
XMLSpy® 2005 now includes a built-in code generator that automatically generates Java, C++, or Microsoft C# class files based on data elements defined in an XML Schema. An overview of the simple two-step code generation process is illustrated in the following figure:
(1) Model data elements in XML Schema using the XMLSpy® 2005 Schema Editor
(2) XMLSpy® 2005 will auto-generate class files (data bindings) corresponding to elements defined in your data model
XML Schema is ideally suited for data modeling in modern software applications because it supports the concept of datatypes and object-oriented design. This enables XML Schema to bridge the gap between the relational database model and current object-oriented software design methodologies.
What is an XML Data Binding?
An XML data binding is a mapping of one or more XML data elements to a set of related software objects. Implementation of a data binding for XML data elements is required because XML is not a full programming language, in that it cannot be compiled or executed as stand-alone binary executable file. Rather, XML documents must be bound to an external software application or runtime environment such as a business-to-business application or Web service.
An XML data binding allows you to programmatically work with XML documents from within your software application via a set of simple objects. It can be thought of as an abstraction layer between an XML document and your custom application (business logic), alleviating the need for developers to understand the technical intricacies of loading, editing, and saving, an XML document using low-level XML parsing APIs.
The following figure shows a typical example of the application of a data binding in a Web Services application, located in between the inbound XML stream and custom business logic:
Today, there are many tools that create the SOAP "plumbing" - i.e. the client/server stubs and skeletons required to marshal an XML document from one process to another - yet you still must write a data binding to process the inbound XML documents within a SOAP envelope and create the appropriate XML message in response. The XMLSpy® 2005 code generator can automate the tedious process of implementing a data binding, freeing a developer to focus on implementing business logic.
Implementing an XML Data Binding
Implementing an XML data binding involves writing infrastructure code to create, read, update and delete an XML document in memory using low-level XML processing APIs such as the Simple API for XML Parsing (SAX) or the Document Object Model (DOM). In addition to the basic infrastructure methods, a data binding must include additional higher level functions/methods to validate, process, transform, and perform other common in-memory operations on an XML document. XMLSpy® 2005 automates this task by providing a simple menu item that can generate program code based on an XML Schema, as shown below:
Implementation of an XML data binding is a tedious, error-prone task, requiring dozens, and possibly hundreds of class files. For example, consider the following data model of a company organization chart, which consists of data elements such as Office, Department, Person, Address, etc. (Click on screenshot to enlarge).
In this example, the generated program code data binding consists of 24 classes and thousands of lines of code. Click to download and view the auto-generated code in for this sample application in Java, C++, or Microsoft C#, then select "Save Target as..." to save and view the files.
XMLSpy® 2005 Code Generation Features
The following is a summary of XMLSpy® 2005 code generator features:
Default templates to automatically generate class definitions corresponding to all declared elements or complex types that redefine any complex type in your XML Schema
Preservation of class derivation as defined by extensions of complex types in your XML Schema.
Support for Java, C++, and Microsoft C# program code output.
Support for industry standard XML processing APIs including Microsoft MSXML, Java API for XML Processing (JAXP), and Microsoft System.XML
The generated C++ output includes a Visual Studio 6.0 project file; the generated Java output is includes a Sun Forte for Java project file and Apache Ant build script; Microsoft C# output includes a Visual Studio.NET project file.
Output code is completely customizable via a simple yet powerful template language that gives full control in mapping XML Schema built-in data-types to the primitive datatypes of a particular programming language.
You can easily replace the underlying parsing and validating engine, customize code according to your company's writing conventions, or use different base libraries such as Microsoft Foundation Classes (MFC) and Standard Template Library (STL).
Ability to build your own templates to automate the generation of anything imaginable, e.g., SQL scripts, ASP or WML code.
Generation of project files for Borland C# Builder and other third party IDEs including MONO.
The following screenshot shows just how easy it is to generate an XML data binding using XMLSpy® 2005 Enterprise Edition:
XMLSpy® 2005 Code Generation Benefits
XMLSpy® 2005's schema editor is a well equipped software modeling and prototyping tool that allows XML applications to be rapidly prototyped at a high level in XML Schema and then automatically generated. Changes to an application's XML Schema content model can be immediately reconciled with a software implementation simply by re-running the code generator. Built-in code generation frees software developers from the mundane task of writing low level infrastructure code, enabling them to focus on implementing critical business logic. By automatically generating a programming language binding, XMLSpy® 2005 accelerates project development time from initial design to final implementation, resulting in substantial cost savings and time to market advantages.
Enhanced Customization Options
The XMLSpy® 2005 code generator now supports the use of Apache Xerces (a popular XML parser) and Standard Template Library (STL), as well am additional support of XML Schema simple types in Java/C#/C++ generated output code.
Did you know that Altova MapForce™ 2005 auto-generates program code for custom XML / database / EDI data integration projects? MapForce™ 2005 and XMLSpy® 2005 are highly complementary - using them together, a software developer could auto-generate much of the code needed for an XML-enabled application, including the code to marshal data from different sources.
To learn more about the comprehensive data integration and code generation capabilities of Altova's highly complementary products, check out the Altova Enterprise XML Suite 2005 and Professional XML Suite 2005. These specially-priced suites bundle Altova's award-winning products to meet all your XML development needs.