newbie: using xsd.exe

D

deko

I've seen the examples on msdn, but still having trouble with xsd.exe

What I want to do: use the command line to create a typed dataset .dll that I
can add to my VS05 project

I assume all I need to do is run these two commands:

xsd.exe /d /l:CS myschema.xsd
csc.exe /t:library myschema.cs /r:System.dll /r:System.Data.dll

And then just add the .dll to my project. Is this correct?

So I opened an XP command prompt window and navigated to the directory in which
the current schema file is located.

I tried this:

xsd.exe /d /l:CS myschema.xsd

but no luck

Error:

'xsd.exe' is not recognized as an internal or external command,
operable program or batch file.

I also tried it from the .NET command window and got this error:

Command "xsd.exe" is not valid.

Is there something wrong with my installation - like xsd is not installed? Or
am I going about this the wrong way?

Thanks in advance.
 
D

deko

Figured it out.

Here's instructions for anyone else that may cross this path.

First, add these two paths to your System Path Environment variable:

C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727

(or whatever they are in your installation)

Then run these 2 commands in an XP command window, in the directory where the
schema is:

1) xsd.exe /d /l:CS myschema.xsd

Output:

Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 2.0.50727.42]
Copyright (C) Microsoft Corporation. All rights reserved.
Writing file 'C:\Documents and Settings\Administrator\My Documents\Visual Studio
2005\Projects\... myschema.cs'.

2) csc.exe /t:library myschema.cs /r:System.dll /r:System.Data.dll

Output:

Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.42
for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
Copyright (C) Microsoft Corporation 2001-2005. All rights reserved.

and behold, you have a database in a dll

Then move the dll to the folder that houses the project that you want this dll
to be a part of (e.g. MyProject_DAL), and add a reference to it.

done
 
J

John Sitka

hopefully it will get a high level contribution.
Still trying to figure out where XML fits into my life, and I'm looking for clues.
 
D

deko

Still trying to figure out where XML fits into my life, and I'm looking for

I've got a small amount of relational data. I could create the database (6
tables with relations and constraints) in Access in about 5 minutes. 4 if I
type with both hands.

I don't want my users to even know what Access is so I've created the database
using an ADO.NET DataSet as the RDBMS and XML for data storage. It's not that
difficult to do. Just create the DataSet structures with code, host the DataSet
as a property in an instance of a singleton class, and serialize/deserialize to
XML with 3 lines of code (a .NET 2.0 bonus is being able to serialize to binary
xml).

The major pain in the neck is performing CRUD operations - like trying to
replicate a SQL nested join. A precompiled (or "typed") DataSet will relieve
that pain considerably. LINQ is supposed to erase it almost completely. But I
don't want to wait for C# 3.0.

There's ample documentation for the singleton pattern, xsd.exe, XML
serialization, and all the idiosyncrasies of the DataSet. Getting everything to
work together is something I've had to figure out on my own.
 
J

John Sitka

Awesome explaination.
I would sure like to see someone demonstrate and explain
this idea to me one day; but whenever I try to "see" it on my own
it just dosen't register.
I don't want my users to even know what Access is

so you are using an XML file that they can open with notepad instead....
OR
The datastore is offsite but somehow your users are going to read your code
and know what that datastore is.
DataSet as the RDBMS.

This seems like bringing a knife to a gunfight
The major pain in the neck is performing CRUD operations - like trying to replicate a SQL nested join.

Other than a trivial applications are their any other kind.


Believe me when I say I'm not being a smartass about this, just trying for some lightbulbs
to go on when I thump the forehead and say to myself "I could/should use XML for this"
I have used it to pass some small selection sets or configurations around inside applications.
Maybe that's cool, but the one thing that DOES really make sense to me WRT XML
is schema's across industries Like STEP ap203 in the design world. That makes sense
as an interop file but still the schema has to be relatively standard for it to be valuable which is why
ISO gets involved. Anyways any XSD info could just as easily be sitting on a RDBMS server
somewhere and when you fire up your CAD station, query the schema from the Database server
and put it in memory.

( the what if you aren't connected arguement, we need to carry the data definition around with us in a durable state,
yeah right those days are gone; connectivity is only gonna get cheaper, more durable, redundant and farther reaching.)
singleton class, and serialize/deserialize to XML with 3 lines of code (a .NET 2.0 bonus is being able to serialize to binary
xml).

Woo hoo, and store it in SQL!
One server one table one column. That's gonna scale.

All in good fun deko,
I just feel like I'm missing a big chunk of my eyeballs when the "XML as database" vision
is put forth and I can't see it.

You know that game.
"I'm going camping and I'm bringing apples. What are you gonna bring?"
That's what it feels like.
 
D

deko

I would sure like to see someone demonstrate and explain
this idea to me one day; but whenever I try to "see" it on my own
it just dosen't register.

I'll post my code on a .NET community site, perhaps codeproject.com - when I get
the bugs worked out :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top