Can we shorten the Class Names 2?

Mar 27, 2009 at 11:27 AM
First of all thank you for the superb tool, this is really great!

I saw this discussion has already been posted but the proposed solution is useless.
If you have to work with third parties xsd you can't change them, moreover how can a complexType converted into a simplyType?
It would be really useful an option to generate class names from element names without nesting all the previous elements names.
To avoid class name conflicts I can suggest two other solutions: the first one is to use namespaces, the second one is to use nested classes.
So an option to decide how class name are generate would be a nice enhancement:
- Class name from element name (can lead to class name conflicts!)
- Class name from nested elements names (standard, how is done today)
- Class name from element name with namespaces
- Class name from element name with nested classes

Example with a simple xsd:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Library" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
  <xs:element name="Library">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Books" minOccurs="1" maxOccurs="1">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Book" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="Chapters" minOccurs="1" maxOccurs="1">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="Chapter" minOccurs="0" maxOccurs="unbounded">
                            <xs:complexType>
                              <xs:attribute name="id" type="xs:string" />
                              <xs:attribute name="name" type="xs:string" />
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                  <xs:attribute name="Id" type="xs:string" />
                  <xs:attribute name="Title" type="xs:string" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
      <xs:attribute name="Id" type="xs:string" />
      <xs:attribute name="Title" type="xs:string" />
    </xs:complexType>
  </xs:element>
</xs:schema>

Class names:
1. Library, Book, Chapter (simple solution, in this case there is no class name conflicts)
2. Library, LibraryBook, LibraryBookChapter (as usual)
3. Library, Books.Book, Books.Chapters.Chapter (namespaces)
4. Library, Library.Book, Library.Book.Chapter (nested classes)