Cannot load schema to dataset

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I'm trying to read an XML schema into a dataset and it fails. I tried both
ways, importing it into VS.NET and then generating dataset there, or using
dataset.readxmlschema("Filename.xsd") method. Both complain about the same
thing, undefined data type : 'monetaryAmount'

The schema itself is a well published schema of the Finnish Finvoice
(electronic invoce) definition. It is quite large and it can be found here

http://www.pankkiyhdistys.fi/verkkolasku/Finvoice.xsd

Any ideas ?

Petri
 
Hi Petri:

There's a lot in that schema that a dataset isn't going to like. ReadXml is
only guaranteed to work if it's from XML generated from a dataset and if you
look at all the complex types in there, it's stuff that is totally valid but
not what a dataset normally does.

If you look at this code
static void Main(string[] args)

{

DataSet ds = new DataSet();

FileStream fs = new FileStream(@"C:\Finvoice.xsd", FileMode.Open );

XmlSchema finvoiceSchema = XmlSchema.Read(fs, new
ValidationEventHandler(ShowErrors));

XmlDocument xml = new XmlDocument();

xml.Schemas.Add(finvoiceSchema);

}

private static void ShowErrors(Object sender, ValidationEventArgs e){

Console.WriteLine("Validation Error: {0}", e.Message);

}



It will read in the schema for you. You can use XSLT if you'd want and
create dataset out of it but that's a very intricate schema and it'll be a
good bit of work.

Cheers,


Bill
 
Bummer ...

Of course what I really really want to do, is to generate these electronic
invoices, that's XML and if you look at an example they don't seem too
complicated.

Example can be found here (it's linked to an xsl so you need to look at the
source)
http://www.pankkiyhdistys.fi/verkkolasku/Finvoice_peruslasku.xml

I thought that I simply create a corresponding dataset from the schema they
provide and that's it. But apparently not...

How would I accomplish this, if a dataset is not an answer.

Petri

W.G. Ryan - MVP said:
Hi Petri:

There's a lot in that schema that a dataset isn't going to like. ReadXml is
only guaranteed to work if it's from XML generated from a dataset and if you
look at all the complex types in there, it's stuff that is totally valid but
not what a dataset normally does.

If you look at this code
static void Main(string[] args)

{

DataSet ds = new DataSet();

FileStream fs = new FileStream(@"C:\Finvoice.xsd", FileMode.Open );

XmlSchema finvoiceSchema = XmlSchema.Read(fs, new
ValidationEventHandler(ShowErrors));

XmlDocument xml = new XmlDocument();

xml.Schemas.Add(finvoiceSchema);

}

private static void ShowErrors(Object sender, ValidationEventArgs e){

Console.WriteLine("Validation Error: {0}", e.Message);

}



It will read in the schema for you. You can use XSLT if you'd want and
create dataset out of it but that's a very intricate schema and it'll be a
good bit of work.

Cheers,


Bill

Petri said:
Hi,

I'm trying to read an XML schema into a dataset and it fails. I tried both
ways, importing it into VS.NET and then generating dataset there, or using
dataset.readxmlschema("Filename.xsd") method. Both complain about the same
thing, undefined data type : 'monetaryAmount'

The schema itself is a well published schema of the Finnish Finvoice
(electronic invoce) definition. It is quite large and it can be found here

http://www.pankkiyhdistys.fi/verkkolasku/Finvoice.xsd

Any ideas ?

Petri
 
Petri said:
Bummer ...

Of course what I really really want to do, is to generate these electronic
invoices, that's XML and if you look at an example they don't seem too
complicated.

Example can be found here (it's linked to an xsl so you need to look at
the
source)
http://www.pankkiyhdistys.fi/verkkolasku/Finvoice_peruslasku.xml
--Yah, this was a *very* cool example - i was quite impressed.
I thought that I simply create a corresponding dataset from the schema
they
provide and that's it. But apparently not...
--In many cases you can, but the more complex stuff is the less likely it
will work.
How would I accomplish this, if a dataset is not an answer.
XmlDocument or an XmlDataDocument. Add the Schema and just add the values.
Petri

W.G. Ryan - MVP said:
Hi Petri:

There's a lot in that schema that a dataset isn't going to like. ReadXml
is
only guaranteed to work if it's from XML generated from a dataset and if
you
look at all the complex types in there, it's stuff that is totally valid
but
not what a dataset normally does.

If you look at this code
static void Main(string[] args)

{

DataSet ds = new DataSet();

FileStream fs = new FileStream(@"C:\Finvoice.xsd", FileMode.Open );

XmlSchema finvoiceSchema = XmlSchema.Read(fs, new
ValidationEventHandler(ShowErrors));

XmlDocument xml = new XmlDocument();

xml.Schemas.Add(finvoiceSchema);

}

private static void ShowErrors(Object sender, ValidationEventArgs e){

Console.WriteLine("Validation Error: {0}", e.Message);

}



It will read in the schema for you. You can use XSLT if you'd want and
create dataset out of it but that's a very intricate schema and it'll be
a
good bit of work.

Cheers,


Bill

Petri said:
Hi,

I'm trying to read an XML schema into a dataset and it fails. I tried
both
ways, importing it into VS.NET and then generating dataset there, or
using
dataset.readxmlschema("Filename.xsd") method. Both complain about the
same
thing, undefined data type : 'monetaryAmount'

The schema itself is a well published schema of the Finnish Finvoice
(electronic invoce) definition. It is quite large and it can be found
here

http://www.pankkiyhdistys.fi/verkkolasku/Finvoice.xsd

Any ideas ?

Petri
 
W.G. Ryan - MVP said:
XmlDocument or an XmlDataDocument. Add the Schema and just add the values.

I must confess, that I'm a bit of a newbie on this subject (pretty
confortable with Datasets though). Can you give a brief example on how to do
that. I tried the example you provided in the previous post (in VB though)
but in my case XmlDocument doesn't seem to have a Schemas.Add method (I'm in
..net 1.1)

I managed to read the schema into an XmlSchema object, but then what ?
Apparently I need to create an xmlDocument based on that schema but I cannot
find any pointers on how to do that.
 
Petri:

Sorry for not getting back sooner. It's kind of involved answer so let me
get back to you. Can you shoot me your email - mine is WilliamRyan At
Gmail Dotcom
 
Back
Top