XSD Class Generation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • SevDer

    #1

    XSD Class Generation

    Hi,

    Can someone tell me how to generate classes from XSD files?
    Is there an easy way to convert it into typed datasets etc?

    Or any other suggestion is welcomed.

    --

    SevDer

  • Cor Ligthert[MVP]

    #2
    Re: XSD Class Generation

    SevDer

    Click right on your mouse on the surface in the IDE where the not XML
    presentation of the XSD is located and choose generate dataset.

    Cor

    "SevDer" <sevder@newsgro up.nospamschree f in bericht
    news:uPVmZkS5HH A.3400@TK2MSFTN GP03.phx.gbl...
    Hi,
    >
    Can someone tell me how to generate classes from XSD files?
    Is there an easy way to convert it into typed datasets etc?
    >
    Or any other suggestion is welcomed.
    >
    --
    >
    SevDer
    http://www.sevder.com

    Comment

    • Marc Gravell

      #3
      Re: XSD Class Generation

      xsd.exe (for example, at a VS2005 command prompt)

      e.g.

      xsd my.xsd /classes /enableDataBindi ng
      xsd my.xsd /dataset
      xsd /?

      Marc

      Comment

      • Steven Cheng[MSFT]

        #4
        RE: XSD Class Generation

        Hi SevDer,

        As Cor has suggested, you can use Visual Studio's built-in DataSet
        generation feature to generate a typedDataset from a given xsd file.
        However, in VS 2005, the supported approach is different from VS 2003(no
        "generate dataset" command is available). Here is how to generate the
        dataset from an xsd file in 2005:
        >>>>>>>>
        1. Select the xsd file in the solution explorer
        2. At the Property Grid (F4) find the CustomTool property and type
        MSDataSetGenera tor
        The typed dataset will be generated for you.
        <<<<<<<<<

        Also, you can use the .net framework sdk's built-in xsd.exe utility to
        generate custom classes from a given xsd file in commandline. This tool
        support generating both normal classes and DataSet classes:

        #XML Schema Definition Tool (Xsd.exe)
        http://msdn2.microsoft.com/en-us/lib...0s(VS.71).aspx

        Hope this also helps.

        Sincerely,

        Steven Cheng

        Microsoft MSDN Online Support Lead


        This posting is provided "AS IS" with no warranties, and confers no rights.





        Comment

        • =?Utf-8?B?WWFyb24gS2Fybmk=?=

          #5
          RE: XSD Class Generation

          check XSDObjectGen.ms i for .net 1.0 also have a look at :


          --
          Sincerely
          Yaron Karni
          All .net c# stuff, patterns code and snippet help programmer.



          "SevDer" wrote:
          Hi,
          >
          Can someone tell me how to generate classes from XSD files?
          Is there an easy way to convert it into typed datasets etc?
          >
          Or any other suggestion is welcomed.
          >
          --
          >
          SevDer

          >

          Comment

          • Barney

            #6
            Re: XSD Class Generation

            You, Sir, are a genius. I have spent soooo long trying to "fix" the
            problem where the designer.cs files weren't being updated when I
            edited my datasets. This got to the point where I ended up migrating
            new and changed dataadapters to a whole new project. I've just tested
            the MSDataSetGenera tor option above, and it works!!! I looked at the
            newer projects, and found they have this property set by default,
            whereas the old ones did not - hence why they weren't regenerating.

            I seriously owe you one - i figured this was a bug or something with
            VS, and I've been ignored in the newsgroups when asking about it.
            Many, many thanks.

            Ship.


            On Aug 23, 6:12 am, stch...@online. microsoft.com (Steven Cheng[MSFT])
            wrote:
            Hi SevDer,
            >
            As Cor has suggested, you can use Visual Studio's built-in DataSet
            generation feature to generate a typedDataset from a given xsd file.
            However, in VS 2005, the supported approach is different from VS 2003(no
            "generate dataset" command is available). Here is how to generate the
            dataset from an xsd file in 2005:
            >
            >
            >
            1. Select the xsd file in the solution explorer
            2. At the Property Grid (F4) find the CustomTool property and type
            MSDataSetGenera tor
            The typed dataset will be generated for you.
            <<<<<<<<<
            >
            Also, you can use the .net framework sdk's built-in xsd.exe utility to
            generate custom classes from a given xsd file in commandline. This tool
            support generating both normal classes and DataSet classes:
            >
            #XML Schema Definition Tool (Xsd.exe)http://msdn2.microsoft.com/en-us/lib...0s(VS.71).aspx
            >
            Hope this also helps.
            >
            Sincerely,
            >
            Steven Cheng
            >
            Microsoft MSDN Online Support Lead
            >
            This posting is provided "AS IS" with no warranties, and confers no rights.

            Comment

            • SevDer

              #7
              Re: XSD Class Generation

              Hello Yaron,

              This is also a great tool.
              However I still have the same problem.
              The problem I am experiencing is, my xsd files are including other xsd files
              and as a result when converting, they are unable to find certain types which
              are included in the include xsd files.
              I think those tools do not work with included xsds

              --

              Sevket Seyalioglu
              CTO

              "Yaron Karni" <yaron.karni@gm ail.comwrote in message
              news:17267F9A-17C3-411E-A898-C3ADE257971D@mi crosoft.com...
              check XSDObjectGen.ms i for .net 1.0 also have a look at :

              >
              --
              Sincerely
              Yaron Karni
              All .net c# stuff, patterns code and snippet help programmer.

              >
              >
              "SevDer" wrote:
              >
              >Hi,
              >>
              >Can someone tell me how to generate classes from XSD files?
              >Is there an easy way to convert it into typed datasets etc?
              >>
              >Or any other suggestion is welcomed.
              >>
              >--
              >>
              >SevDer
              >http://www.sevder.com
              >>

              Comment

              • =?Utf-8?B?WWFyb24gS2Fybmk=?=

                #8
                Re: XSD Class Generation

                i already worked with xsd with reference (using the XSDObjectGen app), so it
                seems very strange.
                --
                Sincerely
                Yaron Karni
                All .net c# stuff, patterns code and snippet help programmer.



                "SevDer" wrote:
                Hello Yaron,
                >
                This is also a great tool.
                However I still have the same problem.
                The problem I am experiencing is, my xsd files are including other xsd files
                and as a result when converting, they are unable to find certain types which
                are included in the include xsd files.
                I think those tools do not work with included xsds
                >
                --
                >
                Sevket Seyalioglu
                CTO

                "Yaron Karni" <yaron.karni@gm ail.comwrote in message
                news:17267F9A-17C3-411E-A898-C3ADE257971D@mi crosoft.com...
                check XSDObjectGen.ms i for .net 1.0 also have a look at :


                --
                Sincerely
                Yaron Karni
                All .net c# stuff, patterns code and snippet help programmer.



                "SevDer" wrote:
                Hi,
                >
                Can someone tell me how to generate classes from XSD files?
                Is there an easy way to convert it into typed datasets etc?
                >
                Or any other suggestion is welcomed.
                >
                --
                >
                SevDer

                >
                >
                >

                Comment

                • SevDer

                  #9
                  Re: XSD Class Generation

                  I managed to work with it by combining included xsd.

                  Actually the included XSD also includes another one and I think thats where
                  I fail.

                  --

                  Sevket Seyalioglu
                  CTO

                  "Yaron Karni" <yaron.karni@gm ail.comwrote in message
                  news:88A2E09D-70B6-4182-B136-E56190A813C1@mi crosoft.com...
                  >i already worked with xsd with reference (using the XSDObjectGen app), so
                  >it
                  seems very strange.
                  --
                  Sincerely
                  Yaron Karni
                  All .net c# stuff, patterns code and snippet help programmer.

                  >
                  >
                  "SevDer" wrote:
                  >
                  >Hello Yaron,
                  >>
                  >This is also a great tool.
                  >However I still have the same problem.
                  >The problem I am experiencing is, my xsd files are including other xsd
                  >files
                  >and as a result when converting, they are unable to find certain types
                  >which
                  >are included in the include xsd files.
                  >I think those tools do not work with included xsds
                  >>
                  >--
                  >>
                  >Sevket Seyalioglu
                  >CTO
                  >www.kbstours.com
                  >"Yaron Karni" <yaron.karni@gm ail.comwrote in message
                  >news:17267F9 A-17C3-411E-A898-C3ADE257971D@mi crosoft.com...
                  check XSDObjectGen.ms i for .net 1.0 also have a look at :

                  >
                  --
                  Sincerely
                  Yaron Karni
                  All .net c# stuff, patterns code and snippet help programmer.

                  >
                  >
                  "SevDer" wrote:
                  >
                  >Hi,
                  >>
                  >Can someone tell me how to generate classes from XSD files?
                  >Is there an easy way to convert it into typed datasets etc?
                  >>
                  >Or any other suggestion is welcomed.
                  >>
                  >--
                  >>
                  >SevDer
                  >http://www.sevder.com
                  >>
                  >>
                  >>

                  Comment

                  • Steven Cheng[MSFT]

                    #10
                    Re: XSD Class Generation

                    Thanks for your reply and the XSD fragment,

                    I'll perform some local test to see whether I can get some result. I'll
                    update you soon.

                    Sincerely,

                    Steven Cheng

                    Microsoft MSDN Online Support Lead


                    This posting is provided "AS IS" with no warranties, and confers no rights.


                    Comment

                    • Steven Cheng[MSFT]

                      #11
                      Re: XSD Class Generation

                      Hi SevDer,

                      Seems I can not get the XSD to work with out the refernced schema. How
                      large is it? Is it possible that you post it over internet so that I can
                      downloat it? Or you can send it to me through the following email(you can
                      package all the stuff in a zip pack):

                      string email = "stcheng" + "@" + "microsoft.com" ;

                      Sincerely,

                      Steven Cheng

                      Microsoft MSDN Online Support Lead


                      This posting is provided "AS IS" with no warranties, and confers no rights.




                      --------------------
                      >>
                      >Thanks for your reply and the XSD fragment,
                      >
                      >I'll perform some local test to see whether I can get some result. I'll
                      >update you soon.
                      >
                      >Sincerely,
                      >
                      >Steven Cheng
                      >
                      >Microsoft MSDN Online Support Lead
                      >
                      >
                      >This posting is provided "AS IS" with no warranties, and confers no rights.
                      >
                      >
                      >

                      Comment

                      • Steven Cheng[MSFT]

                        #12
                        Re: XSD Class Generation

                        Hi SevDer,

                        I have got your email and will have a look into the stuff. I'll update you
                        if I get any new finding on this.

                        Sincerely,

                        Steven Cheng

                        Microsoft MSDN Online Support Lead


                        This posting is provided "AS IS" with no warranties, and confers no rights.




                        --------------------
                        >
                        >Hi SevDer,
                        >
                        >Seems I can not get the XSD to work with out the refernced schema. How
                        >large is it? Is it possible that you post it over internet so that I can
                        >downloat it? Or you can send it to me through the following email(you can
                        >package all the stuff in a zip pack):
                        >
                        >string email = "stcheng" + "@" + "microsoft.com" ;
                        >
                        >Sincerely,
                        >
                        >Steven Cheng
                        >
                        >Microsoft MSDN Online Support Lead
                        >
                        >
                        >This posting is provided "AS IS" with no warranties, and confers no rights.
                        >
                        >
                        >
                        >
                        >--------------------
                        >>>
                        >>Thanks for your reply and the XSD fragment,
                        >>
                        >>I'll perform some local test to see whether I can get some result. I'll
                        >>update you soon.
                        >>
                        >>Sincerely,
                        >>
                        >>Steven Cheng
                        >>
                        >>Microsoft MSDN Online Support Lead
                        >>
                        >>
                        >>This posting is provided "AS IS" with no warranties, and confers no
                        rights.
                        >>
                        >>
                        >>
                        >
                        >

                        Comment

                        • KBSTours

                          #13
                          Re: XSD Class Generation

                          Thanks Steven,

                          I will look forward for your response.

                          --


                          CTO

                          "Steven Cheng[MSFT]" <stcheng@online .microsoft.comw rote in message
                          news:%23M4d0N46 HHA.5204@TK2MSF TNGHUB02.phx.gb l...
                          Hi,
                          >
                          I have got your email and will have a look into the stuff. I'll update you
                          if I get any new finding on this.
                          >
                          Sincerely,
                          >
                          Steven Cheng
                          >
                          Microsoft MSDN Online Support Lead
                          >
                          >
                          This posting is provided "AS IS" with no warranties, and confers no
                          rights.
                          >
                          >
                          >
                          >
                          --------------------
                          >
                          >>
                          >>Hi,
                          >>
                          >>Seems I can not get the XSD to work with out the refernced schema. How
                          >>large is it? Is it possible that you post it over internet so that I can
                          >>downloat it? Or you can send it to me through the following email(you can
                          >>package all the stuff in a zip pack):
                          >>
                          >>string email = "stcheng" + "@" + "microsoft.com" ;
                          >>
                          >>Sincerely,
                          >>
                          >>Steven Cheng
                          >>
                          >>Microsoft MSDN Online Support Lead
                          >>
                          >>
                          >>This posting is provided "AS IS" with no warranties, and confers no
                          >>rights.
                          >>
                          >>
                          >>
                          >>
                          >>--------------------
                          >>>>
                          >>>Thanks for your reply and the XSD fragment,
                          >>>
                          >>>I'll perform some local test to see whether I can get some result. I'll
                          >>>update you soon.
                          >>>
                          >>>Sincerely,
                          >>>
                          >>>Steven Cheng
                          >>>
                          >>>Microsoft MSDN Online Support Lead
                          >>>
                          >>>
                          >>>This posting is provided "AS IS" with no warranties, and confers no
                          rights.
                          >>>
                          >>>
                          >>>
                          >>
                          >>
                          >

                          Comment

                          • Steven Cheng[MSFT]

                            #14
                            Re: XSD Class Generation

                            Hi SevDer,

                            I have performed some research on the three schemas you provided and did
                            found some syntax issues of them. The first problem I found is the base
                            type schemas doesn't have proper targetNamespace and default namespace
                            declared. I've included detailed info in the email sent to you. So far I
                            can get it to generate standard .net classes , but still encounter a error
                            when try generating dataset classes.

                            Sincerely,

                            Steven Cheng
                            Microsoft MSDN Online Support Lead

                            --------------------
                            >From: "KBSTours" <kbstours@kbsto urs.com>
                            >References: <uPVmZkS5HHA.34 00@TK2MSFTNGP03 .phx.gbl>
                            <FRev2QU5HHA.52 04@TK2MSFTNGHUB 02.phx.gbl>
                            <eaIlQgW5HHA.21 08@TK2MSFTNGP02 .phx.gbl>
                            <gqeLmbm5HHA.23 40@TK2MSFTNGHUB 02.phx.gbl>
                            <YhCTCyS6HHA.61 40@TK2MSFTNGHUB 02.phx.gbl>
                            <#M4d0N46HHA.52 04@TK2MSFTNGHUB 02.phx.gbl>
                            >In-Reply-To: <#M4d0N46HHA.52 04@TK2MSFTNGHUB 02.phx.gbl>
                            >Subject: Re: XSD Class Generation
                            >Date: Fri, 31 Aug 2007 07:59:58 -0400
                            >Lines: 77
                            >Message-ID: <5433B41B-F7B7-4F2B-B16F-BD9AFEC2BF69@mi crosoft.com>
                            >MIME-Version: 1.0
                            >Content-Type: text/plain;
                            > format=flowed;
                            > charset="iso-8859-1";
                            > reply-type=original
                            >Content-Transfer-Encoding: 7bit
                            >X-Priority: 3
                            >X-MSMail-Priority: Normal
                            >X-Newsreader: Microsoft Windows Mail 6.0.6000.16480
                            >X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6000.16480
                            >X-MS-CommunityGroup-PostID: {5433B41B-F7B7-4F2B-B16F-BD9AFEC2BF69}
                            >X-MS-CommunityGroup-ThreadID: 2399DCE5-C79D-47F3-B0D2-828BCCBBE4EB
                            >X-MS-CommunityGroup-ParentID: CAAAA142-CB95-4872-B976-5EF29312A4C4
                            >Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
                            >Path: TK2MSFTNGHUB02. phx.gbl
                            >Xref: TK2MSFTNGHUB02. phx.gbl microsoft.publi c.dotnet.langua ges.csharp:4892 4
                            >NNTP-Posting-Host: TK2MSFTNGHUB02. phx.gbl 127.0.0.1
                            >X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
                            >
                            >Thanks Steven,
                            >
                            >I will look forward for your response.
                            >
                            >--
                            >
                            >
                            >CTO
                            >www.kbstours.com
                            >"Steven Cheng[MSFT]" <stcheng@online .microsoft.comw rote in message
                            >news:%23M4d0N4 6HHA.5204@TK2MS FTNGHUB02.phx.g bl...
                            >Hi,
                            >>
                            >I have got your email and will have a look into the stuff. I'll update
                            you
                            >if I get any new finding on this.
                            >>
                            >Sincerely,
                            >>
                            >Steven Cheng
                            >>
                            >Microsoft MSDN Online Support Lead
                            >>
                            >>
                            >This posting is provided "AS IS" with no warranties, and confers no
                            >rights.
                            >>
                            >>
                            >>
                            >>
                            >--------------------
                            >>
                            >>>
                            >>>Hi,
                            >>>
                            >>>Seems I can not get the XSD to work with out the refernced schema. How
                            >>>large is it? Is it possible that you post it over internet so that I can
                            >>>downloat it? Or you can send it to me through the following email(you can
                            >>>package all the stuff in a zip pack):
                            >>>
                            >>>string email = "stcheng" + "@" + "microsoft.com" ;
                            >>>
                            >>>Sincerely,
                            >>>
                            >>>Steven Cheng
                            >>>
                            >>>Microsoft MSDN Online Support Lead
                            >>>
                            >>>
                            >>>This posting is provided "AS IS" with no warranties, and confers no
                            >>>rights.
                            >>>
                            >>>
                            >>>
                            >>>
                            >>>--------------------
                            >>>>>
                            >>>>Thanks for your reply and the XSD fragment,
                            >>>>
                            >>>>I'll perform some local test to see whether I can get some result. I'll
                            >>>>update you soon.
                            >>>>
                            >>>>Sincerely ,
                            >>>>
                            >>>>Steven Cheng
                            >>>>
                            >>>>Microsoft MSDN Online Support Lead
                            >>>>
                            >>>>
                            >>>>This posting is provided "AS IS" with no warranties, and confers no
                            >rights.
                            >>>>
                            >>>>
                            >>>>
                            >>>
                            >>>
                            >>
                            >
                            >

                            Comment

                            Working...