Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. XSD.EXE array, would like list

XSD.EXE array, would like list

Scheduled Pinned Locked Moved XML / XSL
csharpdatabasedockerdata-structuresxml
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kalkwarf
    wrote on last edited by
    #1

    I used XSD.EXE to convert my schema to a C# class. The tool creates arrays to represent elements whose maxOccurs attribute is unbounded. Arrays are very limiting: you cannot add or delete items without a lot of shuffling. Has anyone found a way around this limitation of arrays? For simple cases, I have converted the array to a List and back to an array, but that is only useful in the simplest of cases. Perhaps there is another tool that can convert my schema and use a list or some other suitable container (?).

    B J J 3 Replies Last reply
    0
    • K kalkwarf

      I used XSD.EXE to convert my schema to a C# class. The tool creates arrays to represent elements whose maxOccurs attribute is unbounded. Arrays are very limiting: you cannot add or delete items without a lot of shuffling. Has anyone found a way around this limitation of arrays? For simple cases, I have converted the array to a List and back to an array, but that is only useful in the simplest of cases. Perhaps there is another tool that can convert my schema and use a list or some other suitable container (?).

      B Offline
      B Offline
      Bernhard Hiller
      wrote on last edited by
      #2

      There is no need for converting the list back to an array, you can replace it. I did that e.g. with GPX files (see also Bernie’s Trackviewer[^] where I use some more tricks for getting "nice" classes from an "ugly" XML schema).

      K J 2 Replies Last reply
      0
      • B Bernhard Hiller

        There is no need for converting the list back to an array, you can replace it. I did that e.g. with GPX files (see also Bernie’s Trackviewer[^] where I use some more tricks for getting "nice" classes from an "ugly" XML schema).

        K Offline
        K Offline
        kalkwarf
        wrote on last edited by
        #3

        I am not sure what you mean by "replace it." Do you mean change the implementation of the class produced by XSD.EXE? My process is: - convert class array to List (ToList()) - make my changes (add, delete, modify) - assign back to class array (myList.ToArray)

        1 Reply Last reply
        0
        • B Bernhard Hiller

          There is no need for converting the list back to an array, you can replace it. I did that e.g. with GPX files (see also Bernie’s Trackviewer[^] where I use some more tricks for getting "nice" classes from an "ugly" XML schema).

          J Offline
          J Offline
          jschell
          wrote on last edited by
          #4

          Same basic question as the OP. Looking at your source code it appears that you made manual changes to the generated files? And then fixed the actual serialization problem with XmlElementAttribute?

          B 1 Reply Last reply
          0
          • K kalkwarf

            I used XSD.EXE to convert my schema to a C# class. The tool creates arrays to represent elements whose maxOccurs attribute is unbounded. Arrays are very limiting: you cannot add or delete items without a lot of shuffling. Has anyone found a way around this limitation of arrays? For simple cases, I have converted the array to a List and back to an array, but that is only useful in the simplest of cases. Perhaps there is another tool that can convert my schema and use a list or some other suitable container (?).

            J Offline
            J Offline
            jschell
            wrote on last edited by
            #5

            kalkwarf wrote:

            Has anyone found a way around this limitation of arrays?

            Following looks useful http://stackoverflow.com/questions/386155/comparison-of-xsd-codegenerators-c[^]

            1 Reply Last reply
            0
            • J jschell

              Same basic question as the OP. Looking at your source code it appears that you made manual changes to the generated files? And then fixed the actual serialization problem with XmlElementAttribute?

              B Offline
              B Offline
              Bernhard Hiller
              wrote on last edited by
              #6

              Exactly.

              1 Reply Last reply
              0
              • K kalkwarf

                I used XSD.EXE to convert my schema to a C# class. The tool creates arrays to represent elements whose maxOccurs attribute is unbounded. Arrays are very limiting: you cannot add or delete items without a lot of shuffling. Has anyone found a way around this limitation of arrays? For simple cases, I have converted the array to a List and back to an array, but that is only useful in the simplest of cases. Perhaps there is another tool that can convert my schema and use a list or some other suitable container (?).

                J Offline
                J Offline
                jinzai
                wrote on last edited by
                #7

                That is precisely what Collections are for -- to address the limitations imposed by fixed length arrays. The limitation is not on arrays -- it appears to be on how willing programmers are to writing proper code, IMHO. In C++, the standard library has some things for that, like vectors and maps, and in C# there are collections.

                K 1 Reply Last reply
                0
                • J jinzai

                  That is precisely what Collections are for -- to address the limitations imposed by fixed length arrays. The limitation is not on arrays -- it appears to be on how willing programmers are to writing proper code, IMHO. In C++, the standard library has some things for that, like vectors and maps, and in C# there are collections.

                  K Offline
                  K Offline
                  kalkwarf
                  wrote on last edited by
                  #8

                  I think you do not understand the question. The problem is that the tool (XSD.EXE) generates code that uses arrays. Arrays are limiting since it is difficult to add to or remove items from them. I was looking for another tool (that used a more appropriate collection) or an easy workaround. Perhaps I could have phrased my question better. The limitation I mentioned was intended to mean that the tool generated arrays, not that of arrays themselves. Even at this late stage, I appreciate your answer. However, I believe you misread the question.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups