locked
XSD tool: XSD to language:vb issue RRS feed

  • Question

  • I used the XSD.exe tool to convert XML to XSD then generate vb code behind for the XSD. It is giving me errors in the code even though it was auto-generated. I am weary about messing with the code since it was auto generated. Can anyone help with these errors?
    XSD code behind:
    '------------------------------------------------------------------------------
    ' <auto-generated>
    '     This code was generated by a tool.
    '     Runtime Version:4.0.30319.237
    '
    '     Changes to this file may cause incorrect behavior and will be lost if
    '     the code is regenerated.
    ' </auto-generated>
    '------------------------------------------------------------------------------
    
    Option Strict Off
    Option Explicit On
    
    Imports System.Xml.Serialization
    
    '
    'This source code was auto-generated by xsd, Version=4.0.30319.1.
    '
    
    '''<remarks/>
    <System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1"),  _
     System.SerializableAttribute(),  _
     System.Diagnostics.DebuggerStepThroughAttribute(),  _
     System.ComponentModel.DesignerCategoryAttribute("code"),  _
     System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=true),  _
     System.Xml.Serialization.XmlRootAttribute([Namespace]:="", IsNullable:=false)>  _
    Partial Public Class xml
        
        Private msgField As String
        
        Private errorField As String
        
        Private processTimeField As String
        
        Private versionField As String
        
        Private resultsField()() As xmlResultsArray
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public Property msg() As String
            Get
                Return Me.msgField
            End Get
            Set
                Me.msgField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public Property [error]() As String
            Get
                Return Me.errorField
            End Get
            Set
                Me.errorField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public Property processTime() As String
            Get
                Return Me.processTimeField
            End Get
            Set
                Me.processTimeField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public Property version() As String
            Get
                Return Me.versionField
            End Get
            Set
                Me.versionField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlArrayAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified),  _
         System.Xml.Serialization.XmlArrayItemAttribute("array", GetType(xmlResultsArray), Form:=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable:=false)>  _
        Public Property results() As xmlResultsArray()()
            Get
                Return Me.resultsField
            End Get
            Set
                Me.resultsField = value
            End Set
        End Property
    End Class
    
    '''<remarks/>
    <System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1"),  _
     System.SerializableAttribute(),  _
     System.Diagnostics.DebuggerStepThroughAttribute(),  _
     System.ComponentModel.DesignerCategoryAttribute("code"),  _
     System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=true)>  _
    Partial Public Class xmlResultsArray
        
        Private idField As String
        
        Private titleField As String
        
        Private protectedField As String
        
        Private descriptionField As String
        
        Private createdAtField As String
        
        Private ratingField As String
        
        Private lengthInSecondField As String
        
        Private totalViewsField As String
        
        Private codecIsForLiveHttpField As String
        
        Private serverIdField As String
        
        Private videoNameField As String
        
        Private urlField As String
        
        Private embedTagField As String
        
        Private mp4UrlField As String
        
        Private liveHttpUrlField As String
        
        Private imageUrlField() As xmlResultsArrayImageUrl
        
        Private sourceChannelField() As xmlResultsArraySourceChannel
        
        Private keyField As String
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public Property id() As String
            Get
                Return Me.idField
            End Get
            Set
                Me.idField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public Property title() As String
            Get
                Return Me.titleField
            End Get
            Set
                Me.titleField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public Property [protected]() As String
            Get
                Return Me.protectedField
            End Get
            Set
                Me.protectedField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public Property description() As String
            Get
                Return Me.descriptionField
            End Get
            Set
                Me.descriptionField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public Property createdAt() As String
            Get
                Return Me.createdAtField
            End Get
            Set
                Me.createdAtField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public Property rating() As String
            Get
                Return Me.ratingField
            End Get
            Set
                Me.ratingField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public Property lengthInSecond() As String
            Get
                Return Me.lengthInSecondField
            End Get
            Set
                Me.lengthInSecondField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public Property totalViews() As String
            Get
                Return Me.totalViewsField
            End Get
            Set
                Me.totalViewsField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public Property codecIsForLiveHttp() As String
            Get
                Return Me.codecIsForLiveHttpField
            End Get
            Set
                Me.codecIsForLiveHttpField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public Property serverId() As String
            Get
                Return Me.serverIdField
            End Get
            Set
                Me.serverIdField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public Property videoName() As String
            Get
                Return Me.videoNameField
            End Get
            Set
                Me.videoNameField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public Property url() As String
            Get
                Return Me.urlField
            End Get
            Set
                Me.urlField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public Property embedTag() As String
            Get
                Return Me.embedTagField
            End Get
            Set
                Me.embedTagField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public Property mp4Url() As String
            Get
                Return Me.mp4UrlField
            End Get
            Set
                Me.mp4UrlField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public Property liveHttpUrl() As String
            Get
                Return Me.liveHttpUrlField
            End Get
            Set
                Me.liveHttpUrlField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute("imageUrl", Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public Property imageUrl() As xmlResultsArrayImageUrl()
            Get
                Return Me.imageUrlField
            End Get
            Set
                Me.imageUrlField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute("sourceChannel", Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public Property sourceChannel() As xmlResultsArraySourceChannel()
            Get
                Return Me.sourceChannelField
            End Get
            Set
                Me.sourceChannelField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlAttributeAttribute()>  _
        Public Property key() As String
            Get
                Return Me.keyField
            End Get
            Set
                Me.keyField = value
            End Set
        End Property
    End Class
    
    '''<remarks/>
    <System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1"),  _
     System.SerializableAttribute(),  _
     System.Diagnostics.DebuggerStepThroughAttribute(),  _
     System.ComponentModel.DesignerCategoryAttribute("code"),  _
     System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=true)>  _
    Partial Public Class xmlResultsArrayImageUrl
        
        Private smallField As String
        
        Private mediumField As String
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public Property small() As String
            Get
                Return Me.smallField
            End Get
            Set
                Me.smallField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public Property medium() As String
            Get
                Return Me.mediumField
            End Get
            Set
                Me.mediumField = value
            End Set
        End Property
    End Class
    
    '''<remarks/>
    <System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1"),  _
     System.SerializableAttribute(),  _
     System.Diagnostics.DebuggerStepThroughAttribute(),  _
     System.ComponentModel.DesignerCategoryAttribute("code"),  _
     System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=true)>  _
    Partial Public Class xmlResultsArraySourceChannel
        
        Private idField As String
        
        Private urlField As String
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public Property id() As String
            Get
                Return Me.idField
            End Get
            Set
                Me.idField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>  _
        Public Property url() As String
            Get
                Return Me.urlField
            End Get
            Set
                Me.urlField = value
            End Set
        End Property
    End Class
    
    '''<remarks/>
    <System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1"),  _
    System.SerializableAttribute(),  _
     System.Diagnostics.DebuggerStepThroughAttribute(),  _
     System.ComponentModel.DesignerCategoryAttribute("code"),  _
     System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=true),  _
    System.Xml.Serialization.XmlRootAttribute([Namespace]:="", IsNullable:=false)>  _
    Partial Public Class NewDataSet
        
        Private itemsField() As xml
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute("xml")>  _
        Public Property Items() As xml()
            Get
                Return Me.itemsField
            End Get
            Set
                Me.itemsField = value
            End Set
        End Property
    End Class
    
    

    Warning 1 XML comment cannot be applied more than once on a partial class. XML comments for this class will be ignored. 
    Warning 2 XML comment cannot be applied more than once on a partial class. XML comments for this class will be ignored. 
    Error 3 Attribute 'SerializableAttribute' cannot be applied multiple times. 
    Error 4 Attribute 'DesignerCategoryAttribute' cannot be applied multiple times. 
    Error 5 Attribute 'XmlRootAttribute' cannot be applied multiple times. 
     
    '''<remarks/>
    <System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1"),  _
    System.SerializableAttribute(),  _
    System.Diagnostics.DebuggerStepThroughAttribute(),  _
    System.ComponentModel.DesignerCategoryAttribute("code"),  _
    System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=true),  _
    System.Xml.Serialization.XmlRootAttribute([Namespace]:="", IsNullable:=false)>  _
    These are the errors underlined. This code is from right above the last function in the class. Thanks for your time.
    • Edited by lagwagon504 Wednesday, September 21, 2011 4:06 PM
    Wednesday, September 21, 2011 4:02 PM

Answers

  • You can simply make the designer files visible like they are standard in C#

    Do that while there is not code visible to go to the top of Solution Explorer.

    Then click on the very small button show all files (you only get it by hoovering over it).

    The generated file of the XSD will show up as yourXSDName.Designer.VB

    Much easier than that XSD tool which as far as I know had forever troubles.

     

     


    Success
    Cor
    • Marked as answer by lagwagon504 Wednesday, September 21, 2011 7:50 PM
    Wednesday, September 21, 2011 4:38 PM
  • I just removed the attributes and the errors went away. I also did it with just the  yourXSDName.Designer.VB like you said and the errors went away. So this issue is fixed.

    It was important to me to use the XSD tool because that was the sole purpose of me doing this.. To learn the XSD tool.

    • Marked as answer by lagwagon504 Wednesday, September 21, 2011 7:49 PM
    Wednesday, September 21, 2011 7:49 PM

All replies

  • You can simply make the designer files visible like they are standard in C#

    Do that while there is not code visible to go to the top of Solution Explorer.

    Then click on the very small button show all files (you only get it by hoovering over it).

    The generated file of the XSD will show up as yourXSDName.Designer.VB

    Much easier than that XSD tool which as far as I know had forever troubles.

     

     


    Success
    Cor
    • Marked as answer by lagwagon504 Wednesday, September 21, 2011 7:50 PM
    Wednesday, September 21, 2011 4:38 PM
  • I'm not sure I follow. You are saying just convert the XML to XSD and not to a class?

    Wednesday, September 21, 2011 5:29 PM
  • It is already converted, just try what I said

     


    Success
    Cor
    Wednesday, September 21, 2011 6:11 PM
  • I just removed the attributes and the errors went away. I also did it with just the  yourXSDName.Designer.VB like you said and the errors went away. So this issue is fixed.

    It was important to me to use the XSD tool because that was the sole purpose of me doing this.. To learn the XSD tool.

    • Marked as answer by lagwagon504 Wednesday, September 21, 2011 7:49 PM
    Wednesday, September 21, 2011 7:49 PM