Introduction to MAPFORCE Student Edition Educational materials by Altova Educational Services
Compiled by: Abdellah Benchikhi, David Kershaw Created on: 2003-10-28 Last updated: 2004-04-20 Copyright 2003, Altova GmbH, All Rights Reserved. Except as Otherwise Expressly Permitted, Reproduction Strictly Prohibited This document contains the written materials for the presentation of an Altova training session. Unless your organization is a current participant in the Altova Partner Program at the Elite Level for Education Partners, no part of this publication may be reproduced, transcribed, stored in a retrieval system or transmitted in any form, or by any means, (electronic, mechanical, photocopying or otherwise) or for any purpose without the prior written permission of Altova GmbH. XMLSPY, AUTHENTIC, STYLEVISION, MAPFORFCE, MARKUP YOUR MIND, AXAD, NANONULL, and ALTOVA are trademarks of Altova GmbH (registered in numerous countries). All other trademarks are the property of their respective owners. The information described within this document is subject to change without notice. While Altova has invested effort in the development of this document and believes its contents to be accurate as of the date of publication, neither Altova GmbH nor the author of these materials assumes any responsibility for any errors which may appear herein. The presenter or instructor using these materials is not authorized by Altova to make any representations outside of the scope of that shown within the text of the document. This document is not intended as a replacement for the software documentation provided by Altova as part of the software license agreement with end users. ALTOVA MAKES NO WARRANTIES, EXPRESS OR IMPLIED WITH RESPECT TO THE QUALITY, RELIABILITY, CURRENTNESS, CORRECTNESS, ACCURACY OR FREEDOM FROM ERROR OF THIS DOCUMENT OR THE PRODUCTS DESCRIBED HEREIN. ALTOVA MAKES NO REPRESENTATION OR WARRANTY WITH RESPECT TO THE CONTENTS OF THIS DOCUMENT AND SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE. TO THE GREATEST EXTENT PERMITTED BY LAW, ALTOVA DISCLAIMS ALL LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL, SPECIAL OR EXEMPLARY DAMAGES RESULTING FROM THE USE OF THE INFORMATION CONTAINED IN THIS DOCUMENT OR FROM THE USE OF ANY PRODUCTS DESCRIBED HEREIN. Unless otherwise noted, example companies, data, people, organizations, logos, places, events and products depicted herein are fictitious and no associate with any such real companies, data, people, organization, logos, places, events and products is intended or should be inferred. The sample code or software provided in or with this document is provided "AS IS," without a warranty of any kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. ALTOVA SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL ALTOVA BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF ALTOVA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
Contents Introduction to MAPFORCE 2 - What is mapforce? 9 - Quick overview of mapforce terminology 10 - mapforce concepts and approaches 16 - Organization of generated code 18 - Questions 19 - Resources
What is MAPFORCE? The MAPFORCE 2004v4 user interface Visual data transformation and application integration
What is MAPFORCE continued: product history MAPFORCE is Altova's newest product and the first targeted specifically at systems integration September 2003 : mapforce 2004 launched October 2003 : mapforce 2004 v3 adds C++ and C# code generation May 2004 : mapforce 2004 v4 adds EDI and database insert, update and delete Notes for "What is MAPFORCE " mapforce launched with support for XSLT mapping and Java code generation Less then two months later release 2 added C++ and C# code generation Over the next six to ten months MAPFORCE will add: Design time and code generation to connect with Web services Tighter connections to Altova's other products Other innovative features to add even more value to mapforce's role as a systems integration component generator
What is MAPFORCE continued: new features The new Overview Window Improved XSLT and results views Additional tool bars for new features Notes for "What is MAPFORCE " The Overview Window gives you the 10,000 foot view of your project so you can quickly navigate even the most complex mapping without continuously zooming in and out. mapforce's new text views provide syntax coloring, folding, indent guides, line numbering and more so you can quickly see how your visual changes impact the stylesheets you are generating. This is both a great debugging tool and a terrific way to learn about how XSLT works. User defined functions will be available in 2004v4. The name user defined function is confusingly similar to the custom function idea that has been a part of MAPFORCE from the begining. The difference is that today's custom functions are always XPath functions underneath, or source code. A user defined function will be able to be written in XSLT. As an example of the benefit of this approach, consider the problem of attempting to create a function that does the same thing as xsl:copy. Now this will be easy to do. There are dozens of other improvements and new features in the v4 release of mapforce. The most important of them are visible in the main tool bar, including EDI support and multiple connectors into one end point.
What is MAPFORCE continued There are a few things mapforce doesn't do yet: Doesn't handle mixed text Doesn't do redefines Doesn't see substitution groups Notes for "What is MAPFORCE " Mixed text and substitution groups are due to be implemented by late summer 2004.
What is MAPFORCE continued: what is in the box? mapforce installs several groups of files The mapforce application Examples and documentation Function libraries for XSLT, Java, C#, and C++ Code generation templates (back these up before you modify them!) Notes for "What is MAPFORCE " Help files: Altova help files always include the software's reference manual as well as basic usage information and tutorials. Function libraries: the metadata files are in the MapforceLibraries directory right below the MAPFORCE install directory. Examples: examples and tutorial files are located in MapForceExamples. Code generation templates: the SPL templates mapforce uses to generate programming language mapping components (as opposed to XSLT mappings) are in MapforceSPL.
The MAPFORCE Install directory XMLSPYLicMan.dll and XMLSpyLicManExe.exe are the Altova License Manager components oraclm32.dll is the Oracle client component The gra_*.txt files support the XML, XSD and XSLT parser components in MAPFORCE UnicodeData.txt and Blocks.txt support MAPFORCE's full Unicode character set recognition
What is MAPFORCE continued? mapforce is a: Visual XSLT generator Visual SQL generator Schema driven code generator Mapping tool that can convert between: Relational data XML Schema EDI Java, C# and C++ objects Notes for "What is MAPFORCE " Mapping tool: At its core, mapforce is a combination of two things: 1. XML binding, and 2. object-relational mapping. XML binding frameworks map XML to objects. These tools are either code generators that create the source code that is compiled into classes that know how to serialize themselves into XML or they are independent serialization components that read an object's state and combine that with a description of the desired XML output. Object relational mapping is the process of bridging between relational data and application objects. O/R mapping tools, like XML binding tools, are either code generators or they descriptively bind table fields to object members. Although binding relations of tabular data to objects seems simple enough at first glance, data mapping is one of the perennial issues in enterprise software development and one that has generated many different solutions, from EJB to SQLJ to OODBMS to the stand alone O/R tools. Schema driven code generator: mapforce (and also xmlspy) generates source code using templates you will look at some of those templates shortly. Like most template languages each template is matched with an input that determines exactly how the template behaves. In mapforce's case (and also in XMLSPY's) the primary input is an object representation of an XML Schema or DTD. In fact, mapforce takes more than one schema where xmlspy takes only one. The contents of the schema object models, along with the associated mapping project information, influence what namespaces (packages for Java) the classes will be in, what the names of the classes will be, what members map to what other members, which filters and conditionals are used (if any) and many similar issues. So the code generation is schema driven. This is important to mapforce because, of course, schemas are integral to how the tool works. But it is also important to you because when the day comes that you are working on a major project and you find that you need to get slightly different code out of mapforce Visual query generator: As mapforce becomes able to generate results of mappings within it's own GUI and without code generation it will become possible to think of mapforce as a way to create queries visually across databases.
What is MAPFORCE continued The four broad types of systems integration Notes for "What is MAPFORCE " No doubt there are other valid ways to categorize the types of systems integrations mapforce can play a strong role in each of these categories. Mapping concepts to alphabet soup: However, it makes sense to look primarily at issues of coordination, communication and collection. dprocess integration: includes BPM (business process management), workflow, records management, etc. Application integration: includes EAI (enterprise application integration), MOM (message oriented middleware), etc. Data federation: includes EII (enterprise information integration), ECM (enterprise content management), meta-directories, etc. Data integration: includes ETL (Extract Transform Load), Data Warehousing, etc.
What is MAPFORCE continued A few of the scenarios where mapforce can play a role include: Message-oriented systems integration Object persistence Single-source multi-channel publishing Multi-source reporting Schema evolution Notes for "What is MAPFORCE " Systems integration: one of mapforce's great strengths is data source federation. MAPFORCE makes it relatively simple to join information from multiple relational databases or from multiple XML and relational sources Object persistence: this use of mapforce is twofold: 1. XML serialization, and 2. O/R mapping. However, clearly you must wait until the next point release (2004v4)for mapforce to be able to update a database. Single source publishing: in the publishing industry, and any company where multi-format publishing happens, this is the big goal: outputting the same basic content in forms and formats that are right for a particular context. An example is the publishing company that pipes the same content into printed form, into PDF for ebook use, into a CD-ROM as an educational supplement, and, in a reduced form, on to a subscription web site. Since mapforce moves data in XML form it is only an effective choice for a single source publishing effort if there are output formats that are XML or that have an XML analogue (e.g. WordprocessingML is an effective analogue for Word document format). Multi source reporting: many applications that use mapforce as a systems integration tool are complex, but there are also many cases when just getting data from disparate sources into a report is the challenge. Most report generators can take XML as an input and any XML data can be transformed into a basic report using XSLT. Schema evolution: if you have ever had to deal with a critical schema controlled by a different development group you have probably at least considered the issue of schema evolution. When a schema changes and static data needs to evolve to meet the new standard mapforce can make it a snap to map the changes and process the content.
Quick overview of MAPFORCE terminology Some MAPFORCE terminology in action Notes for " Quick overview of MAPFORCE terminology" Some terminology: Library: a Library is a collection of functions visible in the Libraries window. Four libraries are available in MAPFORCE out of the box: XSLT, C#, C++ and JAVA functions. Component: the term component refers to schemas, databases, functions and other graphical elements you can insert in a mapping project. Function: Functions are operations on data. Each function will have output and may also take input parameters. Dragging a function onto a mapping project from the Libraries Window creates a function component. Item: An item is the unit of data that can be mapped from schema to schema. An item can be either an element, an attribute or a database field. Input and output icons: the small triangles visible on components are called input and output icons. Clicking and dragging one icon to another icon connects them together. The resulting connector line represents a mapping between the two sets of data. Connector: A connector is the line joining two icons. It represents the mapping between the two sets of data the icons represent. Constant: Constants are components that supply fixed data to an input icon. The data is entered into a dialog box when you create the component. Constants can be typed as either numbers or strings. Filter: A filter is a component with two input parameters: node/row and bool, and one output. At runtime, if the boolean is true, the value of the node/row parameter becomes the output of the filter. Condition: A condition is a component which allows you to pass on different sets of data depending on the outcome of a preset condition. The component header displays the text if-else.
MAPFORCE concepts and approaches mapforce has distinctive approaches to several systems integration (SI) challenges In the next few minutes you will get an overview of: Joins and splits Design-time and componentized integration Use of "meta" functions across languages Pipelined logic using conditionals, filters, modifiers and constants Cross-language code generation using templates
MAPFORCE concepts and approaches continued: joins and splits MAPFORCE mapping patterns Notes for "MAPFORCE concepts and approaches " mapforce supports joining data and splitting data: Many to one One to many Many to many Multi-step Heterogeneous joins and data federation
Three targets Two targets Heterogeneous joins: refers to mapforce's ability to link data from different types of data stores. Currently you can merge XML and relational data. In the near future other types of data store will be added to the list EDI first, then others. Data federation is a term that is often used to describe systems that join multiple separate data servers. For example, a data federation tool might be used to create a single logical view of three relational databases, one for sales, one for manufacturing and one for the supply chain.
MAPFORCE concepts and approaches continued: design-time integration Design for integration mapforce encourages the use of schemas as interfaces Integrate in real-time as you design "One touch" integration with your application Notes for "MAPFORCE concepts and approaches " Design for integration: today mapforce is definitely an XML centered tool. In order to create a mapping project you must have a target schema (though in particular circumstances you could ask mapforce to map a database table to its own XML schema representation, as generated by XMLSPY, to achieve a component that simply delivers a "pure" representation of that database schema as XML ). The need for an XML Schema target puts data integration squarely in the realm of extended "domain modeling", regardless of if the application receiving the data is domain modeled itself. We at Altova would argue that is definitely a Good Thing because it 1. forces a more methodical approach to systems integration, and because 2. it permits you to place an abstract XML layer between your systems. Having an XML layer mediate between two systems permits each system to change independently. And because the integration component is code generated by mapforce it is quick and easy to visually update if one system changes, and there are fewer chances for programmer error. Integrate as you design: like most UML tools, mapforce generates code in real time (XSLT, SQL) and on-demand (Java, C#, C++). As you design your mapping you are creating the implementation. Unlike UML tools, mapforce generates a complete integration component, ready to be called from production code, right from your design. Moreover, with XSLT (and in the future also with database mapping projects) you can see the results of your logic in the preview tab so you know when you are on the right track think of this as a kind of virtual continuous integration. One method integration: if your target system takes XML as an input format integrating the code mapforce generates with your application is a question of calling one method. If not, however, you have the usual DOM walking still to write before your system can get the data it needs from the DOM tree or file mapforce generates. In the 2004v4 release mapforce will generate code to connect the generated integration component directly to a target relational database. In the future Web services will also be supported.
MAPFORCE concepts and approaches continued: "meta" functions mapforce applies rules to data using mapforce functions Functions are organized in four pre-defined libraries and any number of custom libraries Users may define and import their own library definitions based on new or existing code Each function definition may cross languages mapforce raises an error if a function is not supported in the language being generated Notes for "MAPFORCE concepts and approaches " Function libraries are simply XML definitions of a set of functions implemented in one or more programming languages. Each function name may have an implementation in C++, C#, Java, and XSLT. Implementations do not necessarily have the same names or outcomes. For the programming languages, functions can use existing code only if the method in question is static and uses mapforce's data wrappers. The data wrapper classes are generated with every mapforce project. They include SchemaString, SchemaInt, etc. It is possible to modify the mapforce code generation templates to ease this requirement; however, that modification requires a fair amount of SPL hacking so going that direction would not be worth while unless you had a substantial amount of legacy code you didn't want to modify to suit mapforce.
The.mff schema
MAPFORCE concepts and approaches continued: pipelined logic Mapping logic is added in function "pipelines" where functions feed from one to another Three types of functions ship with mapforce: Query forming Result filtering Data shaping Three of the more important built-in functions Notes for "MAPFORCE concepts and approaches " Query forming: mapforce functions that are analogs to the relational operators (=, +, <, etc.) and a few similar operators and database functions are used by mapforce as hints for how to generate more efficient SQL queries. Result filtering: these are functions that do not impact the SQL that MAPFORCE generates, but do impact the result of the mapping by filtering the data. Data shaping functions are those that create (constants) or modify data. Even with just the built-in function libraries there is not a lot you can't do with the logic components available to mapforce. However, it is true that the more functions you chain together the more difficult it will be to understand your mapping project. At some point it may make sense to start using more coarse grained custom functions if you find yourself in that position. A future release of mapforce will introduce new strategies to make mapping projects even simpler to understand visually.
MAPFORCE concepts and approaches continued: code generation The way mapforce handles code generation: Separates the logical mappings you create from the programming language you choose Gives you the opportunity to modify mapforce's output to match development patterns mapforce uses the same SPL template language as xmlspy, so you can reuse what you may already know Notes for "MAPFORCE concepts and approaches " The Model Driven Architecture paradigm being pushed by the OMG and UML tool companies says that you will be able to generate working applications from complete models in multiple languages and architectural styles. mapforce is ready when those next generation modeling tools are. If you need to create an integration libraries for.net and J2EE applications, both hitting the same data sources, the mapforce mapping you create for one system could conceivably be regenerated and reused with the other. Today SPL (or Spy Programming Language)is used by many companies to generate Java, C# or C++ domain models using xmlspy. mapforce tkes SPL a step or two further but the fundamental SPL template language stays the same.
Organization of generated code One XSLT file is created for each leg of a transformation, each in the same directory C# and C++ have more files and more complicated directory layouts Java has the most complex directory structure of all, but logically it is almost identical to C# and C++ Java code generation results in a much more complex directory structure then the 'C' languages Notes for "Organization of generated code" The major structures are recognizable in the code trees generated for each language. They are: Altova: holds common infrastructure classes for XML manipulation, Schema data types, database access, functions, etc. Library: holds the classes that are specific to the mapping project's data Mapforce: holds the default mapping application. A different name can be used by changing the application name in the mapping settings dialog.
Organization of generated code continued A mapforce project always generates unit test mapping applications The generated libraries are ready to use as integration components The Java GUI mapping application Notes for "Organization of generated code " Java code generation creates both GUI and command line mapping applications: java com.mapforce.mappingconsole java com.mapforce.mappingapplication The mapping applications are hard coded to map the specific data sources you add to your mapping project; however, customizing them to take command line arguments is straightforward. Look in MappingConsole for the arguments passed to MappingMain1. It may be useful to think of the default mapping applications as a unit test for your mapping project. And the more you customize your SPL templates the more you will need to check your unit test.
Questions Any questions about the mapforce concepts you just learned?
Resources Altova's mapforce discussion board: http://www.altova.com/forum/forums/forum.asp?forumid=38 XML Schema: Part 0: Primer: http://www.w3.org/tr/xmlschema-0/ Part 1: Structures: http://www.w3.org/tr/xmlschema-1/ Part 2: Datatypes: http://www.w3.org/tr/xmlschema-2/ XSLT: XPath 1.0: http://www.w3.org/tr/xpath XSLT 1.0: http://www.w3.org/tr/xslt One well known perspective on O/R mapping: http://www.agiledata.org/essays/mappingobjects.html A brief introduction to EDIFACT: http://www.nls.fi/ptk/standardisation/2.html