Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Automation of re-formating from XML to XML???

Posted on 2011-09-07
5
270 Views
Last Modified: 2012-05-12
I have a new server which process data entry through XML files that it recieves attached with an email.  The problem is that some of my clients system shoot me and xml with different tag names and different format.  Anyone know of a software that i can setup a XML template and filter clients xml with this software so i can spit out their information in the format that my system needs... all automated would be great since we are looking at processing about 6500 xmls in the span of a year.

Ex.
FROM CLIENT
<cliente>
<noparte>partnumber</noparte>
<provedor>Provider</provedor>
</cliente>

NEEDS TO BE FORMATED AUTOMATICALLY TO
<client>
<partNumber>partnumber</partNumber>
<provider>Provider</Provider>
<otherFields>Defaulted value of template</otherFields>
</client>

Hopefully i make sense... Clients xml is in spanish and i need to designate them to the english version and then some fields arent present in the clients xml which i would like to add the through with some type of template.
0
Comment
Question by:Osram34
  • 3
5 Comments
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 250 total points
ID: 36501052
The easiest way to deal with such a templated approach is using XSLT.

I have attached an XSLT that does exactly this for you
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">
    <xsl:output indent="yes"/>
    <xsl:strip-space elements="*"/>
    <xsl:template match="node()">
        <xsl:copy>
            <xsl:copy-of select="@*"/>
            <xsl:apply-templates select="node()"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="cliente">
        <xsl:element name="client">
            <xsl:copy-of select="@*"/>
            <xsl:apply-templates select="node()"/>
            <xsl:element name="otherFields">
                <xsl:text>Defaulted value of template</xsl:text>
            </xsl:element>
        </xsl:element>
    </xsl:template>
    <xsl:template match="noparte">
        <xsl:element name="partNumber">
            <xsl:copy-of select="@*"/>
            <xsl:apply-templates select="node()"/>
        </xsl:element>
    </xsl:template>
    <xsl:template match="provedor">
        <xsl:element name="provider">
            <xsl:copy-of select="@*"/>
            <xsl:apply-templates select="node()"/>
        </xsl:element>
    </xsl:template>
</xsl:stylesheet>

Open in new window

0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 36501105
Your next task is to write a progam that scans the POP3 server (or whatever)
extract the XML from the mail message
and transforms using the XSLT

That should not be hard to do.
All depends on the programming infrastructure you want to use
If you want to do this in batch mode, you could use python or ruby I guess
0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 250 total points
ID: 36502007
Mapforce allow you to easily create a program doing the conversion after doing the mapping
the interface is pretty cool to use and you should be able to generate your first code in 1 hour.
there's a demo on the site, check it.

additionaly check this tools allowing you to really automate the processes:
http://www.opensyncro.org/
https://www.openadaptor.org/
0
 

Author Closing Comment

by:Osram34
ID: 36519421
Two good answers just havent had time to even start on that project but u all helped a ton thanks
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 36519534
welcome
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question