Web Development

Altova MapForce lets you map data to and from XML

MapForce lets developers who aren't heavyweights in XPath, XSLT, and XQuery be productive when mapping data to and from XML.

 

Altova MapForce is a data mapping tool that is used to rearrange one form of data into a different form; it's along the lines of Star Trek's Project Genesis without the negative connotations. Data can be mapped to or from any of the following: XML using DTD or schema, flat files, EDI (Electronic Data Interchange) documents, Excel 2007 or higher, and XBRL (eXtensible Business Reporting Language).

On the surface, this might sound somewhat like Microsoft's BizTalk, but there is a major difference: Unlike BizTalk, MapForce does not have a server component; this eliminates the need for configuration in order to get you maps to execute. Instead, MapForce allows developers to generate the mapping code in any of these languages: XSLT version 1.0, XSLT version 2.0, XQuery, Java, C#, and C++. A language in this list should fit in almost any development shop on the planet. If your preferred language isn't on the list, odds are, there is an XSLT parser that would fit right in. However, as Figure A shows, being a C++ guru isn't necessary. Figure A

A sample Mapping. (Click the image to enlarge.)
In addition, MapForce has a number of built-in functions grouped into libraries that are used to modify data when a straight move just won't do. These libraries, their groupings, and their functions are outlined in Table B. Table B

Library

Type

Function

core  
aggregate functions  
count
sum
conversion functions  
boolean
number
string
logical functions  
equal
equal-or-greater
equal-or-less
greater
less
logical-and
logical-not
logical-or
not-equal
math functions  
add
ceiling
divide
floor
modulus
multiply
round
subtract
node functions  
exists
not-exists
position
substitute-missing
string functions  
concat
contains
normalize-space
starts-with
string-length
substring
substring-after
substring-before
translates
xslt  
xpath functions  
lang
last
local-name
name
namespace-uri
position
xslt functions  
current
document
element-available
format-number
function-available
generate-id
system-property
unparsed-entity-uri

MapForce libraries.

Extending MapForce

You can also create your own custom functions either through creatively combining the above functions (as shown in Figure C) or through code (like that shown in Listing D). There is one minor fly in the ointment: carelessly creating and using your own custom libraries using any but the core functions can restrict the languages to the language used to develop the custom library. While this limitation might not be an issue, I would be remiss not to point it out. Figure C

A date-time to date conversion function using core functions. (Click the image to enlarge.)
Listing D

A date-time to date conversion function using hand-coded XSLT

<xsl:template name="datePart">

<xsl:param name="date"/>

<xsl:choose>

<xsl:when test="contains($date,'T')">

<xsl:value-of select="substring-before($date,'T')"/>

</xsl:when>

<xsl:otherwise>

<xsl:value-of select="$date"/>

</xsl:otherwise>

</xsl:choose>

</xsl:template>

It is this extensibility that makes MapForce a superior data mapping package. The best single feature is that it cuts down on how much of, what a former manager of mine called "the dark arts," that a developer needs to know. In short, it lets developers who aren't heavyweights in XPath, XSLT, and XQuery be productive when mapping data to and from XML.

Check out the Altova site for pricing details about MapForce Enterprise Edition, MapForce Professional Edition, and MapForce Standard Edition. You can also download a 30-day free trial of MapForce 2010.

Get weekly development tips in your inbox Keep your developer skills sharp by signing up for TechRepublic's free Web Developer newsletter, delivered each Tuesday. Automatically subscribe today!
0 comments

Editor's Picks