Access 2007 doesn't import all element data fr

2019-03-03 12:10发布

问题:

I have this XML data I need to import into Access for further processing. I copied here only small part of the data:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="Access Question.xsl"?>
<Catalogue>
<App action="A" id="308">
    <BaseVehicle id="67"/>
    <!-- 1983 Porsche 911 -->
    <BodyType id="9"/>
    <!-- Coupe -->
    <EngineBase id="15"/>
    <!-- H6 3.0L -->
    <Note>OE sensor technology</Note>
    <Qty>1</Qty>
    <PartType id="5132"/>
    <!-- Oxygen Sensor -->
    <MfrLabel>Sensor</MfrLabel>
    <Position id="2172"/>
    <!-- Upstream -->
    <Part>101027</Part>
</App>
<App action="A" id="309">
    <BaseVehicle id="67"/>
    <!-- 1983 Porsche 911 -->
    <BodyType id="10"/>
    <!-- Convertible -->
    <EngineBase id="15"/>
    <!-- H6 3.0L -->
    <Note>OE sensor technology</Note>
    <Note>For vehicles without Start-Stop function</Note>
    <Qty>1</Qty>
    <PartType id="5132"/>
    <!-- Oxygen Sensor -->
    <MfrLabel>Sensor</MfrLabel>
    <Position id="2172"/>
    <!-- Upstream -->
    <Part>101027</Part>
</App>
<App action="A" id="310">
    <BaseVehicle id="68"/>
    <!-- 1984 Porsche 911 -->
    <EngineBase id="16"/>
    <!-- H6 3.2L -->
    <EngineVIN id="13"/>
    <!-- B -->
    <Note>OE sensor technology</Note>
    <Note>For vehicles without Start-Stop function</Note>
    <Qty>1</Qty>
    <PartType id="5132"/>
    <!-- Oxygen Sensor -->
    <MfrLabel>Sensor</MfrLabel>
    <Position id="2172"/>
    <!-- Upstream -->
    <Part>103918</Part>
</App>
<App action="A" id="311">
    <BaseVehicle id="68"/>
    <!-- 1984 Porsche 911 -->
    <EngineBase id="1778"/>
    <!-- H6 3.2L -->
    <Aspiration id="5"/>
    <!-- Naturally Aspirated -->
    <Qty>1</Qty>
    <PartType id="5132"/>
    <!-- Oxygen Sensor -->
    <MfrLabel>Sensor</MfrLabel>
    <Position id="2172"/>
    <!-- Upstream -->
    <Part>103918</Part>
</App>
</Catalogue>

For this data I use this XSLT:

<xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>

<xsl:template match="node()">
<xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="Catalogue/App/@*">
<xsl:element name="{name()}">
    <xsl:value-of select="."/>
</xsl:element>
</xsl:template>

<xsl:template match="Catalogue/App/Note[1]">
    <Note1><xsl:apply-templates select="@*|node()"/></Note1>
</xsl:template>

<xsl:template match="Catalogue/App/Note[2]">
    <Note2><xsl:apply-templates select="@*|node()"/></Note2>
</xsl:template>

<xsl:template match="Catalogue/App/Note[3]">
    <Note3><xsl:apply-templates select="@*|node()"/></Note3>
</xsl:template>

<xsl:template match="Catalogue/App/Note[4]">
    <Note4><xsl:apply-templates select="@*|node()"/></Note4>
</xsl:template>

<xsl:template match="Catalogue/App/Note[5]">
    <Note5><xsl:apply-templates select="@*|node()"/></Note5>
</xsl:template>

<xsl:template match="Catalogue/App/Note[6]">
    <Note6><xsl:apply-templates select="@*|node()"/></Note6>
</xsl:template>

<xsl:template match="Catalogue/App/Note[7]">
    <Note7><xsl:apply-templates select="@*|node()"/></Note7>
</xsl:template>

<xsl:template match="Catalogue/App/Note[8]">
    <Note8><xsl:apply-templates select="@*|node()"/></Note8>
</xsl:template>

<xsl:template match="Catalogue/App/Note[9]">
    <Note9><xsl:apply-templates select="@*|node()"/></Note9>
</xsl:template>

<xsl:template match="Catalogue/App/Note[10]">
    <Note10><xsl:apply-templates select="@*|node()"/></Note10>
</xsl:template>

<xsl:template match="Catalogue/App/Note[11]">
    <Note11><xsl:apply-templates select="@*|node()"/></Note11>
</xsl:template>

<xsl:template match="Catalogue/App/Note[12]">
    <Note12><xsl:apply-templates select="@*|node()"/></Note12>
</xsl:template>

<xsl:template match="Catalogue/App/Note[13]">
    <Note13><xsl:apply-templates select="@*|node()"/></Note13>
</xsl:template>

<xsl:template match="Catalogue/App/Note[14]">
    <Note14><xsl:apply-templates select="@*|node()"/></Note14>
</xsl:template>

<xsl:template match="Catalogue/App/Note[15]">
    <Note15><xsl:apply-templates select="@*|node()"/></Note15>
</xsl:template>

</xsl:stylesheet>

After tranformation it looks like this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<Catalogue>
<App>
  <action>A</action>
  <id>308</id>
  <BaseVehicle>67</BaseVehicle>
  <!-- 1983 Porsche 911 -->
  <BodyType>9</BodyType>
  <!-- Coupe -->
  <EngineBase>15</EngineBase>
  <!-- H6 3.0L -->
  <Note1>OE sensor technology</Note1>
  <Qty>1</Qty>
  <PartType>5132</PartType>
  <!-- Oxygen Sensor -->
  <MfrLabel>Sensor</MfrLabel>
  <Position>2172</Position>
  <!-- Upstream -->
  <Part>101027</Part>
</App>
<App>
  <action>A</action>
  <id>309</id>
  <BaseVehicle>67</BaseVehicle>
  <!-- 1983 Porsche 911 -->
  <BodyType>10</BodyType>
  <!-- Convertible -->
  <EngineBase>15</EngineBase>
  <!-- H6 3.0L -->
  <Note1>OE sensor technology</Note1>
  <Note2>For vehicles without Start-Stop function</Note2>
  <Qty>1</Qty>
  <PartType>5132</PartType>
  <!-- Oxygen Sensor -->
  <MfrLabel>Sensor</MfrLabel>
  <Position>2172</Position>
  <!-- Upstream -->
  <Part>101027</Part>
</App>
<App>
  <action>A</action>
  <id>310</id>
  <BaseVehicle>68</BaseVehicle>
  <!-- 1984 Porsche 911 -->
  <EngineBase>16</EngineBase>
  <!-- H6 3.2L -->
  <EngineVIN>13</EngineVIN>
  <!-- B -->
  <Note1>OE sensor technology</Note1>
  <Note2>For vehicles without Start-Stop function</Note2>
  <Qty>1</Qty>
  <PartType>5132</PartType>
  <!-- Oxygen Sensor -->
  <MfrLabel>Sensor</MfrLabel>
  <Position>2172</Position>
  <!-- Upstream -->
  <Part>103918</Part>
</App>
<App>
  <action>A</action>
  <id>311</id>
  <BaseVehicle>68</BaseVehicle>
  <!-- 1984 Porsche 911 -->
  <EngineBase>1778</EngineBase>
  <!-- H6 3.2L -->
  <Aspiration>5</Aspiration>
  <!-- Naturally Aspirated -->
  <Qty>1</Qty>
  <PartType>5132</PartType>
  <!-- Oxygen Sensor -->
  <MfrLabel>Sensor</MfrLabel>
  <Position>2172</Position>
  <!-- Upstream -->
  <Part>103918</Part>
</App>
</Catalogue>

The problem is when I import this XML into Access with XSLT transformation, elements "Aspiration" and "EngineVIN" aren't imported. When I try to import it the same way into Excel, it works fine. Does anyone knows why is this happening with Access and how to solve it? Anyway I found how to solve the problem. I need to add New App id="0" with all element names that are coming in other App-s, like Aspiration, EngineVIN, etc... how to add this new App id="0" on top of the existing data?