xml integration from different xml schemas

2019-09-09 16:52发布

I want to add products to my system from different suppliers. They will send me their XML files and i will integrate them. The problem is XML files are schema different and tags are different but they serve the same information. I want to make a generic structure so that when a new XML comes out, i can easily add these products to my system, with few changes.

My project is Asp.net and coding language C#.

Is it possible to make this? What approach should i take ?

Here are sample XML files

<products>
<prouduct>
    <code>1</code>
    <name>Tshirt</name>
    <price>10</price>
    <stock>5</stock>
    <category>Men > Shirts</category>
    <subproducts>
        <subproduct>
            <groupid>1<groupid>
            <code>12</code>
            <property>Blue L<property>
            <stock>2</stock>
        <subproduct>
        <subproduct>
            <groupid>1<groupid>
            <code>13</code>
            <property>Red S<property>
        <subproduct>
    </subproducts>
</product>
</prouducts>

another one

<Urunler>
<Urun>
<UrunID>48826</UrunID>
<UrunAdi>PUMA 84075604 CAT LOGO ŞAPKA</UrunAdi>
<Kod>20YU18000010</Kod>
<Fiyat>28.00</Fiyat>
<Stoklar>
    <Stok>
        <Ozellik isim="Color-Size">STANDART STD</Ozellik>
        <Miktar>1</Miktar>
    </Stok>
</Stoklar>
</Urun>
</Urunler>

1条回答
Fickle 薄情
2楼-- · 2019-09-09 17:19

It's a very standard scenario. Most people use XSLT transformations to convert the variety of different schemas into one canonical format, which might be an industry standard or it might be one you design for yourself (or it might be one of the input formats). You'll also want some kind of message handling infrastructure to control the way different stylesheets are applied to different source documents. You might write this yourself e.g. in XProc, or you might use some kind of framework, e.g. Cocoon or JBoss ESB - there are lots of products in this area and I don't know them all.

查看更多
登录 后发表回答