473,405 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

XML to DataSets

Hi All,

I've been given an XML file (12 MB) that I need to extract data from. The
XML file makes the data easy to view, but the data is impossible to analyze
in its current format. I've looked at lots of XMLTextReader stuff and I
can't seem to figure out how to extract the info that I want. Here's a quick
example of the XML format:

<instance identity="A1" name="A1" type="A_Type">
<attribute Name="AttA1-1">
<value>
X
</value>
</attribute>
<instance identity="B1" name="B1" type="B_Type">
<attribute Name="AttB1-1">
<value>
X
</value>
</attribute>
<instance identity="B2" name="B2" type="B_Type">
<attribute Name="AttB2-1">
<value>
X
</value>
</attribute>
<instance identity="C1" name="C1" type="C_Type">
<attribute Name="AttC1-1">
<value>
X
</value>
</attribute>
</instance>
</instance>
</instance>
</instance>

Each A_Type contains several B_Types, and each B_Type contains several
C_Types and the file contains lots of A_Types. I've shown one attribute
each, but there are lots of them for each type!

what I'd like to do is load this data into a few tables with Master-Detail
Releations. So Table A would contain a row for each A_Type plus it's
attributes (with the Attribute Name as the Column Header). For a given row
selected in Table A, Table B would show each of the B_Types and it's
attributes, etc.

So, is there an easy way to get the data from the file using an
XMLTextReader or some other nifty XML tool, or is this going to be a brute
force method with regular expressions and do loops?

I'm not sure if I've supplied enough info, so if you need to know something
else before you can give me an answer, please let me know!! If it's going to
be brute force, that's fine, but I'd hate to spend a few days coding, only
later to find out that there was a quick way to do this!

TIA
Lee
Nov 21 '05 #1
16 1704
lgbjr,

You can always try to open it as file in your IDE, than you get than some
information.

Cor
Nov 21 '05 #2
Cor,

this I understand. I can open the document in IE, I can import it into
Excel, but in both cases, the format is nice for viewing, but not for data
analysis. the way the data is presented is tabular, rather than columnar.
So, If I want to look at a particular attribute for each Type_C, I have lots
of scrolling up and down to compare the values. Understand?

what I need is to convert the XML file to a dataset, with a table for each
Type, columns for each atrribute in the Type, and rows for each instance of
the Type.

I have found lots of information for creating an XML document from an
existing Dataset, but have not had any luck finding anything regarding
creating a dataset from an existing XML document. I know I can do this
manually (going through the file, finding all of the Types (tables), and
attributes (columns), but I was hoping that there was a tool available that
would do this for me (Input to the tool would be the XML document, the
output would be a dataset) Or I'd be happy with an MDB file or SQL DB,
though I really only need the dataset since the data is already stored on
disk in the XML file (No need to store the data in 2 locations!)

Once I have the dataset, I can "Load" the XML document into the dataset and
do whatever analysis that is required. What I'd like to be able to do is to
dynamically generate the dataset (Step 1 - read the XML file and generate
the dataset, Step 2 - load the data from the XML file into the dataset). Is
there a tool that can do this. Can VB.NET do this? Or do I have to manually
create the dataset first, then load the data from the XML file?

TIA
Lee
"Cor Ligthert" <no************@planet.nl> wrote in message
news:uT**************@TK2MSFTNGP09.phx.gbl...
lgbjr,

You can always try to open it as file in your IDE, than you get than some
information.

Cor

Nov 21 '05 #3
lgbjr,

Did you do in your solution explorere: add existing item, choose XML , and
than browse to your XLM file?

Cor
Nov 21 '05 #4
Cor,

Sure, that's not a problem. I can open the XML file in the viewer and what I
see (because I can't use an XSLT file) is the XML code similar to what I
type in my first post.

But, unfortunately, this doesn't get me any closer to getting the data from
the XML file into a dataset.

cheers
Lee

"Cor Ligthert" <no************@planet.nl> wrote in message
news:OB**************@TK2MSFTNGP09.phx.gbl...
lgbjr,

Did you do in your solution explorere: add existing item, choose XML , and
than browse to your XLM file?

Cor

Nov 21 '05 #5
On Sun, 15 May 2005 21:44:58 +0800, "lgbjr" <lg***@online.nospam>
wrote:
Cor,

Sure, that's not a problem. I can open the XML file in the viewer and what I
see (because I can't use an XSLT file) is the XML code similar to what I
type in my first post.

But, unfortunately, this doesn't get me any closer to getting the data from
the XML file into a dataset.

Once opened in the explorer if it is well formed XML, you should be
able to right click and get it to to create a schema for the XML, once
you have a schema, (may be label view data) it is easy to read it in
to a dataset.

Doug Taylorcheers
Lee

"Cor Ligthert" <no************@planet.nl> wrote in message
news:OB**************@TK2MSFTNGP09.phx.gbl...
lgbjr,

Did you do in your solution explorere: add existing item, choose XML , and
than browse to your XLM file?

Cor


Nov 21 '05 #6
lgbjr,
I would consider using an XSLT transform to transform your input data into
something a little more DataSet friendly. Here is the start of such a
transform:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- handle the document/root node of the input -->
<xsl:template match="/">
<xsl:element name="lbgjr">
<xsl:apply-templates select="*" />
</xsl:element>
</xsl:template>
<!-- convert each instance node into a node that is the same as the Type
attribute -->
<!-- from: -->
<!-- <instance identity="A1" name="A1" type="A_Type"> -->
<!-- <instance identity="B1" name="B1" type="B_Type"> -->
<!-- <instance identity="C1" name="C1" type="C_Type"> -->
<!-- to: -->
<!-- <A_Type identity="A1" name="A1" type="A_Type"> -->
<!-- <B_Type identity="B1" name="B1" type="B_Type"> -->
<!-- <C_Type identity="C1" name="C1" type="C_Type"> -->
<xsl:template match="instance">
<xsl:element name="{@type}">
<xsl:for-each select="@*">
<xsl:attribute name="{local-name(.)}">
<xsl:value-of select="." />
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates select="*" />
</xsl:element>
</xsl:template>
<!-- convert each Attribute node into a node that has the same name as the
attribute -->
<!-- from: -->
<!-- <attribute Name="AttA1-1"> -->
<!-- <value>X</value> -->
<!-- </attribute> -->
<!-- to: -->
<!-- <AttA1-1>X</AttA1-1> -->
<xsl:template match="attribute">
<xsl:element name="{@Name}">
<xsl:value-of select="value" />
</xsl:element>
</xsl:template>
</xsl:stylesheet>

You can call it with code similar to:

Dim xslt As New XslTransform
xslt.Load("lgbjr.xslt")
xslt.Transform("lgbjr.xml", "lgbjr.output.xml", Nothing)
Dim ds As New DataSet
ds.ReadXml("lgbjr.output.xml")

I've only minimally tested the above template, as your sample data is not as
well formed as the description you gave...

Hope this helps
Jay

"lgbjr" <lg***@online.nospam> wrote in message
news:um****************@tk2msftngp13.phx.gbl...
| Hi All,
|
| I've been given an XML file (12 MB) that I need to extract data from. The
| XML file makes the data easy to view, but the data is impossible to
analyze
| in its current format. I've looked at lots of XMLTextReader stuff and I
| can't seem to figure out how to extract the info that I want. Here's a
quick
| example of the XML format:
|
| <instance identity="A1" name="A1" type="A_Type">
| <attribute Name="AttA1-1">
| <value>
| X
| </value>
| </attribute>
| <instance identity="B1" name="B1" type="B_Type">
| <attribute Name="AttB1-1">
| <value>
| X
| </value>
| </attribute>
| <instance identity="B2" name="B2" type="B_Type">
| <attribute Name="AttB2-1">
| <value>
| X
| </value>
| </attribute>
| <instance identity="C1" name="C1" type="C_Type">
| <attribute Name="AttC1-1">
| <value>
| X
| </value>
| </attribute>
| </instance>
| </instance>
| </instance>
| </instance>
|
| Each A_Type contains several B_Types, and each B_Type contains several
| C_Types and the file contains lots of A_Types. I've shown one attribute
| each, but there are lots of them for each type!
|
| what I'd like to do is load this data into a few tables with Master-Detail
| Releations. So Table A would contain a row for each A_Type plus it's
| attributes (with the Attribute Name as the Column Header). For a given row
| selected in Table A, Table B would show each of the B_Types and it's
| attributes, etc.
|
| So, is there an easy way to get the data from the file using an
| XMLTextReader or some other nifty XML tool, or is this going to be a brute
| force method with regular expressions and do loops?
|
| I'm not sure if I've supplied enough info, so if you need to know
something
| else before you can give me an answer, please let me know!! If it's going
to
| be brute force, that's fine, but I'd hate to spend a few days coding, only
| later to find out that there was a quick way to do this!
|
| TIA
| Lee
|
|
Nov 21 '05 #7
Hi All,

OK, I'm starting to understand a bit of what I need to do (and why). When I
add the XML file to the project, open it, then right click in the view and
select View Data Grid, I get an error that says "The Table (instance) cannot
be the child table to itself in nested relations. this makes sense based on
the way the XML file is setup.

So, I need to do as Jay recommended, which is to transform each instance to
its type and each attribute to its name. Then, each instance will be a table
(multiples of the same instance will be rows in the table) and each
attribute in an instance will be a column in the table.

So, I'm working with Jay's XSLT file as a start and am using the bit of code
that he supplied to load the XSLT file, then do the transform.

Here's the first problem. when I run the transform, I get an exception:

The empty string '' is not a valid name.

And the output XML file is obviously incomplete.

This is the top of the XML file that I want to transform:

<?xml version="1.0" ?>
<top>
<model mim="CO_BSSMIM" name="MIB_BSS_BSS_TaiZhouBSS01_133146459903480000"
prefixDN="RMA=Radio_Access_Network" release="UNDEFINED" rootLDN=""
version="2.2">
<instance identity="instance_1151" name="BSS_TaiZhouBSS01" type="BSS">
<attribute name="BSSId">
<datatype>
<string>
<value>
BSS_TaiZhouBSS01
</value>
</string>
</datatype>
</attribute> <instance identity="instance_0" name="RBS_H101"
type="RBS">
<attribute name="RBSId">
<datatype>
<string>
<value>
RBS_H101
</value>
</string>
</datatype>
</attribute> <attribute name="RBSModel">
<datatype>
<enumRef name="RBSModelType">
<value>
1
</value>
</enumRef>
</datatype>
</attribute> <attribute name="SectorConfiguration">
<datatype>
<enumRef name="SectorConfigurationType">
<value>
0
</value>
</enumRef>
</datatype>
</attribute>

this is the output XML file:

<?xml version="1.0" encoding="utf-8"?><lgbjr>

<BSS

There are no trailing spaces in the input XML file. The transform is failing
at the first transformation. Can someone tell me why?

thanks!!

Lee

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:ev**************@TK2MSFTNGP09.phx.gbl...
lgbjr,
I would consider using an XSLT transform to transform your input data into
something a little more DataSet friendly. Here is the start of such a
transform:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- handle the document/root node of the input -->
<xsl:template match="/">
<xsl:element name="lbgjr">
<xsl:apply-templates select="*" />
</xsl:element>
</xsl:template>
<!-- convert each instance node into a node that is the same as the Type
attribute -->
<!-- from: -->
<!-- <instance identity="A1" name="A1" type="A_Type"> -->
<!-- <instance identity="B1" name="B1" type="B_Type"> -->
<!-- <instance identity="C1" name="C1" type="C_Type"> -->
<!-- to: -->
<!-- <A_Type identity="A1" name="A1" type="A_Type"> -->
<!-- <B_Type identity="B1" name="B1" type="B_Type"> -->
<!-- <C_Type identity="C1" name="C1" type="C_Type"> -->
<xsl:template match="instance">
<xsl:element name="{@type}">
<xsl:for-each select="@*">
<xsl:attribute name="{local-name(.)}">
<xsl:value-of select="." />
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates select="*" />
</xsl:element>
</xsl:template>
<!-- convert each Attribute node into a node that has the same name as the
attribute -->
<!-- from: -->
<!-- <attribute Name="AttA1-1"> -->
<!-- <value>X</value> -->
<!-- </attribute> -->
<!-- to: -->
<!-- <AttA1-1>X</AttA1-1> -->
<xsl:template match="attribute">
<xsl:element name="{@Name}">
<xsl:value-of select="value" />
</xsl:element>
</xsl:template>
</xsl:stylesheet>

You can call it with code similar to:

Dim xslt As New XslTransform
xslt.Load("lgbjr.xslt")
xslt.Transform("lgbjr.xml", "lgbjr.output.xml", Nothing)
Dim ds As New DataSet
ds.ReadXml("lgbjr.output.xml")

I've only minimally tested the above template, as your sample data is not
as
well formed as the description you gave...

Hope this helps
Jay

"lgbjr" <lg***@online.nospam> wrote in message
news:um****************@tk2msftngp13.phx.gbl...
| Hi All,
|
| I've been given an XML file (12 MB) that I need to extract data from.
The
| XML file makes the data easy to view, but the data is impossible to
analyze
| in its current format. I've looked at lots of XMLTextReader stuff and I
| can't seem to figure out how to extract the info that I want. Here's a
quick
| example of the XML format:
|
| <instance identity="A1" name="A1" type="A_Type">
| <attribute Name="AttA1-1">
| <value>
| X
| </value>
| </attribute>
| <instance identity="B1" name="B1" type="B_Type">
| <attribute Name="AttB1-1">
| <value>
| X
| </value>
| </attribute>
| <instance identity="B2" name="B2" type="B_Type">
| <attribute Name="AttB2-1">
| <value>
| X
| </value>
| </attribute>
| <instance identity="C1" name="C1" type="C_Type">
| <attribute Name="AttC1-1">
| <value>
| X
| </value>
| </attribute>
| </instance>
| </instance>
| </instance>
| </instance>
|
| Each A_Type contains several B_Types, and each B_Type contains several
| C_Types and the file contains lots of A_Types. I've shown one attribute
| each, but there are lots of them for each type!
|
| what I'd like to do is load this data into a few tables with
Master-Detail
| Releations. So Table A would contain a row for each A_Type plus it's
| attributes (with the Attribute Name as the Column Header). For a given
row
| selected in Table A, Table B would show each of the B_Types and it's
| attributes, etc.
|
| So, is there an easy way to get the data from the file using an
| XMLTextReader or some other nifty XML tool, or is this going to be a
brute
| force method with regular expressions and do loops?
|
| I'm not sure if I've supplied enough info, so if you need to know
something
| else before you can give me an answer, please let me know!! If it's
going
to
| be brute force, that's fine, but I'd hate to spend a few days coding,
only
| later to find out that there was a quick way to do this!
|
| TIA
| Lee
|
|

Nov 21 '05 #8
lgbjr,
The error itself is because I used "Name" for the "name" attribute of
Attributes.

However once that is fixed you will have another problem, your original XML
did not include the "type" nodes for Attributes.

Your original XML had:

| > | <attribute Name="AttB1-1">
| > | <value>
| > | X
| > | </value>
| > | </attribute>

While your "actual" XML has:

| <attribute name="BSSId">
| <datatype>
| <string>
| <value>
| BSS_TaiZhouBSS01
| </value>
| </string>
| </datatype>
| </attribute>

Notice the <datatype> & <string> nodes in the above. Also it appears your
original includes both a document node of <top> and another node of <model>.

Here is an updated XSLT:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- handle the document/root node of the input -->
<xsl:template match="/">
<xsl:apply-templates select="*" />
</xsl:template>
<!-- copy the top node "as is" -->
<xsl:template match="top">
<xsl:element name="top">
<xsl:copy-of select="@*" />
<xsl:apply-templates select="*" />
</xsl:element>
</xsl:template>
<!-- copy the model node "as is" -->
<xsl:template match="model">
<xsl:element name="model">
<xsl:copy-of select="@*" />
<xsl:apply-templates select="*" />
</xsl:element>
</xsl:template>
<!-- convert each instance node into a node that is the same as the Type
attribute -->
<xsl:template match="instance">
<xsl:element name="{@type}">
<xsl:copy-of select="@*" />
<xsl:apply-templates select="*" />
</xsl:element>
</xsl:template>
<!-- convert each Attribute node into a node that has the same name as the
attribute -->
<xsl:template match="attribute">
<xsl:element name="{@name}">
<xsl:attribute name="xsi:type"
namespace="http://www.w3.org/2001/XMLSchema-instance">
<xsl:choose>
<xsl:when test="local-name(datatype/*)='enumRef'">
<xsl:value-of select="datatype/*/@name" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="local-name(datatype/*)" />
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:value-of select="datatype/*/value" />
</xsl:element>
</xsl:template>
</xsl:stylesheet>

NOTE: I simply copy the <top> & <model> nodes as is. I "preserve" the type
of the individual Attributes, as an attribute of that Attribute.

This:
| <attribute name="BSSId">
| <datatype>
| <string>
| <value>
| BSS_TaiZhouBSS01
| </value>
| </string>
| </datatype>
| </attribute>

Becomes this:

<BSSId type="string">BSS_TaiZhouBSS01</BSSId>

Note: The type attribute in the above, should probably be xsi:type!

Instead of:
<xsl:element name="{@name}">
<xsl:attribute name="xsi:type"
namespace="http://www.w3.org/2001/XMLSchema-instance">

You can use:
<xsl:element name="{@name}">
<xsl:attribute name="type">

To remove all of the xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
in the output, ideally xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
should be included once on <top>.

Hope this helps
Jay
"lgbjr" <lg***@online.nospam> wrote in message
news:uo**************@TK2MSFTNGP09.phx.gbl...
| Hi All,
|
| OK, I'm starting to understand a bit of what I need to do (and why). When
I
| add the XML file to the project, open it, then right click in the view and
| select View Data Grid, I get an error that says "The Table (instance)
cannot
| be the child table to itself in nested relations. this makes sense based
on
| the way the XML file is setup.
|
| So, I need to do as Jay recommended, which is to transform each instance
to
| its type and each attribute to its name. Then, each instance will be a
table
| (multiples of the same instance will be rows in the table) and each
| attribute in an instance will be a column in the table.
|
| So, I'm working with Jay's XSLT file as a start and am using the bit of
code
| that he supplied to load the XSLT file, then do the transform.
|
| Here's the first problem. when I run the transform, I get an exception:
|
| The empty string '' is not a valid name.
|
| And the output XML file is obviously incomplete.
|
| This is the top of the XML file that I want to transform:
|
| <?xml version="1.0" ?>
| <top>
| <model mim="CO_BSSMIM" name="MIB_BSS_BSS_TaiZhouBSS01_133146459903480000"
| prefixDN="RMA=Radio_Access_Network" release="UNDEFINED" rootLDN=""
| version="2.2">
| <instance identity="instance_1151" name="BSS_TaiZhouBSS01" type="BSS">
| <attribute name="BSSId">
| <datatype>
| <string>
| <value>
| BSS_TaiZhouBSS01
| </value>
| </string>
| </datatype>
| </attribute> <instance identity="instance_0" name="RBS_H101"
| type="RBS">
| <attribute name="RBSId">
| <datatype>
| <string>
| <value>
| RBS_H101
| </value>
| </string>
| </datatype>
| </attribute> <attribute name="RBSModel">
| <datatype>
| <enumRef name="RBSModelType">
| <value>
| 1
| </value>
| </enumRef>
| </datatype>
| </attribute> <attribute name="SectorConfiguration">
| <datatype>
| <enumRef name="SectorConfigurationType">
| <value>
| 0
| </value>
| </enumRef>
| </datatype>
| </attribute>
|
| this is the output XML file:
|
| <?xml version="1.0" encoding="utf-8"?><lgbjr>
|
| <BSS
|
| There are no trailing spaces in the input XML file. The transform is
failing
| at the first transformation. Can someone tell me why?
|
| thanks!!
|
| Lee
|
| "Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
| news:ev**************@TK2MSFTNGP09.phx.gbl...
| > lgbjr,
| > I would consider using an XSLT transform to transform your input data
into
| > something a little more DataSet friendly. Here is the start of such a
| > transform:
| >
| > <?xml version="1.0" encoding="UTF-8" ?>
| > <xsl:stylesheet version="1.0"
| > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
| > <!-- handle the document/root node of the input -->
| > <xsl:template match="/">
| > <xsl:element name="lbgjr">
| > <xsl:apply-templates select="*" />
| > </xsl:element>
| > </xsl:template>
| > <!-- convert each instance node into a node that is the same as the Type
| > attribute -->
| > <!-- from: -->
| > <!-- <instance identity="A1" name="A1" type="A_Type"> -->
| > <!-- <instance identity="B1" name="B1" type="B_Type"> -->
| > <!-- <instance identity="C1" name="C1" type="C_Type"> -->
| > <!-- to: -->
| > <!-- <A_Type identity="A1" name="A1" type="A_Type"> -->
| > <!-- <B_Type identity="B1" name="B1" type="B_Type"> -->
| > <!-- <C_Type identity="C1" name="C1" type="C_Type"> -->
| > <xsl:template match="instance">
| > <xsl:element name="{@type}">
| > <xsl:for-each select="@*">
| > <xsl:attribute name="{local-name(.)}">
| > <xsl:value-of select="." />
| > </xsl:attribute>
| > </xsl:for-each>
| > <xsl:apply-templates select="*" />
| > </xsl:element>
| > </xsl:template>
| > <!-- convert each Attribute node into a node that has the same name as
the
| > attribute -->
| > <!-- from: -->
| > <!-- <attribute Name="AttA1-1"> -->
| > <!-- <value>X</value> -->
| > <!-- </attribute> -->
| > <!-- to: -->
| > <!-- <AttA1-1>X</AttA1-1> -->
| > <xsl:template match="attribute">
| > <xsl:element name="{@Name}">
| > <xsl:value-of select="value" />
| > </xsl:element>
| > </xsl:template>
| > </xsl:stylesheet>
| >
| > You can call it with code similar to:
| >
| > Dim xslt As New XslTransform
| > xslt.Load("lgbjr.xslt")
| > xslt.Transform("lgbjr.xml", "lgbjr.output.xml", Nothing)
| > Dim ds As New DataSet
| > ds.ReadXml("lgbjr.output.xml")
| >
| > I've only minimally tested the above template, as your sample data is
not
| > as
| > well formed as the description you gave...
| >
| > Hope this helps
| > Jay
| >
| > "lgbjr" <lg***@online.nospam> wrote in message
| > news:um****************@tk2msftngp13.phx.gbl...
| > | Hi All,
| > |
| > | I've been given an XML file (12 MB) that I need to extract data from.
| > The
| > | XML file makes the data easy to view, but the data is impossible to
| > analyze
| > | in its current format. I've looked at lots of XMLTextReader stuff and
I
| > | can't seem to figure out how to extract the info that I want. Here's a
| > quick
| > | example of the XML format:
| > |
| > | <instance identity="A1" name="A1" type="A_Type">
| > | <attribute Name="AttA1-1">
| > | <value>
| > | X
| > | </value>
| > | </attribute>
| > | <instance identity="B1" name="B1" type="B_Type">
| > | <attribute Name="AttB1-1">
| > | <value>
| > | X
| > | </value>
| > | </attribute>
| > | <instance identity="B2" name="B2" type="B_Type">
| > | <attribute Name="AttB2-1">
| > | <value>
| > | X
| > | </value>
| > | </attribute>
| > | <instance identity="C1" name="C1" type="C_Type">
| > | <attribute Name="AttC1-1">
| > | <value>
| > | X
| > | </value>
| > | </attribute>
| > | </instance>
| > | </instance>
| > | </instance>
| > | </instance>
| > |
| > | Each A_Type contains several B_Types, and each B_Type contains several
| > | C_Types and the file contains lots of A_Types. I've shown one
attribute
| > | each, but there are lots of them for each type!
| > |
| > | what I'd like to do is load this data into a few tables with
| > Master-Detail
| > | Releations. So Table A would contain a row for each A_Type plus it's
| > | attributes (with the Attribute Name as the Column Header). For a given
| > row
| > | selected in Table A, Table B would show each of the B_Types and it's
| > | attributes, etc.
| > |
| > | So, is there an easy way to get the data from the file using an
| > | XMLTextReader or some other nifty XML tool, or is this going to be a
| > brute
| > | force method with regular expressions and do loops?
| > |
| > | I'm not sure if I've supplied enough info, so if you need to know
| > something
| > | else before you can give me an answer, please let me know!! If it's
| > going
| > to
| > | be brute force, that's fine, but I'd hate to spend a few days coding,
| > only
| > | later to find out that there was a quick way to do this!
| > |
| > | TIA
| > | Lee
| > |
| > |
| >
| >
|
|
Nov 21 '05 #9
Hi Jay,

Thank you very much for the help. I've been using VB.NET for 2 years now, so
I've been surrounded by XML, but never actually used it! Now I've got a
requirement to use it and I'm having to jump in with both feet. I'm sure
that playing with all of the nice little examples in the docs and on the web
would have eventually gotten me to this point, but honestly, now, I just
don't have the time. Once I get this finished, I'll go back and do the step
by step stuff (which I'm sure will lead to a whole set of new questions!)
Thanks for getting me in the fast lane on this stuff. I appreciate that your
posts include not only code, but comments as to why certain things are
there. This makes a big difference to me as it's easier to understand why
things are done a certain way.

Sorry for not including the same XML code in the original post. Again, as
this is new to me, I didn't really know what was important and what wasn't.
I opted for being as brief as possible the first time. Now, I know better!

Thanks Again,
Lee

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:O9**************@TK2MSFTNGP09.phx.gbl...
lgbjr,
The error itself is because I used "Name" for the "name" attribute of
Attributes.

However once that is fixed you will have another problem, your original
XML
did not include the "type" nodes for Attributes.

Your original XML had:

| > | <attribute Name="AttB1-1">
| > | <value>
| > | X
| > | </value>
| > | </attribute>

While your "actual" XML has:

| <attribute name="BSSId">
| <datatype>
| <string>
| <value>
| BSS_TaiZhouBSS01
| </value>
| </string>
| </datatype>
| </attribute>

Notice the <datatype> & <string> nodes in the above. Also it appears your
original includes both a document node of <top> and another node of
<model>.

Here is an updated XSLT:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- handle the document/root node of the input -->
<xsl:template match="/">
<xsl:apply-templates select="*" />
</xsl:template>
<!-- copy the top node "as is" -->
<xsl:template match="top">
<xsl:element name="top">
<xsl:copy-of select="@*" />
<xsl:apply-templates select="*" />
</xsl:element>
</xsl:template>
<!-- copy the model node "as is" -->
<xsl:template match="model">
<xsl:element name="model">
<xsl:copy-of select="@*" />
<xsl:apply-templates select="*" />
</xsl:element>
</xsl:template>
<!-- convert each instance node into a node that is the same as the Type
attribute -->
<xsl:template match="instance">
<xsl:element name="{@type}">
<xsl:copy-of select="@*" />
<xsl:apply-templates select="*" />
</xsl:element>
</xsl:template>
<!-- convert each Attribute node into a node that has the same name as the
attribute -->
<xsl:template match="attribute">
<xsl:element name="{@name}">
<xsl:attribute name="xsi:type"
namespace="http://www.w3.org/2001/XMLSchema-instance">
<xsl:choose>
<xsl:when test="local-name(datatype/*)='enumRef'">
<xsl:value-of select="datatype/*/@name" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="local-name(datatype/*)" />
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:value-of select="datatype/*/value" />
</xsl:element>
</xsl:template>
</xsl:stylesheet>

NOTE: I simply copy the <top> & <model> nodes as is. I "preserve" the type
of the individual Attributes, as an attribute of that Attribute.

This:
| <attribute name="BSSId">
| <datatype>
| <string>
| <value>
| BSS_TaiZhouBSS01
| </value>
| </string>
| </datatype>
| </attribute>

Becomes this:

<BSSId type="string">BSS_TaiZhouBSS01</BSSId>

Note: The type attribute in the above, should probably be xsi:type!

Instead of:
<xsl:element name="{@name}">
<xsl:attribute name="xsi:type"
namespace="http://www.w3.org/2001/XMLSchema-instance">

You can use:
<xsl:element name="{@name}">
<xsl:attribute name="type">

To remove all of the xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
in the output, ideally
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
should be included once on <top>.

Hope this helps
Jay
"lgbjr" <lg***@online.nospam> wrote in message
news:uo**************@TK2MSFTNGP09.phx.gbl...
| Hi All,
|
| OK, I'm starting to understand a bit of what I need to do (and why).
When
I
| add the XML file to the project, open it, then right click in the view
and
| select View Data Grid, I get an error that says "The Table (instance)
cannot
| be the child table to itself in nested relations. this makes sense based
on
| the way the XML file is setup.
|
| So, I need to do as Jay recommended, which is to transform each instance
to
| its type and each attribute to its name. Then, each instance will be a
table
| (multiples of the same instance will be rows in the table) and each
| attribute in an instance will be a column in the table.
|
| So, I'm working with Jay's XSLT file as a start and am using the bit of
code
| that he supplied to load the XSLT file, then do the transform.
|
| Here's the first problem. when I run the transform, I get an exception:
|
| The empty string '' is not a valid name.
|
| And the output XML file is obviously incomplete.
|
| This is the top of the XML file that I want to transform:
|
| <?xml version="1.0" ?>
| <top>
| <model mim="CO_BSSMIM"
name="MIB_BSS_BSS_TaiZhouBSS01_133146459903480000"
| prefixDN="RMA=Radio_Access_Network" release="UNDEFINED" rootLDN=""
| version="2.2">
| <instance identity="instance_1151" name="BSS_TaiZhouBSS01" type="BSS">
| <attribute name="BSSId">
| <datatype>
| <string>
| <value>
| BSS_TaiZhouBSS01
| </value>
| </string>
| </datatype>
| </attribute> <instance identity="instance_0" name="RBS_H101"
| type="RBS">
| <attribute name="RBSId">
| <datatype>
| <string>
| <value>
| RBS_H101
| </value>
| </string>
| </datatype>
| </attribute> <attribute name="RBSModel">
| <datatype>
| <enumRef name="RBSModelType">
| <value>
| 1
| </value>
| </enumRef>
| </datatype>
| </attribute> <attribute name="SectorConfiguration">
| <datatype>
| <enumRef name="SectorConfigurationType">
| <value>
| 0
| </value>
| </enumRef>
| </datatype>
| </attribute>
|
| this is the output XML file:
|
| <?xml version="1.0" encoding="utf-8"?><lgbjr>
|
| <BSS
|
| There are no trailing spaces in the input XML file. The transform is
failing
| at the first transformation. Can someone tell me why?
|
| thanks!!
|
| Lee
|
| "Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in
message
| news:ev**************@TK2MSFTNGP09.phx.gbl...
| > lgbjr,
| > I would consider using an XSLT transform to transform your input data
into
| > something a little more DataSet friendly. Here is the start of such a
| > transform:
| >
| > <?xml version="1.0" encoding="UTF-8" ?>
| > <xsl:stylesheet version="1.0"
| > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
| > <!-- handle the document/root node of the input -->
| > <xsl:template match="/">
| > <xsl:element name="lbgjr">
| > <xsl:apply-templates select="*" />
| > </xsl:element>
| > </xsl:template>
| > <!-- convert each instance node into a node that is the same as the
Type
| > attribute -->
| > <!-- from: -->
| > <!-- <instance identity="A1" name="A1" type="A_Type"> -->
| > <!-- <instance identity="B1" name="B1" type="B_Type"> -->
| > <!-- <instance identity="C1" name="C1" type="C_Type"> -->
| > <!-- to: -->
| > <!-- <A_Type identity="A1" name="A1" type="A_Type"> -->
| > <!-- <B_Type identity="B1" name="B1" type="B_Type"> -->
| > <!-- <C_Type identity="C1" name="C1" type="C_Type"> -->
| > <xsl:template match="instance">
| > <xsl:element name="{@type}">
| > <xsl:for-each select="@*">
| > <xsl:attribute name="{local-name(.)}">
| > <xsl:value-of select="." />
| > </xsl:attribute>
| > </xsl:for-each>
| > <xsl:apply-templates select="*" />
| > </xsl:element>
| > </xsl:template>
| > <!-- convert each Attribute node into a node that has the same name as
the
| > attribute -->
| > <!-- from: -->
| > <!-- <attribute Name="AttA1-1"> -->
| > <!-- <value>X</value> -->
| > <!-- </attribute> -->
| > <!-- to: -->
| > <!-- <AttA1-1>X</AttA1-1> -->
| > <xsl:template match="attribute">
| > <xsl:element name="{@Name}">
| > <xsl:value-of select="value" />
| > </xsl:element>
| > </xsl:template>
| > </xsl:stylesheet>
| >
| > You can call it with code similar to:
| >
| > Dim xslt As New XslTransform
| > xslt.Load("lgbjr.xslt")
| > xslt.Transform("lgbjr.xml", "lgbjr.output.xml", Nothing)
| > Dim ds As New DataSet
| > ds.ReadXml("lgbjr.output.xml")
| >
| > I've only minimally tested the above template, as your sample data is
not
| > as
| > well formed as the description you gave...
| >
| > Hope this helps
| > Jay
| >
| > "lgbjr" <lg***@online.nospam> wrote in message
| > news:um****************@tk2msftngp13.phx.gbl...
| > | Hi All,
| > |
| > | I've been given an XML file (12 MB) that I need to extract data
from.
| > The
| > | XML file makes the data easy to view, but the data is impossible to
| > analyze
| > | in its current format. I've looked at lots of XMLTextReader stuff
and
I
| > | can't seem to figure out how to extract the info that I want. Here's
a
| > quick
| > | example of the XML format:
| > |
| > | <instance identity="A1" name="A1" type="A_Type">
| > | <attribute Name="AttA1-1">
| > | <value>
| > | X
| > | </value>
| > | </attribute>
| > | <instance identity="B1" name="B1" type="B_Type">
| > | <attribute Name="AttB1-1">
| > | <value>
| > | X
| > | </value>
| > | </attribute>
| > | <instance identity="B2" name="B2" type="B_Type">
| > | <attribute Name="AttB2-1">
| > | <value>
| > | X
| > | </value>
| > | </attribute>
| > | <instance identity="C1" name="C1" type="C_Type">
| > | <attribute Name="AttC1-1">
| > | <value>
| > | X
| > | </value>
| > | </attribute>
| > | </instance>
| > | </instance>
| > | </instance>
| > | </instance>
| > |
| > | Each A_Type contains several B_Types, and each B_Type contains
several
| > | C_Types and the file contains lots of A_Types. I've shown one
attribute
| > | each, but there are lots of them for each type!
| > |
| > | what I'd like to do is load this data into a few tables with
| > Master-Detail
| > | Releations. So Table A would contain a row for each A_Type plus it's
| > | attributes (with the Attribute Name as the Column Header). For a
given
| > row
| > | selected in Table A, Table B would show each of the B_Types and it's
| > | attributes, etc.
| > |
| > | So, is there an easy way to get the data from the file using an
| > | XMLTextReader or some other nifty XML tool, or is this going to be a
| > brute
| > | force method with regular expressions and do loops?
| > |
| > | I'm not sure if I've supplied enough info, so if you need to know
| > something
| > | else before you can give me an answer, please let me know!! If it's
| > going
| > to
| > | be brute force, that's fine, but I'd hate to spend a few days
coding,
| > only
| > | later to find out that there was a quick way to do this!
| > |
| > | TIA
| > | Lee
| > |
| > |
| >
| >
|
|

Nov 21 '05 #10
Hi Jay,

OK, so far, so good. Using your XSLT as a start, I added some more
transforms (for things that where not included in the previous posts. So,
the XSLT works, I can read the resulting XML file (dataset.ReadXML), and I
can create an XSD file (dataset.WriteXmlSchema). As a test, I imported the
resulting Schema into Access, then imported the XML file (append data to
exisiting tables) and everything looks good.

After seeing that the results were good, I went back to my small transform
app and added a shell to XSD.exe to generate a typed dataset from the XSD
file.

Now, my thinking is that using a typed data set is the easiest way to go for
use in a new app. I just add the typed dataset, and the rest is pretty easy.
But, of course, as soon as I realize something will be easy, it doesn't
work!! XSD.exe creates a vb file that I added to a new app. then I dropped a
dataset on my form and selected the typed dataset, but I get an error saying
"Exception has been thrown by the target of an invocation". Not very
descriptive!!

Now, temporarily, forgetting the typed dataset, if I do a dataset.readxml, I
have to dynamically create each table and column and relationship that I
want to see in a grid. If I add the XSD file to my project, how can I use
the tables/columns/relationships defined in the XSD file? Or can I only do
this with a typed dataset created from the XSD file?

TIA,
Lee

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:O9**************@TK2MSFTNGP09.phx.gbl...
lgbjr,
The error itself is because I used "Name" for the "name" attribute of
Attributes.

However once that is fixed you will have another problem, your original
XML
did not include the "type" nodes for Attributes.

Your original XML had:

| > | <attribute Name="AttB1-1">
| > | <value>
| > | X
| > | </value>
| > | </attribute>

While your "actual" XML has:

| <attribute name="BSSId">
| <datatype>
| <string>
| <value>
| BSS_TaiZhouBSS01
| </value>
| </string>
| </datatype>
| </attribute>

Notice the <datatype> & <string> nodes in the above. Also it appears your
original includes both a document node of <top> and another node of
<model>.

Here is an updated XSLT:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- handle the document/root node of the input -->
<xsl:template match="/">
<xsl:apply-templates select="*" />
</xsl:template>
<!-- copy the top node "as is" -->
<xsl:template match="top">
<xsl:element name="top">
<xsl:copy-of select="@*" />
<xsl:apply-templates select="*" />
</xsl:element>
</xsl:template>
<!-- copy the model node "as is" -->
<xsl:template match="model">
<xsl:element name="model">
<xsl:copy-of select="@*" />
<xsl:apply-templates select="*" />
</xsl:element>
</xsl:template>
<!-- convert each instance node into a node that is the same as the Type
attribute -->
<xsl:template match="instance">
<xsl:element name="{@type}">
<xsl:copy-of select="@*" />
<xsl:apply-templates select="*" />
</xsl:element>
</xsl:template>
<!-- convert each Attribute node into a node that has the same name as the
attribute -->
<xsl:template match="attribute">
<xsl:element name="{@name}">
<xsl:attribute name="xsi:type"
namespace="http://www.w3.org/2001/XMLSchema-instance">
<xsl:choose>
<xsl:when test="local-name(datatype/*)='enumRef'">
<xsl:value-of select="datatype/*/@name" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="local-name(datatype/*)" />
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:value-of select="datatype/*/value" />
</xsl:element>
</xsl:template>
</xsl:stylesheet>

NOTE: I simply copy the <top> & <model> nodes as is. I "preserve" the type
of the individual Attributes, as an attribute of that Attribute.

This:
| <attribute name="BSSId">
| <datatype>
| <string>
| <value>
| BSS_TaiZhouBSS01
| </value>
| </string>
| </datatype>
| </attribute>

Becomes this:

<BSSId type="string">BSS_TaiZhouBSS01</BSSId>

Note: The type attribute in the above, should probably be xsi:type!

Instead of:
<xsl:element name="{@name}">
<xsl:attribute name="xsi:type"
namespace="http://www.w3.org/2001/XMLSchema-instance">

You can use:
<xsl:element name="{@name}">
<xsl:attribute name="type">

To remove all of the xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
in the output, ideally
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
should be included once on <top>.

Hope this helps
Jay
"lgbjr" <lg***@online.nospam> wrote in message
news:uo**************@TK2MSFTNGP09.phx.gbl...
| Hi All,
|
| OK, I'm starting to understand a bit of what I need to do (and why).
When
I
| add the XML file to the project, open it, then right click in the view
and
| select View Data Grid, I get an error that says "The Table (instance)
cannot
| be the child table to itself in nested relations. this makes sense based
on
| the way the XML file is setup.
|
| So, I need to do as Jay recommended, which is to transform each instance
to
| its type and each attribute to its name. Then, each instance will be a
table
| (multiples of the same instance will be rows in the table) and each
| attribute in an instance will be a column in the table.
|
| So, I'm working with Jay's XSLT file as a start and am using the bit of
code
| that he supplied to load the XSLT file, then do the transform.
|
| Here's the first problem. when I run the transform, I get an exception:
|
| The empty string '' is not a valid name.
|
| And the output XML file is obviously incomplete.
|
| This is the top of the XML file that I want to transform:
|
| <?xml version="1.0" ?>
| <top>
| <model mim="CO_BSSMIM"
name="MIB_BSS_BSS_TaiZhouBSS01_133146459903480000"
| prefixDN="RMA=Radio_Access_Network" release="UNDEFINED" rootLDN=""
| version="2.2">
| <instance identity="instance_1151" name="BSS_TaiZhouBSS01" type="BSS">
| <attribute name="BSSId">
| <datatype>
| <string>
| <value>
| BSS_TaiZhouBSS01
| </value>
| </string>
| </datatype>
| </attribute> <instance identity="instance_0" name="RBS_H101"
| type="RBS">
| <attribute name="RBSId">
| <datatype>
| <string>
| <value>
| RBS_H101
| </value>
| </string>
| </datatype>
| </attribute> <attribute name="RBSModel">
| <datatype>
| <enumRef name="RBSModelType">
| <value>
| 1
| </value>
| </enumRef>
| </datatype>
| </attribute> <attribute name="SectorConfiguration">
| <datatype>
| <enumRef name="SectorConfigurationType">
| <value>
| 0
| </value>
| </enumRef>
| </datatype>
| </attribute>
|
| this is the output XML file:
|
| <?xml version="1.0" encoding="utf-8"?><lgbjr>
|
| <BSS
|
| There are no trailing spaces in the input XML file. The transform is
failing
| at the first transformation. Can someone tell me why?
|
| thanks!!
|
| Lee
|
| "Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in
message
| news:ev**************@TK2MSFTNGP09.phx.gbl...
| > lgbjr,
| > I would consider using an XSLT transform to transform your input data
into
| > something a little more DataSet friendly. Here is the start of such a
| > transform:
| >
| > <?xml version="1.0" encoding="UTF-8" ?>
| > <xsl:stylesheet version="1.0"
| > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
| > <!-- handle the document/root node of the input -->
| > <xsl:template match="/">
| > <xsl:element name="lbgjr">
| > <xsl:apply-templates select="*" />
| > </xsl:element>
| > </xsl:template>
| > <!-- convert each instance node into a node that is the same as the
Type
| > attribute -->
| > <!-- from: -->
| > <!-- <instance identity="A1" name="A1" type="A_Type"> -->
| > <!-- <instance identity="B1" name="B1" type="B_Type"> -->
| > <!-- <instance identity="C1" name="C1" type="C_Type"> -->
| > <!-- to: -->
| > <!-- <A_Type identity="A1" name="A1" type="A_Type"> -->
| > <!-- <B_Type identity="B1" name="B1" type="B_Type"> -->
| > <!-- <C_Type identity="C1" name="C1" type="C_Type"> -->
| > <xsl:template match="instance">
| > <xsl:element name="{@type}">
| > <xsl:for-each select="@*">
| > <xsl:attribute name="{local-name(.)}">
| > <xsl:value-of select="." />
| > </xsl:attribute>
| > </xsl:for-each>
| > <xsl:apply-templates select="*" />
| > </xsl:element>
| > </xsl:template>
| > <!-- convert each Attribute node into a node that has the same name as
the
| > attribute -->
| > <!-- from: -->
| > <!-- <attribute Name="AttA1-1"> -->
| > <!-- <value>X</value> -->
| > <!-- </attribute> -->
| > <!-- to: -->
| > <!-- <AttA1-1>X</AttA1-1> -->
| > <xsl:template match="attribute">
| > <xsl:element name="{@Name}">
| > <xsl:value-of select="value" />
| > </xsl:element>
| > </xsl:template>
| > </xsl:stylesheet>
| >
| > You can call it with code similar to:
| >
| > Dim xslt As New XslTransform
| > xslt.Load("lgbjr.xslt")
| > xslt.Transform("lgbjr.xml", "lgbjr.output.xml", Nothing)
| > Dim ds As New DataSet
| > ds.ReadXml("lgbjr.output.xml")
| >
| > I've only minimally tested the above template, as your sample data is
not
| > as
| > well formed as the description you gave...
| >
| > Hope this helps
| > Jay
| >
| > "lgbjr" <lg***@online.nospam> wrote in message
| > news:um****************@tk2msftngp13.phx.gbl...
| > | Hi All,
| > |
| > | I've been given an XML file (12 MB) that I need to extract data
from.
| > The
| > | XML file makes the data easy to view, but the data is impossible to
| > analyze
| > | in its current format. I've looked at lots of XMLTextReader stuff
and
I
| > | can't seem to figure out how to extract the info that I want. Here's
a
| > quick
| > | example of the XML format:
| > |
| > | <instance identity="A1" name="A1" type="A_Type">
| > | <attribute Name="AttA1-1">
| > | <value>
| > | X
| > | </value>
| > | </attribute>
| > | <instance identity="B1" name="B1" type="B_Type">
| > | <attribute Name="AttB1-1">
| > | <value>
| > | X
| > | </value>
| > | </attribute>
| > | <instance identity="B2" name="B2" type="B_Type">
| > | <attribute Name="AttB2-1">
| > | <value>
| > | X
| > | </value>
| > | </attribute>
| > | <instance identity="C1" name="C1" type="C_Type">
| > | <attribute Name="AttC1-1">
| > | <value>
| > | X
| > | </value>
| > | </attribute>
| > | </instance>
| > | </instance>
| > | </instance>
| > | </instance>
| > |
| > | Each A_Type contains several B_Types, and each B_Type contains
several
| > | C_Types and the file contains lots of A_Types. I've shown one
attribute
| > | each, but there are lots of them for each type!
| > |
| > | what I'd like to do is load this data into a few tables with
| > Master-Detail
| > | Releations. So Table A would contain a row for each A_Type plus it's
| > | attributes (with the Attribute Name as the Column Header). For a
given
| > row
| > | selected in Table A, Table B would show each of the B_Types and it's
| > | attributes, etc.
| > |
| > | So, is there an easy way to get the data from the file using an
| > | XMLTextReader or some other nifty XML tool, or is this going to be a
| > brute
| > | force method with regular expressions and do loops?
| > |
| > | I'm not sure if I've supplied enough info, so if you need to know
| > something
| > | else before you can give me an answer, please let me know!! If it's
| > going
| > to
| > | be brute force, that's fine, but I'd hate to spend a few days
coding,
| > only
| > | later to find out that there was a quick way to do this!
| > |
| > | TIA
| > | Lee
| > |
| > |
| >
| >
|
|

Nov 21 '05 #11
Lee,
Rather then use XSD.exe to explicitly create the typed dataset, I would
simply add the .XSD itself (the one created by DataSet.WriteXmlSchema) to my
project. I would then open the .XSD file, right click & select "Generate
DataSet".

This implicitly creates a typed dataset.

Hope this helps
Jay

"lgbjr" <lg***@online.nospam> wrote in message
news:ep**************@TK2MSFTNGP12.phx.gbl...
| Hi Jay,
|
| OK, so far, so good. Using your XSLT as a start, I added some more
| transforms (for things that where not included in the previous posts. So,
| the XSLT works, I can read the resulting XML file (dataset.ReadXML), and I
| can create an XSD file (dataset.WriteXmlSchema). As a test, I imported the
| resulting Schema into Access, then imported the XML file (append data to
| exisiting tables) and everything looks good.
|
| After seeing that the results were good, I went back to my small transform
| app and added a shell to XSD.exe to generate a typed dataset from the XSD
| file.
|
| Now, my thinking is that using a typed data set is the easiest way to go
for
| use in a new app. I just add the typed dataset, and the rest is pretty
easy.
| But, of course, as soon as I realize something will be easy, it doesn't
| work!! XSD.exe creates a vb file that I added to a new app. then I dropped
a
| dataset on my form and selected the typed dataset, but I get an error
saying
| "Exception has been thrown by the target of an invocation". Not very
| descriptive!!
|
| Now, temporarily, forgetting the typed dataset, if I do a dataset.readxml,
I
| have to dynamically create each table and column and relationship that I
| want to see in a grid. If I add the XSD file to my project, how can I use
| the tables/columns/relationships defined in the XSD file? Or can I only do
| this with a typed dataset created from the XSD file?
|
| TIA,
| Lee
|
<<snip>>
Nov 21 '05 #12
Hi Jay,

Yep, that works! Quick question: I'm actually doing this project in 2003 and
2005 at the same time (just to see the differences. In 2005, if I
right-click on the XSD view, there isn't a "Generate Dataset" option.

Any ideas on how to proceed in 2005?

Thanks!

Lee

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:eH**************@TK2MSFTNGP14.phx.gbl...
Lee,
Rather then use XSD.exe to explicitly create the typed dataset, I would
simply add the .XSD itself (the one created by DataSet.WriteXmlSchema) to
my
project. I would then open the .XSD file, right click & select "Generate
DataSet".

This implicitly creates a typed dataset.

Hope this helps
Jay

"lgbjr" <lg***@online.nospam> wrote in message
news:ep**************@TK2MSFTNGP12.phx.gbl...
| Hi Jay,
|
| OK, so far, so good. Using your XSLT as a start, I added some more
| transforms (for things that where not included in the previous posts.
So,
| the XSLT works, I can read the resulting XML file (dataset.ReadXML), and
I
| can create an XSD file (dataset.WriteXmlSchema). As a test, I imported
the
| resulting Schema into Access, then imported the XML file (append data to
| exisiting tables) and everything looks good.
|
| After seeing that the results were good, I went back to my small
transform
| app and added a shell to XSD.exe to generate a typed dataset from the
XSD
| file.
|
| Now, my thinking is that using a typed data set is the easiest way to go
for
| use in a new app. I just add the typed dataset, and the rest is pretty
easy.
| But, of course, as soon as I realize something will be easy, it doesn't
| work!! XSD.exe creates a vb file that I added to a new app. then I
dropped
a
| dataset on my form and selected the typed dataset, but I get an error
saying
| "Exception has been thrown by the target of an invocation". Not very
| descriptive!!
|
| Now, temporarily, forgetting the typed dataset, if I do a
dataset.readxml,
I
| have to dynamically create each table and column and relationship that I
| want to see in a grid. If I add the XSD file to my project, how can I
use
| the tables/columns/relationships defined in the XSD file? Or can I only
do
| this with a typed dataset created from the XSD file?
|
| TIA,
| Lee
|
<<snip>>

Nov 21 '05 #13
HI Jay,

Actually I sent the last post a buick to quick. what I see in 2005 is that
the XSD file already looks like a dataset (meaning that when I view the XSD
file, the toolbox items that are available are listed under the heading of
"Dataset" and are items that one would add to a dataset, such as table
adapters, data tables, etc.). However, the project does not have a data
source. So, if I add a grid or some other control that I can bind to the
data, the datasource selection shows "None".

So, how do I get the XSD file in 2005 to show as a data source?

Thanks
Lee

"lgbjr" <lg***@online.nospam> wrote in message
news:en**************@TK2MSFTNGP12.phx.gbl...
Hi Jay,

Yep, that works! Quick question: I'm actually doing this project in 2003
and 2005 at the same time (just to see the differences. In 2005, if I
right-click on the XSD view, there isn't a "Generate Dataset" option.

Any ideas on how to proceed in 2005?

Thanks!

Lee

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:eH**************@TK2MSFTNGP14.phx.gbl...
Lee,
Rather then use XSD.exe to explicitly create the typed dataset, I would
simply add the .XSD itself (the one created by DataSet.WriteXmlSchema) to
my
project. I would then open the .XSD file, right click & select "Generate
DataSet".

This implicitly creates a typed dataset.

Hope this helps
Jay

"lgbjr" <lg***@online.nospam> wrote in message
news:ep**************@TK2MSFTNGP12.phx.gbl...
| Hi Jay,
|
| OK, so far, so good. Using your XSLT as a start, I added some more
| transforms (for things that where not included in the previous posts.
So,
| the XSLT works, I can read the resulting XML file (dataset.ReadXML),
and I
| can create an XSD file (dataset.WriteXmlSchema). As a test, I imported
the
| resulting Schema into Access, then imported the XML file (append data
to
| exisiting tables) and everything looks good.
|
| After seeing that the results were good, I went back to my small
transform
| app and added a shell to XSD.exe to generate a typed dataset from the
XSD
| file.
|
| Now, my thinking is that using a typed data set is the easiest way to
go
for
| use in a new app. I just add the typed dataset, and the rest is pretty
easy.
| But, of course, as soon as I realize something will be easy, it doesn't
| work!! XSD.exe creates a vb file that I added to a new app. then I
dropped
a
| dataset on my form and selected the typed dataset, but I get an error
saying
| "Exception has been thrown by the target of an invocation". Not very
| descriptive!!
|
| Now, temporarily, forgetting the typed dataset, if I do a
dataset.readxml,
I
| have to dynamically create each table and column and relationship that
I
| want to see in a grid. If I add the XSD file to my project, how can I
use
| the tables/columns/relationships defined in the XSD file? Or can I only
do
| this with a typed dataset created from the XSD file?
|
| TIA,
| Lee
|
<<snip>>


Nov 21 '05 #14
Hi

Since VS.NET 2005(Whidbey) has not been released, so far for Whidbey issue,
we have newsgroup about Whidbey.
microsoft.beta.whidbey.*

Thanks for your understanding!

If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #15
Lee,
You can ask 2005 specific questions at: http://forums.microsoft.com/msdn/

There was a post recently in microsoft.beta.whidbey.* that they are being
closed in favor of the above forums which IMHO is a mistake. Hopefully I
miss read the post...
My understanding is that both 2003 & 2005 using the msdata:IsDataSet
attribute (in the XSD itself) to identify the .xsd file as a "DataSet" or
not. I am not seeing an obvious way of setting that attribute.

The "Generate DataSet" command in 2003 actually sets the Custom Tool in the
properties for the file itself (select the file in Solution Explorer & look
at its properties).

You may want to ask in the above 2005 forums on how to add the dataset as a
datasource...

Hope this helps
Jay
"lgbjr" <lg***@online.nospam> wrote in message
news:uQ****************@TK2MSFTNGP12.phx.gbl...
| HI Jay,
|
| Actually I sent the last post a buick to quick. what I see in 2005 is that
| the XSD file already looks like a dataset (meaning that when I view the
XSD
| file, the toolbox items that are available are listed under the heading of
| "Dataset" and are items that one would add to a dataset, such as table
| adapters, data tables, etc.). However, the project does not have a data
| source. So, if I add a grid or some other control that I can bind to the
| data, the datasource selection shows "None".
|
| So, how do I get the XSD file in 2005 to show as a data source?
|
| Thanks
| Lee
|
| "lgbjr" <lg***@online.nospam> wrote in message
| news:en**************@TK2MSFTNGP12.phx.gbl...
| > Hi Jay,
| >
| > Yep, that works! Quick question: I'm actually doing this project in 2003
| > and 2005 at the same time (just to see the differences. In 2005, if I
| > right-click on the XSD view, there isn't a "Generate Dataset" option.
| >
| > Any ideas on how to proceed in 2005?
| >
| > Thanks!
| >
| > Lee
| >
| > "Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in
message
| > news:eH**************@TK2MSFTNGP14.phx.gbl...
| >> Lee,
| >> Rather then use XSD.exe to explicitly create the typed dataset, I would
| >> simply add the .XSD itself (the one created by DataSet.WriteXmlSchema)
to
| >> my
| >> project. I would then open the .XSD file, right click & select
"Generate
| >> DataSet".
| >>
| >> This implicitly creates a typed dataset.
| >>
| >> Hope this helps
| >> Jay
| >>
<< snip >>
Nov 21 '05 #16
Hi Jay and Peter,

Yeah, I know about the Whidbey groups and AFAIK they are switching to the
forums, which I agree, is a mistake. I was just being lazy.

However, I did figure out the problem (as a workaround). If I add a new
dataset to the project, open the XSD file that was created with
DS.WriteXmlSchema, then copy/paste the contents into the new dataset, the
new dataset works as it should.

Regards,

Lee
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:Oi**************@TK2MSFTNGP10.phx.gbl...
Lee,
You can ask 2005 specific questions at: http://forums.microsoft.com/msdn/

There was a post recently in microsoft.beta.whidbey.* that they are being
closed in favor of the above forums which IMHO is a mistake. Hopefully I
miss read the post...
My understanding is that both 2003 & 2005 using the msdata:IsDataSet
attribute (in the XSD itself) to identify the .xsd file as a "DataSet" or
not. I am not seeing an obvious way of setting that attribute.

The "Generate DataSet" command in 2003 actually sets the Custom Tool in
the
properties for the file itself (select the file in Solution Explorer &
look
at its properties).

You may want to ask in the above 2005 forums on how to add the dataset as
a
datasource...

Hope this helps
Jay
"lgbjr" <lg***@online.nospam> wrote in message
news:uQ****************@TK2MSFTNGP12.phx.gbl...
| HI Jay,
|
| Actually I sent the last post a buick to quick. what I see in 2005 is
that
| the XSD file already looks like a dataset (meaning that when I view the
XSD
| file, the toolbox items that are available are listed under the heading
of
| "Dataset" and are items that one would add to a dataset, such as table
| adapters, data tables, etc.). However, the project does not have a data
| source. So, if I add a grid or some other control that I can bind to the
| data, the datasource selection shows "None".
|
| So, how do I get the XSD file in 2005 to show as a data source?
|
| Thanks
| Lee
|
| "lgbjr" <lg***@online.nospam> wrote in message
| news:en**************@TK2MSFTNGP12.phx.gbl...
| > Hi Jay,
| >
| > Yep, that works! Quick question: I'm actually doing this project in
2003
| > and 2005 at the same time (just to see the differences. In 2005, if I
| > right-click on the XSD view, there isn't a "Generate Dataset" option.
| >
| > Any ideas on how to proceed in 2005?
| >
| > Thanks!
| >
| > Lee
| >
| > "Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in
message
| > news:eH**************@TK2MSFTNGP14.phx.gbl...
| >> Lee,
| >> Rather then use XSD.exe to explicitly create the typed dataset, I
would
| >> simply add the .XSD itself (the one created by
DataSet.WriteXmlSchema)
to
| >> my
| >> project. I would then open the .XSD file, right click & select
"Generate
| >> DataSet".
| >>
| >> This implicitly creates a typed dataset.
| >>
| >> Hope this helps
| >> Jay
| >>
<< snip >>

Nov 21 '05 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Alpha | last post by:
I have a small Window application and through out the different forms I create a different dataset. At the begining I used the Tools to drag and drop the SqlDataAdapter, connection and dataset...
9
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got...
0
by: S.Tedeschi | last post by:
Hi all; as posted some days ago, I'm converting an on-line app; I used to heavily rely on strongly-typed DataSets directly dropped onto pages, and so viewed by code(-behind) as well. In the next...
12
by: BillE | last post by:
I'm trying to decide if it is better to use typed datasets or business objects, so I would appreciate any thoughts from someone with more experience. When I use a business object to populate a...
9
by: gardnern | last post by:
We have X number of data sets, of Y length each. For example... Small, Medium, Large and Red, Green, Blue, Yellow We need to generate a list of all possibilities Small Red
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.