Error using ReadXmlSchema on a xsd file.

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

    #1

    Error using ReadXmlSchema on a xsd file.

    I am using some sample code from gotdotnet to Create DataSet mappings from a
    xsd schema. I am geting this error. code and error below. I might mention
    there is also a publictypelibra ry file with this file I may have to use it in
    some way. I am very new at XML so some examples or articles would be helpfull.




    The error is:

    Undefined complexType 'http://www.adsml.org/typelibrary/1.1:MLItemType' is
    used as a base for complex type extension."


    The code Is:


    Imports System
    Imports System.IO
    Imports System.Xml

    Partial Class _Default
    Inherits System.Web.UI.P age
    Dim myLoadSchema As String
    Dim myXmlDataDocume nt As XmlDataDocument
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As
    System.EventArg s) Handles Me.Load

    myLoadSchema = Request.MapPath ("BookingsMa in-AS.xsd")
    'This file was also with this file Bookings-PublicTypeLibra ry-AS.xsd
    Run(myLoadSchem a)

    End Sub
    Public Sub Run(ByVal args As String)
    Try
    myXmlDataDocume nt = New XmlDataDocument ()
    Response.Write( "Creating an XmlDataDocument ...")
    ParseSchema(arg s)
    DisplayTableStr ucture()
    Catch e As exception
    Response.Write( "Exception: " & e.ToString())
    End Try
    End Sub

    ' Loads a specified schema into the DataSet
    Public Sub ParseSchema(ByV al schema As String)
    Dim myStreamReader As StreamReader = Nothing
    Try
    myStreamReader = New StreamReader(sc hema)
    Response.Write( "Reading Schema file ...")

    '*************
    myXmlDataDocume nt.DataSet.Read XmlSchema(myStr eamReader)
    '********Error is here in the ReadXmlSchema

    Catch e As exception
    Response.Write( "Exception: " & e.ToString())

    Finally
    If Not myStreamReader Is Nothing Then
    myStreamReader. Close()
    End If

    End Try
    End Sub

    ' Displays the DataSet tables structure
    Private Sub DisplayTableStr ucture()
    Response.Write( " ")
    Response.Write( "Table structure")
    Response.Write( " ")
    Response.Write( "Tables count=" &
    myXmlDataDocume nt.DataSet.Tabl es.Count.ToStri ng())

    Dim i, j As Integer

    For i = 0 To (myXmlDataDocum ent.DataSet.Tab les.Count - 1)
    Response.Write( "TableName= '" &
    myXmlDataDocume nt.DataSet.Tabl es(i).TableName & "'.")
    Response.Write( "Columns count=" &
    myXmlDataDocume nt.DataSet.Tabl es(i).Columns.C ount.ToString() )

    For j = 0 To (myXmlDataDocum ent.DataSet.Tab les(i).Columns. Count
    - 1)
    Response.Write( Strings.Chr(9) & "ColumnName ='" &
    myXmlDataDocume nt.DataSet.Tabl es(i).Columns(j ).ColumnName & "', type = " &
    myXmlDataDocume nt.DataSet.Tabl es(i).Columns(j ).DataType.ToSt ring())
    Next
    Response.Write( " ")
    Next
    End Sub


    End Class

    Thank you


    --
    Jerry
  • Kevin Yu [MSFT]

    #2
    RE: Error using ReadXmlSchema on a xsd file.

    Hi Jerry,

    You're getting this error message, because your schema might be referencing
    another one. This type is not defined in your schema. Could you please post
    your schema content here. Or it will be better if you point me to the
    gotdotnet URL for this code sample. Thanks!

    Kevin Yu
    Microsoft Online Community Support

    =============== =============== =============== =====
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscripti...ult.aspx#notif
    ications.
    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscripti...t/default.aspx.
    =============== =============== =============== =====

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

    Comment

    • Jerry C

      #3
      RE: Error using ReadXmlSchema on a xsd file.

      Kevin,

      Thank you for the reply.

      I think you are correct about this schema referencing another file. There
      are two files in the distribution. I have emailed you both of the files. One
      of the files has typelibrary in the filename ( this is a clue). Now the
      question is how do I use these files to create the dataset from the XSD files
      since there are two files. I also think there may be a collection of schemas
      in this file. How do I find out how this file is constructed.

      Thank you
      Jerry
      --
      Jerry


      "Kevin Yu [MSFT]" wrote:
      Hi Jerry,
      >
      You're getting this error message, because your schema might be referencing
      another one. This type is not defined in your schema. Could you please post
      your schema content here. Or it will be better if you point me to the
      gotdotnet URL for this code sample. Thanks!
      >
      Kevin Yu
      Microsoft Online Community Support
      >
      =============== =============== =============== =====
      Get notification to my posts through email? Please refer to
      http://msdn.microsoft.com/subscripti...ult.aspx#notif
      ications.
      Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
      where an initial response from the community or a Microsoft Support
      Engineer within 1 business day is acceptable. Please note that each follow
      up response may take approximately 2 business days as the support
      professional working with you may need further investigation to reach the
      most efficient resolution. The offering is not appropriate for situations
      that require urgent, real-time or phone-based interactions or complex
      project analysis and dump analysis issues. Issues of this nature are best
      handled working with a dedicated Microsoft Support Engineer by contacting
      Microsoft Customer Support Services (CSS) at
      http://msdn.microsoft.com/subscripti...t/default.aspx.
      =============== =============== =============== =====
      >
      (This posting is provided "AS IS", with no warranties, and confers no
      rights.)
      >
      >

      Comment

      • Jerry C

        #4
        RE: Error using ReadXmlSchema on a xsd file.

        keven,
        Sorry I could not email you the files. online.microsof t.com gets bounced. If
        you need the files please tell me how to send them to you.

        Thank you,
        --
        Jerry


        "Jerry C" wrote:
        Kevin,
        >
        Thank you for the reply.
        >
        I think you are correct about this schema referencing another file. There
        are two files in the distribution. I have emailed you both of the files. One
        of the files has typelibrary in the filename ( this is a clue). Now the
        question is how do I use these files to create the dataset from the XSD files
        since there are two files. I also think there may be a collection of schemas
        in this file. How do I find out how this file is constructed.
        >
        Thank you
        Jerry
        --
        Jerry
        >
        >
        "Kevin Yu [MSFT]" wrote:
        >
        Hi Jerry,

        You're getting this error message, because your schema might be referencing
        another one. This type is not defined in your schema. Could you please post
        your schema content here. Or it will be better if you point me to the
        gotdotnet URL for this code sample. Thanks!

        Kevin Yu
        Microsoft Online Community Support

        =============== =============== =============== =====
        Get notification to my posts through email? Please refer to
        http://msdn.microsoft.com/subscripti...ult.aspx#notif
        ications.
        Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
        where an initial response from the community or a Microsoft Support
        Engineer within 1 business day is acceptable. Please note that each follow
        up response may take approximately 2 business days as the support
        professional working with you may need further investigation to reach the
        most efficient resolution. The offering is not appropriate for situations
        that require urgent, real-time or phone-based interactions or complex
        project analysis and dump analysis issues. Issues of this nature are best
        handled working with a dedicated Microsoft Support Engineer by contacting
        Microsoft Customer Support Services (CSS) at
        http://msdn.microsoft.com/subscripti...t/default.aspx.
        =============== =============== =============== =====

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

        Comment

        • Kevin Yu [MSFT]

          #5
          RE: Error using ReadXmlSchema on a xsd file.

          Hi Jerry,

          Is this a typed DataSet schema? As I assume, a typed DataSet schema is
          always in one file. Not all xml schemas can be loaded as a DataSet schema.
          You might need to combine them into one valid DataSet schema, since
          DataSet.ReadXml Schema can only read from one file/stream.

          Kevin Yu
          Microsoft Online Community Support
          =============== =============== =============== =====

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

          Comment

          • Jerry C

            #6
            RE: Error using ReadXmlSchema on a xsd file.

            Keven,

            Thank you for the reply.

            I am a little new at XML to know what kind of dataset this is there are
            hundreds of lines of XSD in these files. I was hopping to understand how to
            use these files to create datasets or what ever they were intended for. I
            have found this post that talks about schemas and multiple files.



            I can email you the files and maybe you can give me some guidance about how
            to use them. These files do open in dot.net 2005 and there is a graphical
            display.

            Thank you

            --
            Jerry


            "Kevin Yu [MSFT]" wrote:
            Hi Jerry,
            >
            Is this a typed DataSet schema? As I assume, a typed DataSet schema is
            always in one file. Not all xml schemas can be loaded as a DataSet schema.
            You might need to combine them into one valid DataSet schema, since
            DataSet.ReadXml Schema can only read from one file/stream.
            >
            Kevin Yu
            Microsoft Online Community Support
            =============== =============== =============== =====
            >
            (This posting is provided "AS IS", with no warranties, and confers no
            rights.)
            >
            >

            Comment

            • Jerry C

              #7
              RE: Error using ReadXmlSchema on a xsd file.

              Keven,

              I am testing in asp.net 2005 using VB in case you needed that info.

              There is a include and several Imports in the first part of the file XSD
              file I wonder if the app is finding these files. I have them in the app dir
              but these Namespace= "location" does not exists. How should these be in the
              file so they will be found.

              This is the text of the include and Imports


              <xs:include schemaLocation= "AdsMLBooki ngs-1.0-PublicTypeLibra ry-AS.xsd" />
              <xs:import namespace="http ://www.adsml.org/typelibrary/1.1"
              schemaLocation= "AdsMLTypeLibra ry-1.1-AS.xsd" />
              <xs:import namespace="http ://www.adsml.org/controlledvocab ularies/2.0"
              schemaLocation= "AdsMLControlle dVocabularies-2.0-AS.xsd" />
              <xs:import namespace="http ://www.adsml.org/adsmlmaterials/1.0"
              schemaLocation= "AdsMLMater ials-1.0-PublicTypeLibra ry-AS.xsd" />

              Thank you


              --
              Jerry


              "Jerry C" wrote:
              Keven,
              >
              Thank you for the reply.
              >
              I am a little new at XML to know what kind of dataset this is there are
              hundreds of lines of XSD in these files. I was hopping to understand how to
              use these files to create datasets or what ever they were intended for. I
              have found this post that talks about schemas and multiple files.
              >

              >
              I can email you the files and maybe you can give me some guidance about how
              to use them. These files do open in dot.net 2005 and there is a graphical
              display.
              >
              Thank you
              >
              --
              Jerry
              >
              >
              "Kevin Yu [MSFT]" wrote:
              >
              Hi Jerry,

              Is this a typed DataSet schema? As I assume, a typed DataSet schema is
              always in one file. Not all xml schemas can be loaded as a DataSet schema.
              You might need to combine them into one valid DataSet schema, since
              DataSet.ReadXml Schema can only read from one file/stream.

              Kevin Yu
              Microsoft Online Community Support
              =============== =============== =============== =====

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

              Comment

              • Kevin Yu [MSFT]

                #8
                RE: Error using ReadXmlSchema on a xsd file.

                Hi Jerry,

                If the files are in same directory, are the include and import tags
                specifying the correct location for these files? Are all the files in that
                folder? If so, and your code still doesn't work, please send these XSDs to
                my mailbox. Remove 'online' from my nospam alias is my real email.

                Kevin Yu
                Microsoft Online Community Support
                =============== =============== =============== =====

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

                Comment

                • Jerry C

                  #9
                  RE: Error using ReadXmlSchema on a xsd file.

                  Keven,

                  Thank you for the reply.

                  I think you are correct about the location of the files. The tags point to a
                  site that does not exist.

                  The namespace points to:
                  namespace="http ://www.adsml.org/controlledvocab ularies/2.0"
                  which does not exist. and the schemaLocation points to:
                  schemaLocation= "AdsMLControlle dVocabularies-2.0-AS.xsd" />
                  All the xsd files are in the app directory. The question now is do I use a
                  full path name for the xsd file in the namespace or schemaLocation or is the
                  path in the namespace and the xsd file name in the schemaLocation.

                  I will email you the files

                  Thank you,

                  --
                  Jerry


                  "Kevin Yu [MSFT]" wrote:
                  Hi Jerry,
                  >
                  If the files are in same directory, are the include and import tags
                  specifying the correct location for these files? Are all the files in that
                  folder? If so, and your code still doesn't work, please send these XSDs to
                  my mailbox. Remove 'online' from my nospam alias is my real email.
                  >
                  Kevin Yu
                  Microsoft Online Community Support
                  =============== =============== =============== =====
                  >
                  (This posting is provided "AS IS", with no warranties, and confers no
                  rights.)
                  >
                  >

                  Comment

                  • Kevin Yu [MSFT]

                    #10
                    RE: Error using ReadXmlSchema on a xsd file.

                    Hi Jerry,

                    I've received the schema file you sent me. The schema cannot be loaded, not
                    because the namespace points to an invalid site. The namespace is only a
                    string that gives a name. It can be any string actually.

                    After my research, I found a type named StructuredDescr iptionsType was not
                    declared in your schema. It was used in file
                    AdsMLMaterials-1.0-PublicTypeLibra ry-AS.xsd, but never declared anywhere.

                    <xs:element name="Structure dDescriptions"
                    type="adsml-sd:StructuredDe scriptionsType" minOccurs="0" />

                    You need to contact the source of these .xsd files to check for this issue.
                    Let me know if anything is unclear.

                    Kevin Yu
                    Microsoft Online Community Support
                    =============== =============== =============== =====

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

                    Comment

                    • Jerry C

                      #11
                      RE: Error using ReadXmlSchema on a xsd file.

                      Kevin,

                      Thank you for the reply,

                      I think I have complicated the issue by not including all the files in the
                      distribution. There are imports and includes in all the files I sent you so
                      when I included all of them in the app dir the error you found went away and
                      I was back to the original one in my first post. I will email you all the
                      files.
                      --
                      Jerry


                      "Kevin Yu [MSFT]" wrote:
                      Hi Jerry,
                      >
                      I've received the schema file you sent me. The schema cannot be loaded, not
                      because the namespace points to an invalid site. The namespace is only a
                      string that gives a name. It can be any string actually.
                      >
                      After my research, I found a type named StructuredDescr iptionsType was not
                      declared in your schema. It was used in file
                      AdsMLMaterials-1.0-PublicTypeLibra ry-AS.xsd, but never declared anywhere.
                      >
                      <xs:element name="Structure dDescriptions"
                      type="adsml-sd:StructuredDe scriptionsType" minOccurs="0" />
                      >
                      You need to contact the source of these .xsd files to check for this issue.
                      Let me know if anything is unclear.
                      >
                      Kevin Yu
                      Microsoft Online Community Support
                      =============== =============== =============== =====
                      >
                      (This posting is provided "AS IS", with no warranties, and confers no
                      rights.)
                      >
                      >

                      Comment

                      • Kevin Yu [MSFT]

                        #12
                        RE: Error using ReadXmlSchema on a xsd file.

                        Hi Jerry,

                        It seems that this XSD is not a valid DataSet schema. Not all XSD files can
                        be loaded as a DataSet. This is a really bit schema, and it is valid. But
                        it cannot be as a DataSet schema, because some types in it cannot be a
                        DataType in a DataTable.

                        Kevin Yu
                        Microsoft Online Community Support

                        =============== =============== =============== =====
                        Get notification to my posts through email? Please refer to
                        http://msdn.microsoft.com/subscripti...ult.aspx#notif
                        ications.
                        Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
                        where an initial response from the community or a Microsoft Support
                        Engineer within 1 business day is acceptable. Please note that each follow
                        up response may take approximately 2 business days as the support
                        professional working with you may need further investigation to reach the
                        most efficient resolution. The offering is not appropriate for situations
                        that require urgent, real-time or phone-based interactions or complex
                        project analysis and dump analysis issues. Issues of this nature are best
                        handled working with a dedicated Microsoft Support Engineer by contacting
                        Microsoft Customer Support Services (CSS) at
                        http://msdn.microsoft.com/subscripti...t/default.aspx.
                        =============== =============== =============== =====

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

                        Comment

                        • Jerry C

                          #13
                          RE: Error using ReadXmlSchema on a xsd file.

                          Kevin,

                          Thanks for the reply.

                          I am kind of new to XML. How would these files be used by asp.net to help
                          create XML files. Are there utilites to help format the XML to be correct for
                          these XSD files. some Links to articles would be helpfull

                          Thank you,
                          --
                          Jerry


                          "Kevin Yu [MSFT]" wrote:
                          Hi Jerry,
                          >
                          It seems that this XSD is not a valid DataSet schema. Not all XSD files can
                          be loaded as a DataSet. This is a really bit schema, and it is valid. But
                          it cannot be as a DataSet schema, because some types in it cannot be a
                          DataType in a DataTable.
                          >
                          Kevin Yu
                          Microsoft Online Community Support
                          >
                          =============== =============== =============== =====
                          Get notification to my posts through email? Please refer to
                          http://msdn.microsoft.com/subscripti...ult.aspx#notif
                          ications.
                          Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
                          where an initial response from the community or a Microsoft Support
                          Engineer within 1 business day is acceptable. Please note that each follow
                          up response may take approximately 2 business days as the support
                          professional working with you may need further investigation to reach the
                          most efficient resolution. The offering is not appropriate for situations
                          that require urgent, real-time or phone-based interactions or complex
                          project analysis and dump analysis issues. Issues of this nature are best
                          handled working with a dedicated Microsoft Support Engineer by contacting
                          Microsoft Customer Support Services (CSS) at
                          http://msdn.microsoft.com/subscripti...t/default.aspx.
                          =============== =============== =============== =====
                          >
                          (This posting is provided "AS IS", with no warranties, and confers no
                          rights.)
                          >
                          >

                          Comment

                          • Kevin Yu [MSFT]

                            #14
                            RE: Error using ReadXmlSchema on a xsd file.

                            Hi Jerry,

                            XMLSpy is a widely used tool which provides this function to help your
                            create/validate xml files accroding to your schema. It also have a lot of
                            other functions for Xml. You can download to try it.

                            XMLSpy XML Editor is an advanced, time-saving tool for editing XML, JSON, and related technologies. See why it’s the choice of over 5 million developers with a free, 30-day trial.


                            Also, if you're developing an ASP.NET app, you can use an XmlReader to
                            validate your xml file. Here is a sample.

                            http://msdn2.microsoft.com/en-us/library/8f0h7att.aspx

                            HTH.

                            Kevin Yu
                            Microsoft Online Community Support
                            =============== =============== =============== =====

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

                            Comment

                            Working...