Processing the Groupon API with Altova MapForce


We often think of a data integration project as a translation from one singular data input file to some other data set, but Altova MapForce lets you greatly expand the concept of an input file. For instance, the MergeMultipleFiles.mfd example installed with MapForce illustrates how you can use a filename with wildcard characters to merge multiple input files into a single output. MapForce MergeMultipleFiles.mfd example A MapForce mapping input doesn’t even need to be a physical file – it can be a URL that returns predictable structured data, like the APIs for popular Web sites like Groupon and many others.

In this blog post we’ll describe how to use Altova tools to retrieve, filter, analyze, and present data available from a Web-based API, using Groupon as an example. If you want to follow along yourself, you will first need to visit http://www.groupon.com/pages/api to request your personal Groupon API client key. The Problem: All Deals Are Local The Groupon Web site and email subscriptions are great for finding deals in your local neighborhood, but what if you’re looking for a deal to use on an upcoming vacation, or for a gift for friends or family across the country? Sure, you could enter each location manually at the Groupon Web page, but that’s so last century. Let’s use the Altova MissionKit to automate things. The Groupon API offers two URL queries that return data in .json or .xml formats: the first returns a list of all Groupon localities (called divisions), and the second returns current deals information for one named division. If we want to see all the deals for more than one division, we need to resolve multiple URLs and aggregate the data into a single result. Yes, MapForce can do that! First We Need a Schema The Groupon API documentation describes the elements that will be returned by our requests, but doesn’t provide an XML Schema. That’s okay, we can use MapForce to generate one. All we have to do is open a new mapping design and choose Insert XML Schema/File, then click the Switch to URL button. Now we can enter the URL to retrieve the Groupon divisions list: Inserting a new component into a MapForce mapping by URL When we click the Open button MapForce offers to generate the schema: MapForce offers to generate an XML Schema When we click Yes, the File / Save dialog opens. I saved the schema as divisions.xsd, and the mapping with the new XML Schema inserted looks like this: Generated .xsd as a new component in a MapForce design And the Properties dialog for the XML Schema component automatically contains the API /divisions URL as the Input XML File: Component properties for the generated .xsd Check the Work We want to filter the Groupon divisions data to build a list of id names to use for deal queries for each locality. But before we go any further, now might be a good time to apply the text file trick from the Quick Solution for Complicated Functions blog post to look at the id values. When we insert the text file and connect the divisions and id schema elements, the mapping looks like this: MapForce design with text file to preview output We connected the division element to Rows in the text file in order to generate a new row in the text file for each unique division, so that Field1 in each row will hold the id. Clicking the Output button now generates this result: MapForce Output window All we need to do is apply the concat string function to build the list of /deal URLs for all division IDs. The next step in the mapping looks like this: Using the MapForce concat function to build a string Rolling the cursor over the constant connected to value1 of the concat function displays its full definition: Definition of a MapForce string constant When we click the Output button to execute the mapping, the Output file now looks like this: MapForce Ouput window As a further review, we can open the generated XML Schema in XMLSpy and display it in graphical Schema View: Altova XMLSpy graphical schema view of the generated .xsd So far we have:

  • built a MapForce mapping that queries the Groupon API for all divisions
  • extracted the division id fields
  • and built a list of URLs for API queries to get the deals in each division

In the next post in this series we will process the list of deal queries as the input for a new mapping component and filter the output for some interesting information. Find out for yourself how easy it is to apply MapForce to convert data from a Web API! Download a free 30-day trial of MapForce.
Editor’s Note: Our original series on mapping data from the Groupon API ran in three parts you can see by clicking the links here: Part 1 of Processing the Groupon API with Altova MapForce describes how to create dynamic input by collecting data from multiple URLs. Processing the Groupon API with MapForce – Part 2 describes how we filtered data from the API and defined the output to extract only the most interesting details. Processing the Groupon API – Part 3 describes formatting the output as a single HTML document optimized for desktop and mobile devices, and reviews ways to automate repeat execution.

Tags: , , , , , ,

Switch Statement vs. Look-up Table in MapForce


One of the great things about working with software developers is you not only get to create new things that never existed before, you also get to see how other peoples’ minds work when they discover alternate solutions to any design challenge. We received a comment from a software developer on our recent post titled Expandable If-Else Works like a Switch Statement in MapForce regarding one of the examples we used. The reader suggests that our second example illustrated a problem that would be more elegantly solved in Altova MapForce with Value-Map than by our Expanded If-Else statement. Here was the original example that received the month as a string of characters and needed to generate the corresponding number: Original Expanded If_Else example in MapForce A Value-Map in MapForce is an alternate solution that functions as a look-up table, whereas an Expanded If-Else acts like a switch statement. Here is how our mapping would look with a Value-Map in place of the Expanded If-Else: Value-Map alternative in MapForce Yep, that’s it. Rather than copying, pasting, and modifying sets of elements the way we built our original Expanded If-Else, a Value-Map lets us easily create the entire look-up table in its Properties dialog: Value-Map Properties dialog in MapForce We accept the commenter’s point — Value-Map definitely works better for the problem we chose because it’s much quicker and easier to create! The table from the Value-Map properties is also more concise and easier to interpret in MapForce-generated mapping documentation than our original Expanded If-Else structure. Of course you can’t always replace an Expanded If-Else statement with a Value-Map. Data entering the Value-Map must equal a single value in the input table to generate a specific output, whereas Expanded If-Else lets you set up a series of conditions with different logical tests. Sometimes the exact nature of a data conversion project makes it a judgment call to use a switch element vs. a look-up table. Let’s say your project receives input as a number that represents a wavelength of the electromagnetic spectrum and you want to handle ultraviolet, visible colors, and infrared energy individually. In that case we could use an Expanded If-Else to test for ranges of input values. The Expanded If-Else section of the mapping might look like this: Expanded If-Else mapping in Altova MapForce If the input is an integer, you could also create a solution using Value-Map, but you would need to build a very long look-up table. And then what happens later if the project requirements change and the input becomes a decimal number, or you need to filter each visible color separately by name? Essentially Altova MapForce is a really cool graphical representation of a complete software language toolbox that insulates you from detailed programming language syntax, with a rich collection of components you can assemble creatively to solve your own data mapping, conversion, and integration challenges. Find out for yourself how easy it is to apply MapForce to your own data mapping projects. Download a free 30-day trial of MapForce.

Tags: , , , , , ,

Expandable If-Else Works like a Switch Statement in MapForce


In response to several user requests, the if-else component in MapForce has been enhanced in MapForce 2011 Release 2 to accommodate any number of variables. This feature, which is equivalent to a switch statement in many programming languages, enables you to easily control the flow of data in a mapping project by matching a value to a selected criterion. For example, the screenshot below shows the if-then component used in combination with other components to analyze temperature data and produce the following results:

  • If temp is greater than 20, true is passed on to bool1 and "high" is passed on to value-true1.
  • If temp is less than 5, true is passed on to bool2 and "low" is passed on to value-true2.
  • Only one of the value-true parameters can be true for any given temperature, and that is the one that is passed on to the desc attribute in the target component.

Expandable if-else example included with MapForce The screenshot above is taken from the sample file Classify Temperatures.mfd included during the MapForce installation, so you can immediately process the sample data or modify the mapping to see the output for yourself. The new expandable if-else functionality helps developers build data mappings more rapidly, creates a mapping diagram that displays the conditional test more effectively, and facilitates testing and debugging because the expanded if-else function is much easier to read than a cascading structure of individual components. This is even more obvious when you have to evaluate a large number of conditions. The screenshot below shows a conversion from string to number where the string consists of a three-letter abbreviation of the month. (To save space here, this if-else function only processes strings for the first six months of the year.) Expandable if-else statement in MapForce In a copy-paste oversight we forgot to update the output constant for May from the value 4 to 5. That’s a much easier error to find and fix when you can see all the logic in one view!(UPDATE: We originally created this example to illustrate the advantages of Expanded If-Else over nested or cascading If-Else mappings that can quickly grow too large to view on a single screen. For a better design for solving this and other similar conversions using a look-up table, see the Switch Statement vs. Look-up Table in MapForce blog post.) Find out for yourself how easy it is to use expanded if-else functions in your own data mapping projects. Download a free 30-day trial of MapForce.

Tags: , ,

MapForce Japanese Version – 日本語版 MapForce


ホームページXMLSpy 製品ページ含む Altova ウェブページの多くが日本語化されました!この作業は今後も継続して行われ、新たに翻訳されたページもできる限り素早く追加していく予定です。 We are excited to announce that a large portion of the Altova Web site – including the home page and XMLSpy product pages – is now available in Japanese! This is an ongoing effort, and new translated pages are being added as quickly as possible.

日本語版 MapForce 2010

他にも、次の日本語化された Altova バージョン 2010 製品となる MapForce 2010 のリリースを行いました。MapForce データマッピングツールは XMLSpy と共に完全に翻訳され、英語版、ドイツ語版と共にお求め頂けます(単一のライセンスキーコードにより使用する言語に関係なく製品のアンロックを行うことができます)。 日本語ユーザも、XML、データベース、EDI、フラットファイル、Excel 2007+、XBRL、そしてウェブサービスと言ったデータのマッピングと変換をグラフィカルに行う MapForce インターフェースを利用できるようになりました。無料トライアル版をダウンロードする際に、言語ドロップダウンから日本語を選択してください。 続けてその他の製品についても、地域化を続けて行く予定です。ご期待下さい!   We’ve also released the next Altova Version 2010 product to be localized in Japanese: MapForce 2010. The MapForce data mapping tool joins XMLSpy in being fully translated and available for download in Japanese as well as English and German. (A single license key code unlocks whichever language version you install.) Now Japanese-speaking users can take advantage of the graphical MapForce interface for mapping and transforming data in any format, including XML, databases, EDI, flat files, Excel 2007+, XBRL, and Web services. Simply select Japanese from the language drop down when downloading a free trial. We will continue localizing the rest of the product line throughout the year – stay tuned for more news!   altova_jp

Tags: , ,

Altova MapForce Brings Powerful Data Transformation Capabilities to Quark Dynamic Publishing Solution


This week Altova announced the integration of Altova MapForce, its conversion and data mapping tool, with Quark® Dynamic Publishing Solution. Through Automation Services™, a component of Quark’s dynamic publishing software, MapForce transformations translate XML into Web publishing formats, transform QuarkXPress® layouts for digital publishing, and convert XML to print pages, providing multi-channel publishers with a complete, automated XML-based publishing solution. This solution highlights two powerful features of MapForce that have demonstrated benefits to users with a wide range of data conversion needs: The MapForce visual data mapping interface supports integrating data as the source or destination in virtually any format, including XML, databases, flat files, EDI, Excel 2007+, XBRL, and Web services. MapForce includes the ability to automate data integration and repeatable business processes through an automation interface that lets developers access its advanced features programmatically. Users can also automate MapForce through the command line interface, or by using MapForce generated royalty-free code in XSLT 1.0/2.0, XQuery, Java, C++ or C#. mapforce_data_mapping_thumb “Having the ability to transform and publish data to multiple channels using an automated process helps users improve productivity and cut costs,” said Alexander Falk, President and CEO for Altova. The Altova Web site features a series of MapForce flash videos that each demonstrate a significant feature in 4 minutes or less. The Altova Online Training page offers three free MapForce self-paced training modules for Beginning, Intermediate, and Advanced data integration needs. Find out for yourself how convenient and cost-effective can be to solve your data conversion requirements. Click here to download a fully functional, free 30-day trial of Altova MapForce 2010!

Tags: , , , ,

New MapForce Online Training


If you’re not already familiar with MapForce, Altova’s award-winning graphical data integration tool, now’s the perfect time! Altova has just released a new MapForce course as part of its line of free online training modules. The new course has been completely updated with comprehensive data mapping training for beginning, intermediate, and advanced users and includes step-by-step tutorials, evaluation exercises, and a chance to work with mapping files and functions that meet a broad range of needs. data_integration_thumb So roll up your sleeves, download a free 30-day trial of MapForce, go to our training page, and get your hands dirty with some powerful visual data transformation from Altova!

Tags: , ,

HL7 and XML Healthcare Data Integration at HIMSS10


Altova is kicking off the 2010 trade show season with our first participation in the annual conference of the Healthcare Information Management Systems Society (HIMSS). The HIMSS10 conference will be held on March 1-4 at the Georgia World Congress Center in Atlanta. We’re looking forward to demonstrating the functionality in XMLSpy 2010 for editing, analyzing, and validating HL7 healthcare data. We will also show how MapForce 2010 can map older EDI-based legacy healthcare records to the latest XML-based HL7 v3.x standard. The example below shows a simple MapForce mapping to update an HL7 v2.6 message to v3.x. MapForce mapping for HL7 This will be our first opportunity to demonstrate the new Altova MissionKit 2010 Release 2 with significant speed and performance enhancements across the product line. Come see the new 64-bit versions for yourself, or download a free trial today. If you are one of the expected 30,000+ attendees traveling to Atlanta for HIMSS10, stop by and see us at booth 5744. Or click here to get more information on the Altova MissionKit and HL7.

Tags: , , , , , ,