|
-
Jul 7th, 2004, 03:00 PM
#1
Thread Starter
PowerPoster
If you work with XML...
If you are working with XML in your application, you need to know about the xsd.exe tool. I just starting to use the tool, and am in love with it. It comes with your VS.Net install, so no files to download.
I have taken 10 XSD documents, and created classes that I can use programmically. When I am done, I can serialize the classes and bam, I am assured that they match the schema. It is perfect.
I can see lots of uses for this tool, so I thought I would let others know about it. I knew it was there, just didn't realize the power until that little lightbulb went off in my head yesterday!
http://msdn.microsoft.com/library/de...ToolXsdexe.asp
-
Jul 18th, 2004, 12:07 PM
#2
Lively Member
I want to add a tip for help also: Anybody facing some problems with identifying elements in a normal dataset can use this tool for creating Strongly Typed DataSets.
Do you think my life is easy?
Do you think it's good to win?
do you think it's nice to kill?
Do you think learning is a must?
Do you think computers are nothing?
Do you think this post is stupid?
Do ypu think we're really humen?
DO YOU THINK IT'S GOOD TO THINK AT ALL? ? ? ! ! !
-
Aug 8th, 2004, 02:55 PM
#3
Frenzied Member
Im about to start a project where I want to use strongly typed datasets and XML.
Basically it's a simple asp.net app that will use all the latest stuff we have learned in our company, OO, n-tier, patterns etc. It is a simple maintanence app where you can do CRUD stuff.
The database is SQL server and is already designed by our db department, and they have mailed me the schema file. It's a simple database with about 12 tables with various joins and keys.
Now I want to use their design to build my OO model with classes and strongly typed datasets. Somehow I want to make some use of the existing db model and map that to my business logic and db layer.
Why do I want to use this? Well, if I list all products, then select one product from the list, there is a "save info to file" button. When I click that I want to serialize an xml file based on the info that is present in the UI... without any boring manual coding... the info should already be available to me in the typed dataset which the datagrid is bound to...
As I understand it I have two choices when it comes to designing the business logic, either write custom classes(like we have done before) and make them serializable, OR make typed datasets instead.
All I need are some good advice and a few pointers, and then I can take it from there...
ps I really want to show off how we can benefit from xml and typed datasets and how the db department and the programmers can work more closely together... ds
Kind regards
Henrik
-
Sep 2nd, 2004, 03:15 AM
#4
Fanatic Member
I have toiled with the same question for ages now.
either write custom classes
or .
The conclusion I have come to is:
If the classes are doing more than just CRUD (i.e. complex calculations, relationship management and object manipulation), and the system demands better interaction (e.g. enterprise event messaging), then I use a custom class. Otherwise I use datasets.
With the functionality built into datasets, you can get away with just using datasets. However, I think it is important to make them typed using an xsd, and as a programmer/architect/engineer, ALWAYS treet them as if they were your custom class. In your mind, you should see that typed dataset as your custom class. I have seen designs go to s**t when developers loose sight of their objects. Anyway, thats just the way I like to think of it to keep my mind clear about what is what.
So, back to your problem,
I think you can just use a typed dataset for your CRUD operations and serialize them using an xml formatter.
Please can you inform us of the route you decided to follow, and of course, a success rating... It would be interesting to hear what others thought of this problem, and i'm sure, there are plenty of people who have been there.
-
Sep 2nd, 2004, 03:18 AM
#5
Fanatic Member
Here is another helpful commandline tool downloadable from Microsoft website:
msxsl.exe
You can do xml transformations from the commandline using this tool. I have found it very helpful!
Of course, you can write your own in a couple of minutes, but why reinvent the wheel?
-
Sep 2nd, 2004, 03:38 AM
#6
Frenzied Member
The problem Im facing is that if I have 40 methods in my DAL, 35 of them are special operations with HUGE sql querys performing 3-4 joins... how can I use typed datasets with them? Of course if you read only one table, then it is easy to perform cruds using the dataadapter.. but what if you need to update 6 tables at a time, just because you fetched data from 6 tables to get the correct relationships???? Then I use custom classes and custom DAL methods... because often in the projects I worked wit the data model is so complex and relations are all over the place. The concepts are so very abstract it is hard to understand it using typed datasets...
I think the customer->person->salespoint->item etc etc only exist in the textbook.. such simple applications cannot be found in real life. I have tried... Just as an example, what if you want to update a field from this select query:
VB Code:
ELECT dbo.gq64_order_head.internal_order_no, dbo.gq64_order_head.part_no, dbo.gq64_order_head.denomination_swe,
CASE WHEN dbo.gq56_work_center.work_center_denom_gps IS NULL
THEN dbo.gq65_order_operation.work_center ELSE dbo.gq56_work_center.work_center_denom_gps END AS work_center,
dbo.gq65_order_operation.part_no_core, dbo.gq53_core.prel_denomination,
CASE WHEN dbo.gq65_order_operation.operation_prio < 999 THEN dbo.gq65_order_operation.operation_prio ELSE dbo.gq64_order_head.planned_prio
END AS prio
FROM dbo.gq65_order_operation INNER JOIN
dbo.gq64_order_head ON dbo.gq65_order_operation.part_no = dbo.gq64_order_head.part_no AND
dbo.gq65_order_operation.internal_order_no = dbo.gq64_order_head.internal_order_no INNER JOIN
dbo.gq56_work_center ON dbo.gq65_order_operation.work_center = dbo.gq56_work_center.work_center INNER JOIN
dbo.gq53_core ON dbo.gq65_order_operation.part_no_core = dbo.gq53_core.part_no_core
WHERE (dbo.gq65_order_operation.operation_no = @OpNo) AND (dbo.gq64_order_head.internal_order_no = @OrderNo) AND
(dbo.gq64_order_head.part_no = @PartNo)
as you can see this is a normal sql query I work with... and how do you apply this into a datatable.. and an even more important question, how does the dataadapter generate updates, inserts and deletes???? that is the functionality I want!!!
kind regards
henrik
-
Sep 2nd, 2004, 04:16 AM
#7
Fanatic Member
Firstly, place this in a new thread! You will get more answers that way.
-
Sep 2nd, 2004, 04:19 AM
#8
Fanatic Member
-
Apr 19th, 2008, 12:34 PM
#9
Frenzied Member
Re: If you work with XML...
Hi shunt:
Sory return to your post,but i need some help here with schemas...
I have a Schema.xsl that I want to convert to a .xml file...
In this moment I have the reference in my code:
Code:
Imports System.Xml
Imports System.Xml.Schema
Can you post some code to exemplified the way to do this?
Thanks
-
Apr 20th, 2008, 08:49 AM
#10
Fanatic Member
Re: If you work with XML...
Hi, I don't think I fully understand your requirement. An XML Schema is XML. You can load a schema file directly into an XMLDocument object. Also, if you have an .XSL file you can simply rename the file to .XML.
Open the xsl file with IE or notepad and you will see that it is an XML file.
Perhaps you actually want to generate an XML file from an XSL file?
-
Apr 20th, 2008, 12:10 PM
#11
Frenzied Member
Re: If you work with XML...
Hi:
Perhaps you actually want to generate an XML file from an XSL file?
Yes that's it...but I don't know the way to do this programatically...I need some help with a few lines of code if you have ok?
Thanks
-
Apr 20th, 2008, 12:32 PM
#12
Fanatic Member
Re: If you work with XML...
Sorry. Firstly I made a mistake. A schema file has a file extension ".xsd". A template file has a file extension ".xsl".
An XSD (schema) describes the layout of an XML file. An XSL (template) transforms one xml file from one format to another.
I see you said "Schema.xsl", so for clarrity, do you have a schema or a template?
-
Apr 20th, 2008, 12:41 PM
#13
Frenzied Member
Re: If you work with XML...
Sory...I Have a .XSD(schema) file
-
Apr 20th, 2008, 03:58 PM
#14
Fanatic Member
Re: If you work with XML...
Okay... A schema file simply defines what the XML must conform to. Unfortunately, there is no magic "generate" function that will generate all the nodes required by your XSD. The good news is that an XSD is essentially the same as the dictionary of a database. It describes a set of tables and a set of attributes. I have never tried to use an XSD to generate XML before, but if I was to try, I would start by using an ADO.NET dataset object. Create a dataset object and then try using the ReadXMLSchema function. This should initialize the table objects in the dataset and you can then populate tables using standard ADO.NET methods. Then when you want to generate the XML just use WriteXml or GetXml functions.
Just google "dataset ReadXmlSchema" for examples
-
Apr 20th, 2008, 06:07 PM
#15
Frenzied Member
Re: If you work with XML...
ok...I will try your suggestion
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|