The strongly typed dataset was a requirement (not dictated by myself) to make a specific region of code easier to maintain.
I wasn't arguing the merits (or otherwise) of the question posted by the original poster I was just offering a solution..
- Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
- Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
Reply to: Creating XSD from XML data
Collapse
You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:
- You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
- You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
- If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.
Logging in...
Previously on "Creating XSD from XML data"
Collapse
-
About as useful as a chocolate teapot unless you happen to want a typed dataset schema!Originally posted by jim2406vb.net code to do it
Dim doc As New XmlDocument
Dim sr As New System.IO.StreamReader("C:\foo.xml")
Dim xmlS As String = sr.ReadToEnd
sr.Close()
doc.LoadXml(xmlS)
Dim ds As DataSet = New DataSet
ds.ReadXml("C:\foo.xml")
ds.WriteXmlSchema("C:\foo.xsd")
works fine but obviously the XSD isnt the most useful thing in the world. i did it the other day as i wanted to generate a strongly typed dataset from some XML in a spec (no XSD provided)
HTH
Really, a million schemas can represent one XML document. The best xsd tool is the human brain. It ain't hard, and it is much more likely to represent an intelligent schema representation of the XML document (assuming you know something about what the XML means and is to be used for), than these tools.
Leave a comment:
-
no one mentioned the xsd tool ?
xsd/?
Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 2.0.50727.42]
Copyright (C) Microsoft Corporation. All rights reserved.
xsd.exe -
Utility to generate schema or class files from given source.
xsd.exe <schema>.xsd /classes|dataset [/e:] [/l:] [/n:] [/o:] [/s] [/uri:]
xsd.exe <assembly>.dll|.exe [/outputdir:] [/type: [...]]
xsd.exe <instance>.xml [/outputdir:]
xsd.exe <schema>.xdr [/outputdir:]
Leave a comment:
-
vb.net code to do it
Dim doc As New XmlDocument
Dim sr As New System.IO.StreamReader("C:\foo.xml")
Dim xmlS As String = sr.ReadToEnd
sr.Close()
doc.LoadXml(xmlS)
Dim ds As DataSet = New DataSet
ds.ReadXml("C:\foo.xml")
ds.WriteXmlSchema("C:\foo.xsd")
works fine but obviously the XSD isnt the most useful thing in the world. i did it the other day as i wanted to generate a strongly typed dataset from some XML in a spec (no XSD provided)
HTH
Leave a comment:
-
XSD can be generated from XML using MS XML Schema Generation Tool.
See the following link
http://msdn2.microsoft.com/en-us/lib...0s(vs.80).aspx
Leave a comment:
-
.NET can do it. At least it claims to. Never tried it in anger.
Leave a comment:
-
Yep that's right, just a starting point -- and God knows if they only want it for "documentational" purposes, i.e. never to be seen again!
Thanks again.
Leave a comment:
-
How can you ever expect the XSD produced to be useful?
Optional elements and attributes, field lengths, patterns (regex), sequence, unions, referenced types, namespaces, and lots and lots more are in the XSD that can never be "inferred" by one or more XML instances.
Madness.
Leave a comment:
-
Looks like you can create the DTD from the XMlL, but there's no mention of the XSD.Originally posted by scotspinexmlpad
I'll take a look in more detail - thanks.
Leave a comment:
-
Originally posted by Spacecadetwhy do you want to create it automatically
IMO you'll find less problems doing it yourself based on a spec than hoping that the XML file your trying to base it on contains all the correct data
Yep I agree, in fact that is what I suggested -- it's for another team here.
They just want to use the data to create the bulk of the structure, and fill in the blanks so to say.
Leave a comment:
-
why do you want to create it automatically
IMO you'll find less problems doing it yourself based on a spec than hoping that the XML file your trying to base it on contains all the correct data
Leave a comment:
-
Creating XSD from XML data
Anyone know how to do this? Is it possible in XML Spy?
I know there can be issues, such as incomplete XML data, but anything would help....
Thanks in advance!Tags: None
- Home
- News & Features
- First Timers
- IR35 / S660 / BN66
- Employee Benefit Trusts
- Agency Workers Regulations
- MSC Legislation
- Limited Companies
- Dividends
- Umbrella Company
- VAT / Flat Rate VAT
- Job News & Guides
- Money News & Guides
- Guide to Contracts
- Successful Contracting
- Contracting Overseas
- Contractor Calculators
- MVL
- Contractor Expenses
Advertisers

Leave a comment: