R
Richard Kucia
I have an XML parsing problem that I can not resolve.
I have 2 files which contain identical data; call them SI (Schema Included)
and SX (Schema eXcluded). Each file contains 40 tables, most of which hold
only a few rows. When I view them in the Visual Studio, the files are
perfect. In fact, I originally let Visual Studio load SX and generate the
schema that I then pasted into the SI file. The data preview in Visual
Studio is correct.
I have been testing my application using various combinations of the SI and
SX files and the various ReadMode options. The data is loaded into an empty
dataset with ReadXML. A hand-typed highly abbreviated portion of the XML
data that demonstrates the problem is:
<platforms>
<platform type=0>
<networks>
<network linktype=0 />
(other network rows, with child tables [rates] and [rate])
</networks>
</platform>
<platform type=1>
<networks>
<network linktype=0 />
(other network rows, with child tables [rates] and [rate])
</networks>
</platform>
To track down the problem, I wrote a little schema-and-data table dumper. As
expected, tables called [platforms], [platform], [networks] and [network]
are created in the dataset. The dump for [networks] is always correct. It
is:
Table networks: networks_Id platform_Id
Parent of network with networks_Id = networks_Id
0 0
1 1
Here is the dump for [network] on SX with ReadMode.Auto. This means that the
schema needs to be inferred.
Table network: network_Id linktype enabled resource minport maxport
portname desc devices networks_Id
Parent of rates with network_Id = network_Id
0 0 true 2191 0 0 NONE None 0 0
1 1 true 2192 1 4 COM# Serial 16 0
2 2 false 2193 1 2 DN# DeviceNet 64 0
3 3 false 2194 0 0 CB CanBus 64 0
4 4 false 2195 0 0 PB ProfiBus 256 0
5 0 true 2191 0 0 NONE None 0 1
6 1 true 2192 1 8 COM# Serial 16 1
7 2 false 2193 1 2 DN# DeviceNet 64 1
8 3 false 2194 0 0 CB CanBus 64 1
9 4 false 2195 0 0 PB ProfiBus 256 1
However, here is the dump for [network] on SI with ReadMode.Auto. Since the
schema is indeed embedded in the file,
that schema should be used and thus the schema will not need to be inferred.
Remember that Visual Studio generated this
schema originally, and that the data content looks correct within the Visual
Studio preview.
Table network: linktype enabled resource minport maxport portname
desc devices network_Id networks_Id
Parent of rates with network_Id = network_Id
0 true 2191 0 0 NONE None 0 0 0
2 false 2193 1 2 DN# DeviceNet 64 1 0
3 false 2194 0 0 CB CanBus 64 2 0
4 false 2195 0 0 PB ProfiBus 256 3 0
0 true 2191 0 0 NONE None 0 4 1
2 false 2193 1 2 DN# DeviceNet 64 5 1
3 false 2194 0 0 CB CanBus 64 6 1
4 false 2195 0 0 PB ProfiBus 256 7 1
There are 2 problems:
1) OK, this is not a real problem, but it was a surprise. The schemas
reported by the dumper are different. The upper dump shows a [network_Id]
column as column #0, while that column appears second-last in the lower
dump. It does demonstrate that the schema-handling logic is different in the
two cases.
2) HUGE PROBLEM: the [network] rows for COM# are missing! There's 10 rows in
the table but only 8 show up. Check the sequence of values in column
[linktype] and [network_Id]. The XML parser seems to have completely ignored
2 rows!
Please tell me I've overlooked something obvious. Thanks.
Richard Kucia
I have 2 files which contain identical data; call them SI (Schema Included)
and SX (Schema eXcluded). Each file contains 40 tables, most of which hold
only a few rows. When I view them in the Visual Studio, the files are
perfect. In fact, I originally let Visual Studio load SX and generate the
schema that I then pasted into the SI file. The data preview in Visual
Studio is correct.
I have been testing my application using various combinations of the SI and
SX files and the various ReadMode options. The data is loaded into an empty
dataset with ReadXML. A hand-typed highly abbreviated portion of the XML
data that demonstrates the problem is:
<platforms>
<platform type=0>
<networks>
<network linktype=0 />
(other network rows, with child tables [rates] and [rate])
</networks>
</platform>
<platform type=1>
<networks>
<network linktype=0 />
(other network rows, with child tables [rates] and [rate])
</networks>
</platform>
To track down the problem, I wrote a little schema-and-data table dumper. As
expected, tables called [platforms], [platform], [networks] and [network]
are created in the dataset. The dump for [networks] is always correct. It
is:
Table networks: networks_Id platform_Id
Parent of network with networks_Id = networks_Id
0 0
1 1
Here is the dump for [network] on SX with ReadMode.Auto. This means that the
schema needs to be inferred.
Table network: network_Id linktype enabled resource minport maxport
portname desc devices networks_Id
Parent of rates with network_Id = network_Id
0 0 true 2191 0 0 NONE None 0 0
1 1 true 2192 1 4 COM# Serial 16 0
2 2 false 2193 1 2 DN# DeviceNet 64 0
3 3 false 2194 0 0 CB CanBus 64 0
4 4 false 2195 0 0 PB ProfiBus 256 0
5 0 true 2191 0 0 NONE None 0 1
6 1 true 2192 1 8 COM# Serial 16 1
7 2 false 2193 1 2 DN# DeviceNet 64 1
8 3 false 2194 0 0 CB CanBus 64 1
9 4 false 2195 0 0 PB ProfiBus 256 1
However, here is the dump for [network] on SI with ReadMode.Auto. Since the
schema is indeed embedded in the file,
that schema should be used and thus the schema will not need to be inferred.
Remember that Visual Studio generated this
schema originally, and that the data content looks correct within the Visual
Studio preview.
Table network: linktype enabled resource minport maxport portname
desc devices network_Id networks_Id
Parent of rates with network_Id = network_Id
0 true 2191 0 0 NONE None 0 0 0
2 false 2193 1 2 DN# DeviceNet 64 1 0
3 false 2194 0 0 CB CanBus 64 2 0
4 false 2195 0 0 PB ProfiBus 256 3 0
0 true 2191 0 0 NONE None 0 4 1
2 false 2193 1 2 DN# DeviceNet 64 5 1
3 false 2194 0 0 CB CanBus 64 6 1
4 false 2195 0 0 PB ProfiBus 256 7 1
There are 2 problems:
1) OK, this is not a real problem, but it was a surprise. The schemas
reported by the dumper are different. The upper dump shows a [network_Id]
column as column #0, while that column appears second-last in the lower
dump. It does demonstrate that the schema-handling logic is different in the
two cases.
2) HUGE PROBLEM: the [network] rows for COM# are missing! There's 10 rows in
the table but only 8 show up. Check the sequence of values in column
[linktype] and [network_Id]. The XML parser seems to have completely ignored
2 rows!
Please tell me I've overlooked something obvious. Thanks.
Richard Kucia