使用XSLT修改导入到Access的XML数据

时间:2016-05-21 12:54:54

标签: xml ms-access xslt import

好的,我不熟悉XML或XSLT,我需要将XML文档正确导入Access。理想情况下,我希望主要元素的名称(节点?)我不熟悉术语,以成为DATE元素的值。

我还希望在访问的一个表中显示所有内容。目前存在一些问题,例如因为Board_NUMBER只出现在每3个(使用此XSLT导入和修改的其他XML文件可能更多)TRAVELLER_LINES它只显示9个板结果而不是所有玩过的游戏。 (这是桥接结果的数据库)我也可能想删除EVENTS中的所有其他元素。

因此,将要修改的XML是(桥接结果以USEBIO格式输入):

<?xml version="1.0"?>
<!DOCTYPE USEBIO SYSTEM "http://www.ebu.co.uk/usebio/usebio_v1_0.dtd">
<USEBIO Version="1.1">
<CLUB>
<CLUB_NAME>*****@hotmail.com</CLUB_NAME>
<CLUB_ID_NUMBER>9999</CLUB_ID_NUMBER>
</CLUB>
<EVENT EVENT_TYPE="MP_PAIRS">
<EVENT_IDENTIFIER>13</EVENT_IDENTIFIER>
<EVENT_DESCRIPTION>Thursday - Section A</EVENT_DESCRIPTION>
<PROGRAM_NAME>Compscore2</PROGRAM_NAME>
<TITLE>Thursday</TITLE>
<DATE>19/05/2016</DATE>
<VENUE></VENUE> 
<P2P_CHARGE_RATE>10</P2P_CHARGE_RATE>
<MPS_AWARDED_FLAG>Y</MPS_AWARDED_FLAG>
<PARTICIPANTS EVENT_TYPE="MP_PAIRS">
 <PAIR>
  <PAIR_NUMBER>1NS</PAIR_NUMBER>
  <DIRECTION>NS</DIRECTION>
  <TOTAL_SCORE>18.00</TOTAL_SCORE>
  <PERCENTAGE>50.00</PERCENTAGE>
  <PLACE>2</PLACE>
  <MASTER_POINTS_AWARDED>6</MASTER_POINTS_AWARDED>
  <PLAYER>
   <PLAYER_NAME>TEST</PLAYER_NAME>
   <NATIONAL_ID_NUMBER></NATIONAL_ID_NUMBER>
   <CLUB_ID_NUMBER>1</CLUB_ID_NUMBER>
  </PLAYER>
  <PLAYER>
   <PLAYER_NAME>TEST2</PLAYER_NAME>
   <NATIONAL_ID_NUMBER></NATIONAL_ID_NUMBER>
   <CLUB_ID_NUMBER>2</CLUB_ID_NUMBER>
  </PLAYER>
 </PAIR>
 <PAIR>
  <PAIR_NUMBER>1EW</PAIR_NUMBER>
  <DIRECTION>EW</DIRECTION>
  <TOTAL_SCORE>21.00</TOTAL_SCORE>
  <PERCENTAGE>58.33</PERCENTAGE>
  <PLACE>1</PLACE>
  <MASTER_POINTS_AWARDED>9</MASTER_POINTS_AWARDED>
  <PLAYER>
   <PLAYER_NAME>TEST 3</PLAYER_NAME>
   <NATIONAL_ID_NUMBER></NATIONAL_ID_NUMBER>
   <CLUB_ID_NUMBER>3</CLUB_ID_NUMBER>
 </PLAYER>
 ...
</PARTICIPANTS>
<BOARD EVENT_TYPE="MP_PAIRS">
  <BOARD_NUMBER>1</BOARD_NUMBER>
  <TRAVELLER_LINE>
  <NS_PAIR_NUMBER>1NS</NS_PAIR_NUMBER>
  <EW_PAIR_NUMBER>1EW</EW_PAIR_NUMBER>
  <CONTRACT>2NT</CONTRACT>
  <PLAYED_BY>N</PLAYED_BY>
  <LEAD>5H</LEAD>
  <TRICKS>9</TRICKS>
  <SCORE>150</SCORE>
  <NS_MATCH_POINTS>0</NS_MATCH_POINTS>
  <EW_MATCH_POINTS>4</EW_MATCH_POINTS>
 </TRAVELLER_LINE>
 <TRAVELLER_LINE>
  <NS_PAIR_NUMBER>2NS</NS_PAIR_NUMBER>
  <EW_PAIR_NUMBER>2EW</EW_PAIR_NUMBER>
  <CONTRACT>3NT</CONTRACT>
  <PLAYED_BY>N</PLAYED_BY>
  <LEAD>4H</LEAD>
  <TRICKS>10</TRICKS>
  <SCORE>430</SCORE>
  <NS_MATCH_POINTS>4</NS_MATCH_POINTS>
  <EW_MATCH_POINTS>0</EW_MATCH_POINTS>
 </TRAVELLER_LINE>
 <TRAVELLER_LINE>
  <NS_PAIR_NUMBER>3NS</NS_PAIR_NUMBER>
  <EW_PAIR_NUMBER>3EW</EW_PAIR_NUMBER>
  <CONTRACT>3NT</CONTRACT>
  <PLAYED_BY>N</PLAYED_BY>
  <LEAD>4H</LEAD>
  <TRICKS>9</TRICKS>
  <SCORE>400</SCORE>
  <NS_MATCH_POINTS>2</NS_MATCH_POINTS>
  <EW_MATCH_POINTS>2</EW_MATCH_POINTS>
 </TRAVELLER_LINE>
</BOARD>
 <BOARD EVENT_TYPE="MP_PAIRS">
  <BOARD_NUMBER>2</BOARD_NUMBER>
  <TRAVELLER_LINE>
   <NS_PAIR_NUMBER>1NS</NS_PAIR_NUMBER>
   <EW_PAIR_NUMBER>1EW</EW_PAIR_NUMBER>
   <CONTRACT>1NT</CONTRACT>
   <PLAYED_BY>N</PLAYED_BY>
   <LEAD>3S</LEAD>
   <TRICKS>7</TRICKS>
   <SCORE>90</SCORE>
   <NS_MATCH_POINTS>3</NS_MATCH_POINTS>
   <EW_MATCH_POINTS>1</EW_MATCH_POINTS>
  </TRAVELLER_LINE>
...
</EVENT>
</USEBIO>

我根本不确定结果应该是什么样子,因为我不知道它将如何导入Access,但是像

这样的字段
    <?xml version="1.0"?>
<!DOCTYPE USEBIO SYSTEM "http://www.ebu.co.uk/usebio/usebio_v1_0.dtd">
<USEBIO Version="1.1">
 <19/05/2016>
   <EVENT_DESCRIPTION>Thursday - Section A</EVENT_DESCRIPTION>
   <DATE>19/05/2016</DATE>
   <PAIR_NUMBER>1NS</PAIR_NUMBER>
   <DIRECTION>NS</DIRECTION>
   <TOTAL_SCORE>18.00</TOTAL_SCORE>
   <PERCENTAGE>50.00</PERCENTAGE>
   <PLACE>2</PLACE>
   <MASTER_POINTS_AWARDED>6</MASTER_POINTS_AWARDED>
   <PLAYER_NAME>TEST</PLAYER_NAME>
   <NATIONAL_ID_NUMBER></NATIONAL_ID_NUMBER>
   <CLUB_ID_NUMBER>1</CLUB_ID_NUMBER>
   <PAIR_NUMBER>1NS</PAIR_NUMBER>
   <PLAYER_NAME>TEST2</PLAYER_NAME>
   <NATIONAL_ID_NUMBER></NATIONAL_ID_NUMBER>
   <CLUB_ID_NUMBER>2</CLUB_ID_NUMBER>
   <PAIR_NUMBER>1EW</PAIR_NUMBER>
   <DIRECTION>EW</DIRECTION>
   <TOTAL_SCORE>21.00</TOTAL_SCORE>
   <PERCENTAGE>58.33</PERCENTAGE>
   <PLACE>1</PLACE>
   <MASTER_POINTS_AWARDED>9</MASTER_POINTS_AWARDED>
   <PLAYER_NAME>TEST 3</PLAYER_NAME>
   <NATIONAL_ID_NUMBER></NATIONAL_ID_NUMBER>
   <CLUB_ID_NUMBER>3</CLUB_ID_NUMBER>
 ...
   <BOARD_NUMBER>1</BOARD_NUMBER>
   <NS_PAIR_NUMBER>1NS</NS_PAIR_NUMBER>
   <EW_PAIR_NUMBER>1EW</EW_PAIR_NUMBER>
   <CONTRACT>2NT</CONTRACT>
   <PLAYED_BY>N</PLAYED_BY>
   <LEAD>5H</LEAD>
   <TRICKS>9</TRICKS>
   <SCORE>150</SCORE>
   <NS_MATCH_POINTS>0</NS_MATCH_POINTS>
   <EW_MATCH_POINTS>4</EW_MATCH_POINTS>
   <BOARD_NUMBER>1</BOARD_NUMBER>
   <NS_PAIR_NUMBER>2NS</NS_PAIR_NUMBER>
   <EW_PAIR_NUMBER>2EW</EW_PAIR_NUMBER>
   <CONTRACT>3NT</CONTRACT>
   <PLAYED_BY>N</PLAYED_BY>
   <LEAD>4H</LEAD>
   <TRICKS>10</TRICKS>
   <SCORE>430</SCORE>
   <NS_MATCH_POINTS>4</NS_MATCH_POINTS>
   <EW_MATCH_POINTS>0</EW_MATCH_POINTS>
   <BOARD_NUMBER>1</BOARD_NUMBER>
   <NS_PAIR_NUMBER>3NS</NS_PAIR_NUMBER>
   <EW_PAIR_NUMBER>3EW</EW_PAIR_NUMBER>
   <CONTRACT>3NT</CONTRACT>
   <PLAYED_BY>N</PLAYED_BY>
   <LEAD>4H</LEAD>
   <TRICKS>9</TRICKS>
   <SCORE>400</SCORE>
   <NS_MATCH_POINTS>2</NS_MATCH_POINTS>
   <EW_MATCH_POINTS>2</EW_MATCH_POINTS>
   <BOARD_NUMBER>2</BOARD_NUMBER>
   <NS_PAIR_NUMBER>1NS</NS_PAIR_NUMBER>
   <EW_PAIR_NUMBER>1EW</EW_PAIR_NUMBER>
   <CONTRACT>1NT</CONTRACT>
   <PLAYED_BY>N</PLAYED_BY>
   <LEAD>3S</LEAD>
   <TRICKS>7</TRICKS>
   <SCORE>90</SCORE>
   <NS_MATCH_POINTS>3</NS_MATCH_POINTS>
   <EW_MATCH_POINTS>1</EW_MATCH_POINTS>
    ...
 </19/05/2016>
</USEBIO>

1 个答案:

答案 0 :(得分:1)

实际上,如果您不熟悉XML,我可以高度建议您the XML tutorial from W3Schools。您的元素名称不能是<19/05/2016>之类的日期,因为格式无效。请参阅链接页面:

  

XML元素必须遵循以下命名规则:

     
      
  • 元素名称区分大小写

  •   
  • 元素名称必须以字母或下划线开头

  •   
  • 元素名称不能以字母xml(或XML或Xml等)开头

  •   
  • 元素名称可以包含字母,数字,连字符,下划线和句点

  •   
  • 元素名称不能包含空格

  •   
     

可以使用任何名称,不保留任何单词(xml除外)。

但您的元素可能有一个日期为值的属性。