create xml document based from schema

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

    create xml document based from schema

    I have the following schema. I need to know how to make an xml document
    based from it. The main worry I have is the DateTime field.

    <?xml version="1.0" encoding="utf-8"?>

    <xs:schema attributeFormDe fault="unqualif ied" elementFormDefa ult="qualified"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <xs:element name="NewsArtic le">

    <xs:complexType >

    <xs:sequence>

    <xs:element name="Descripti on" type="xs:string " />

    <xs:element name="Body" type="xs:string " />

    </xs:sequence>

    <xs:attribute name="title" type="xs:string " use="required" />

    <xs:attribute name="Date" type="xs:dateTi me" use="required" />

    </xs:complexType>

    </xs:element>

    </xs:schema>


  • Martin Honnen

    #2
    Re: create xml document based from schema

    Andy B wrote:
    I have the following schema. I need to know how to make an xml document
    based from it. The main worry I have is the DateTime field.
    Do you want to do that programmaticall y? You could use the xsd.exe tool
    to infer a.NET class in VB or C# from the XML, then you could compile
    and instantiate the class and populate its members to finally serialize
    the class instance to XML.




    --

    Martin Honnen --- MVP XML

    Comment

    • Navid

      #3
      Re: create xml document based from schema

      Martin Honnen wrote:
      Andy B wrote:
      >I have the following schema. I need to know how to make an xml
      >document based from it. The main worry I have is the DateTime field.
      >
      Do you want to do that programmaticall y? You could use the xsd.exe tool
      to infer a.NET class in VB or C# from the XML, then you could compile
      and instantiate the class and populate its members to finally serialize
      the class instance to XML.

      >
      >
      >
      Hi Martin,
      I am trying to use the xsd.exe tool i am trying to do something similar
      and i was just writing my own library to do it but want to try this out.
      I am using Visual Studios 2008 V3.5 and i cant seem to find the tool to
      add to my external tools. Any idea where it might be or where i could
      get it from?

      Comment

      • Martin Honnen

        #4
        Re: create xml document based from schema

        Navid wrote:
        I am trying to use the xsd.exe tool i am trying to do something similar
        and i was just writing my own library to do it but want to try this out.
        I am using Visual Studios 2008 V3.5 and i cant seem to find the tool to
        add to my external tools. Any idea where it might be or where i could
        get it from?
        xsd.exe is a command line tool so open up a Visual Studio 2008 command
        prompt
        Programs -Visual Studio 2008 -Visual Studio Tools -Visual Studio
        command prompt
        and use xsd.exe from the command line.

        --

        Martin Honnen --- MVP XML

        Comment

        • Navid

          #5
          Re: create xml document based from schema

          Martin Honnen wrote:
          Navid wrote:
          >
          >I am trying to use the xsd.exe tool i am trying to do something
          >similar and i was just writing my own library to do it but want to try
          >this out.
          >I am using Visual Studios 2008 V3.5 and i cant seem to find the tool
          >to add to my external tools. Any idea where it might be or where i
          >could get it from?
          >
          xsd.exe is a command line tool so open up a Visual Studio 2008 command
          prompt
          Programs -Visual Studio 2008 -Visual Studio Tools -Visual Studio
          command prompt
          and use xsd.exe from the command line.
          >
          Is it possible to use it inside an application?
          For example if i have a Windows Form application once the schema is
          defined or even before the application is started onLoad() to use this
          to get the classes from a XML schema file?

          Comment

          • Navid

            #6
            Re: create xml document based from schema

            Navid wrote:
            Martin Honnen wrote:
            >Navid wrote:
            >>
            >>I am trying to use the xsd.exe tool i am trying to do something
            >>similar and i was just writing my own library to do it but want to
            >>try this out.
            >>I am using Visual Studios 2008 V3.5 and i cant seem to find the tool
            >>to add to my external tools. Any idea where it might be or where i
            >>could get it from?
            >>
            >xsd.exe is a command line tool so open up a Visual Studio 2008 command
            >prompt
            >Programs -Visual Studio 2008 -Visual Studio Tools -Visual Studio
            >command prompt
            >and use xsd.exe from the command line.
            >>
            Is it possible to use it inside an application?
            For example if i have a Windows Form application once the schema is
            defined or even before the application is started onLoad() to use this
            to get the classes from a XML schema file?
            Is there any way using the xsd.exe tool to find out if a element or
            attribute is required or what the minOccurs is?

            Comment

            • Martin Honnen

              #7
              Re: create xml document based from schema

              Navid wrote:
              >xsd.exe is a command line tool so open up a Visual Studio 2008 command
              >prompt
              >Programs -Visual Studio 2008 -Visual Studio Tools -Visual Studio
              >command prompt
              >and use xsd.exe from the command line.
              >>
              Is it possible to use it inside an application?
              For example if i have a Windows Form application once the schema is
              defined or even before the application is started onLoad() to use this
              to get the classes from a XML schema file?
              You would use xsd.exe while developing your application to infer the
              class code files from the schema, then you would add the classes to your
              project to compile and build them together with the rest of your
              application.



              --

              Martin Honnen --- MVP XML

              Comment

              Working...