未加星标

MapForce Offers Dynamic Access to Node Names

字体大小 | |
[前端(javascript) 所属分类 前端(javascript) | 发布者 店小二04 | 时间 2016 | 作者 红领巾 ] 0人收藏点击收藏

There are situations, especially when encountering loosely structured data, where you may want to map and transform structural components of a data stream along with content. MapForce 2017 includes a new feature to dynamically access node names of XML elements, attributes, or text file columns such as the contents of CSV files, to target components.

Dynamic access to node names allows creation on the fly of target elements and attributes whose names do not need to be known beforehand or specifically identified in thedata mapping. This feature lets you create much more generic, flexible, and reusable mappings that require less manual intervention if data models evolve.


MapForce Offers Dynamic Access to Node Names

Here is an example of a very common style of CSV file where data fields are not identified by column names, but by labels in a neighboring cell within the row:


MapForce Offers Dynamic Access to Node Names

The records in this example are not even structured consistently, since one record includes a suffix after the last name and another record includes a middle initial.

A likely data mapping requirement for files like this is to map the cells in column A as XML element names and the cells in column B as values for each corresponding element. This is now easily accomplished with dynamic mapping of node names. Let’s look at how it’s done.

Dynamic Access toNode Names of XMLElements

We’ll start by creating a very simple XML Schema for the mapping target that uses the <xs:any> element to define a complex <Employee> element that can have any child elements. Here it is in XMLSpy Schema view:


MapForce Offers Dynamic Access to Node Names

We start the mapping by dropping in the CSV file and using a group function that will create a new <Employee> element each time FirstName appears in Column A of the input.


MapForce Offers Dynamic Access to Node Names

Next we drop in the target XML Schema, and right-click the <Employee> element:


MapForce Offers Dynamic Access to Node Names

This opens the context menu, showing new options added in MapForce v2017. We will choose the option Show Child Elements with Dynamic Name, which opens a dialog where we will select text as the data type for child elements. This exposes the node name and content for child elements of <Employee> as shown here:


MapForce Offers Dynamic Access to Node Names

Now it’s a simple process to map from Field1 (column A of the CSV file) to the child element node names and from Field2 (column B) to the element content. Here is the final data mapping:


MapForce Offers Dynamic Access to Node Names

The function group-starting-with at the top creates a new <Employee> element every time “FirstName” is encountered in the input file. Then, for each row, entries in column A generate child element names and entries in column B become values for each child element.

Output for the mapping above looks like this:


MapForce Offers Dynamic Access to Node Names

The advantage of a data mapping that uses dynamic access to the names of nodes is you do not have to do a comprehensive survey of the input data to identify and map every possible element name.

Consider a common production scenario where you accept multiple input files from one or more external sources and automate mapping execution with MapForce Server and FlowForce Server. If an input file arrives that suddenly contains an unexpected child element OfficeLocation or MailStop, for instance the data will not be lost.

Dynamic Access to Node Namesof XML Attributes

You can also dynamically map the names of XML attributes, with the same ability to create target elements and attributes on the fly without necessarily identifying them all ahead of time.

MapForce 2017 with dynamic node name mapping, enhanced XBRL and database support, and many other new features, is available for download here as a 30-day trial. V2017 is also a free upgrade for existing users with valid SMP.

本文前端(javascript)相关术语:javascript是什么意思 javascript下载 javascript权威指南 javascript基础教程 javascript 正则表达式 javascript设计模式 javascript高级程序设计 精通javascript javascript教程

主题: XMLOffice
分页:12
转载请注明
本文标题:MapForce Offers Dynamic Access to Node Names
本站链接:http://www.codesec.net/view/482490.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 前端(javascript) | 评论(0) | 阅读(35)