可以将两个xml连接在一起

时间:2009-08-08 16:52:31

标签: xml

我有一些问题,因为我在XSLT中并不擅长......

例如,我有来自三家公司的3种xml

XML 1(公司1)file1.xml

<HotelList name="Company1">
   <Hotel><HotelCode>C1004</HotelCode>

                 <HotelName>Hotel 4</HotelName>

                <Price>100</Price>

   </Hotel>
    <Hotel><HotelCode>C1001</HotelCode>

                <HotelName>Hotel 1</HotelName>

                <Price>20</Price>

   </Hotel>
   <Hotel><HotelCode>C1003</HotelCode>

                <HotelName>Hotel 3</HotelName>

                <Price>15</Price>

   </Hotel>
   <Hotel><HotelCode>C1002</HotelCode></HotelList>

               <HotelName>Hotel 2</HotelName>

                <Price>10</Price>

   </Hotel>

XML 2(公司2)file2.xml

<HotelList name="Company2">
    <Hotel><HotelCode>C2002</HotelCode>

               <HotelName>Hotel Two</HotelName>

                <PriceList><Price>15</Price></PriceList>

   </Hotel>
   <Hotel><HotelCode>C2005</HotelCode>

                 <HotelName>Hotel Five</HotelName>

                 <PriceList><Price>100</Price></PriceList>

   </Hotel>
   <Hotel><HotelCode>C2003</HotelCode>

                <HotelName>Hotel Three</HotelName>

                <PriceList><Price>7</Price></PriceList>

   </Hotel>
   <Hotel><HotelCode>C2004</HotelCode>

                 <HotelName>Hotel Four</HotelName>

                <PriceList><Price>99</Price></PriceList>

   </Hotel>


   <Hotel><HotelCode>C2001</HotelCode>
</HotelList>

                <HotelName>Hotel One</HotelName>

                <PriceList><Price>10</Price></PriceList>



 </Hotel> 

XML 3(公司3)file3.xml

<HotelList name="Company2">
    <Hotel><HotelCode>13 </HotelCode>

                <HotelName>Hotel One</HotelName>

                <Rates><PriceList><Price>11</Price></PriceList></Rates>

   </Hotel>
   <Hotel><HotelCode>23</HotelCode>

               <HotelName>Hotel Two</HotelName>

               <Rates><PriceList><Price>8</Price></PriceList></Rates>

   </Hotel>
     <Hotel><HotelCode>53</HotelCode>

                 <HotelName>Hotel Five</HotelName>

                <Rates><PriceList><Price>100</Price></PriceList></Rates>

   </Hotel>

  <Hotel><HotelCode>63</HotelCode>

                 <HotelName>Hotel Six</HotelName>

                <Rates><PriceList><Price>120</Price></PriceList></Rates>

   </Hotel>
  <Hotel><HotelCode>33</HotelCode>

                <HotelName>Hotel Three</HotelName>

               <Rates><PriceList><Price>7</Price></PriceList></Rates>

   </Hotel>
   <Hotel><HotelCode>43</HotelCode>

                 <HotelName>Hotel Four</HotelName>

               <Rates><PriceList><Price>85</Price></PriceList></Rates>

   </Hotel>


</HotelList>

1)这里的xml,酒店的ID不是按顺序排列的

2)酒店身份和酒店名称不是常数

3)如果酒店ID不是常数,是否需要创建一个sql表来保持常量id?像这样的事情

HotelName             HotelCode          NewHotelName          NewHotelCode

Hotel 1                    C1001               Hotel-1                           1

Hotel 2                    C1002               Hotel-2                           2

Hotel 3                    C1003               Hotel-3                           3

Hotel 4                    C1004               Hotel-4                           4

Hotel One                C2001               Hotel-1                           1

Hotel Two                C2002               Hotel-2                           2

Hotel Three              C2003               Hotel-3                           3

Hotel Four                C2004               Hotel-4                           4

Hotel Five                 C2005               Hotel-5                           5

Hotel One                 13                    Hotel-1                           1

Hotel Two                 23                    Hotel-2                           2

Hotel Three               33                    Hotel-3                           3

Hotel Four                 43                    Hotel-4                           4

Hotel Five                  53                    Hotel-5                           5

Hotel Six                    63                    Hotel-6                          6

3)我的目标是,从这三个xml中显示价格较低的酒店(没有重复)

4)我需要的结果是

Hotel Name: Hotel-1

Hotel Code: C2001

Hotel New Code: 1

Price :10



Hotel Name: Hotel-2

Hotel Code: 23

Hotel New Code: 2

Price :8



Hotel Name: Hotel-3

Hotel Code: C1003

Hotel New Code: 3

Price :7



Hotel Name: Hotel-4

Hotel Code: 43

Hotel New Code: 4

Price :85



Hotel Name: Hotel-5

Hotel Code: C2005

Hotel New Code: 5

Price :100



Hotel Name: Hotel-6

Hotel Code: 63

Hotel New Code: 6

Price :120

1 个答案:

答案 0 :(得分:0)

是的,请参阅this reference以获取示例。