• 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!
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.

Previously on "Creating XSD from XML data"

Collapse

  • jim2406
    replied
    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..

    Leave a comment:


  • DimPrawn
    replied
    Originally posted by jim2406
    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
    About as useful as a chocolate teapot unless you happen to want a typed dataset schema!

    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:


  • madhippy
    replied
    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:


  • jim2406
    replied
    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:


  • Hedgehog
    replied
    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:


  • thunderlizard
    replied
    .NET can do it. At least it claims to. Never tried it in anger.

    Leave a comment:


  • ChimpMaster
    replied
    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:


  • scotspine
    replied
    he mentioned using it as a starting point, nothing more...

    Leave a comment:


  • DimPrawn
    replied
    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:


  • scotspine
    replied
    xml>create schema>generate new w3c schema

    Leave a comment:


  • ChimpMaster
    replied
    Originally posted by scotspine
    xmlpad
    Looks like you can create the DTD from the XMlL, but there's no mention of the XSD.

    I'll take a look in more detail - thanks.

    Leave a comment:


  • scotspine
    replied
    xmlpad

    Leave a comment:


  • ChimpMaster
    replied
    Originally posted by Spacecadet
    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

    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:


  • Spacecadet
    replied
    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:


  • ChimpMaster
    started a topic Creating XSD from XML data

    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!
Working...
X