How to improve XML schema with sub-elements or references?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I have a xml schema like the one being shown below but I have noticed that it would be very complicated to maintain.



I want to improve the current schema in one of the following ways but I am not sure if they would be the best/correct route:



Option 1: Use a reference of all elements of movieDetails within movies.



Option 2: Add movieDetails as a sub-element of movies (which I frankly am struggling to achieve)



Which route would be best and what would be the best way to structure it?



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

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://xml.netbeans.org/schema/AmazingMovies"
xmlns:tns="http://xml.netbeans.org/schema/AmazingMovies"
elementFormDefault="qualified">

<xsd:complexType name="movies">
<xsd:sequence>
<xsd:element name="Title" type="xsd:string"/>
<xsd:element name="Director" type="xsd:string"></xsd:element>
<xsd:element name="Year" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="movieDetails">
<xsd:sequence>
<xsd:element name="Actor" type="xsd:string"/>
<xsd:element name="numberOfCast" type="xsd:int"></xsd:element>
<xsd:element name="releaseDate" type="xsd:date"/>
</xsd:sequence>
</xsd:complexType>

<xsd:element name="OnDisplay">
<xsd:complexType>
<xsd:sequence >
<xsd:element name="collectionOfMovies" type="tns:movies" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

</xsd:schema>


Extra information




OnDisplay element would add all elements of movies into a list in order to use them when unMarshalling. However, I want to also add movieDetails onto OnDisplay, therefore, it would be convenient to have them included in movies as a ref, sub-element or another form.




Tried the following methods but failed XML validation




Method 1




<xsd:element name="MoviesAndDetails">
<xsd:complexType name="movies">
<xsd:sequence>
<xsd:element name="Title" type="xsd:string"/>
<xsd:element name="Director" type="xsd:string"></xsd:element>
<xsd:element name="Year" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="movieDetails">
<xsd:sequence>
<xsd:element name="Actor" type="xsd:string"/>
<xsd:element name="numberOfCast" type="xsd:int"> </xsd:element>
<xsd:element name="releaseDate" type="xsd:date"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>



Method 2




<xsd:complexType name="MoviesAndDetails">
<xsd:complexType name="movies">
<xsd:sequence>
<xsd:element name="Title" type="xsd:string"/>
<xsd:element name="Director" type="xsd:string"></xsd:element>
<xsd:element name="Year" type="xsd:int"/>
<xsd:element ref="Actor"/>
<xsd:element ref="numberOfCast"/>
<xsd:element ref="releaseDate"/>
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="movieDetails">
<xsd:sequence>
<xsd:element name="Actor" type="xsd:string"/>
<xsd:element name="numberOfCast" type="xsd:int"> </xsd:element>
<xsd:element name="releaseDate" type="xsd:date"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>









share|improve this question





























    0















    I have a xml schema like the one being shown below but I have noticed that it would be very complicated to maintain.



    I want to improve the current schema in one of the following ways but I am not sure if they would be the best/correct route:



    Option 1: Use a reference of all elements of movieDetails within movies.



    Option 2: Add movieDetails as a sub-element of movies (which I frankly am struggling to achieve)



    Which route would be best and what would be the best way to structure it?



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

    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://xml.netbeans.org/schema/AmazingMovies"
    xmlns:tns="http://xml.netbeans.org/schema/AmazingMovies"
    elementFormDefault="qualified">

    <xsd:complexType name="movies">
    <xsd:sequence>
    <xsd:element name="Title" type="xsd:string"/>
    <xsd:element name="Director" type="xsd:string"></xsd:element>
    <xsd:element name="Year" type="xsd:int"/>
    </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="movieDetails">
    <xsd:sequence>
    <xsd:element name="Actor" type="xsd:string"/>
    <xsd:element name="numberOfCast" type="xsd:int"></xsd:element>
    <xsd:element name="releaseDate" type="xsd:date"/>
    </xsd:sequence>
    </xsd:complexType>

    <xsd:element name="OnDisplay">
    <xsd:complexType>
    <xsd:sequence >
    <xsd:element name="collectionOfMovies" type="tns:movies" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>

    </xsd:schema>


    Extra information




    OnDisplay element would add all elements of movies into a list in order to use them when unMarshalling. However, I want to also add movieDetails onto OnDisplay, therefore, it would be convenient to have them included in movies as a ref, sub-element or another form.




    Tried the following methods but failed XML validation




    Method 1




    <xsd:element name="MoviesAndDetails">
    <xsd:complexType name="movies">
    <xsd:sequence>
    <xsd:element name="Title" type="xsd:string"/>
    <xsd:element name="Director" type="xsd:string"></xsd:element>
    <xsd:element name="Year" type="xsd:int"/>
    </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="movieDetails">
    <xsd:sequence>
    <xsd:element name="Actor" type="xsd:string"/>
    <xsd:element name="numberOfCast" type="xsd:int"> </xsd:element>
    <xsd:element name="releaseDate" type="xsd:date"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>



    Method 2




    <xsd:complexType name="MoviesAndDetails">
    <xsd:complexType name="movies">
    <xsd:sequence>
    <xsd:element name="Title" type="xsd:string"/>
    <xsd:element name="Director" type="xsd:string"></xsd:element>
    <xsd:element name="Year" type="xsd:int"/>
    <xsd:element ref="Actor"/>
    <xsd:element ref="numberOfCast"/>
    <xsd:element ref="releaseDate"/>
    </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="movieDetails">
    <xsd:sequence>
    <xsd:element name="Actor" type="xsd:string"/>
    <xsd:element name="numberOfCast" type="xsd:int"> </xsd:element>
    <xsd:element name="releaseDate" type="xsd:date"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>









    share|improve this question

























      0












      0








      0








      I have a xml schema like the one being shown below but I have noticed that it would be very complicated to maintain.



      I want to improve the current schema in one of the following ways but I am not sure if they would be the best/correct route:



      Option 1: Use a reference of all elements of movieDetails within movies.



      Option 2: Add movieDetails as a sub-element of movies (which I frankly am struggling to achieve)



      Which route would be best and what would be the best way to structure it?



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

      <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://xml.netbeans.org/schema/AmazingMovies"
      xmlns:tns="http://xml.netbeans.org/schema/AmazingMovies"
      elementFormDefault="qualified">

      <xsd:complexType name="movies">
      <xsd:sequence>
      <xsd:element name="Title" type="xsd:string"/>
      <xsd:element name="Director" type="xsd:string"></xsd:element>
      <xsd:element name="Year" type="xsd:int"/>
      </xsd:sequence>
      </xsd:complexType>

      <xsd:complexType name="movieDetails">
      <xsd:sequence>
      <xsd:element name="Actor" type="xsd:string"/>
      <xsd:element name="numberOfCast" type="xsd:int"></xsd:element>
      <xsd:element name="releaseDate" type="xsd:date"/>
      </xsd:sequence>
      </xsd:complexType>

      <xsd:element name="OnDisplay">
      <xsd:complexType>
      <xsd:sequence >
      <xsd:element name="collectionOfMovies" type="tns:movies" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
      </xsd:complexType>
      </xsd:element>

      </xsd:schema>


      Extra information




      OnDisplay element would add all elements of movies into a list in order to use them when unMarshalling. However, I want to also add movieDetails onto OnDisplay, therefore, it would be convenient to have them included in movies as a ref, sub-element or another form.




      Tried the following methods but failed XML validation




      Method 1




      <xsd:element name="MoviesAndDetails">
      <xsd:complexType name="movies">
      <xsd:sequence>
      <xsd:element name="Title" type="xsd:string"/>
      <xsd:element name="Director" type="xsd:string"></xsd:element>
      <xsd:element name="Year" type="xsd:int"/>
      </xsd:sequence>
      </xsd:complexType>

      <xsd:complexType name="movieDetails">
      <xsd:sequence>
      <xsd:element name="Actor" type="xsd:string"/>
      <xsd:element name="numberOfCast" type="xsd:int"> </xsd:element>
      <xsd:element name="releaseDate" type="xsd:date"/>
      </xsd:sequence>
      </xsd:complexType>
      </xsd:element>



      Method 2




      <xsd:complexType name="MoviesAndDetails">
      <xsd:complexType name="movies">
      <xsd:sequence>
      <xsd:element name="Title" type="xsd:string"/>
      <xsd:element name="Director" type="xsd:string"></xsd:element>
      <xsd:element name="Year" type="xsd:int"/>
      <xsd:element ref="Actor"/>
      <xsd:element ref="numberOfCast"/>
      <xsd:element ref="releaseDate"/>
      </xsd:sequence>
      </xsd:complexType>

      <xsd:complexType name="movieDetails">
      <xsd:sequence>
      <xsd:element name="Actor" type="xsd:string"/>
      <xsd:element name="numberOfCast" type="xsd:int"> </xsd:element>
      <xsd:element name="releaseDate" type="xsd:date"/>
      </xsd:sequence>
      </xsd:complexType>
      </xsd:element>









      share|improve this question














      I have a xml schema like the one being shown below but I have noticed that it would be very complicated to maintain.



      I want to improve the current schema in one of the following ways but I am not sure if they would be the best/correct route:



      Option 1: Use a reference of all elements of movieDetails within movies.



      Option 2: Add movieDetails as a sub-element of movies (which I frankly am struggling to achieve)



      Which route would be best and what would be the best way to structure it?



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

      <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://xml.netbeans.org/schema/AmazingMovies"
      xmlns:tns="http://xml.netbeans.org/schema/AmazingMovies"
      elementFormDefault="qualified">

      <xsd:complexType name="movies">
      <xsd:sequence>
      <xsd:element name="Title" type="xsd:string"/>
      <xsd:element name="Director" type="xsd:string"></xsd:element>
      <xsd:element name="Year" type="xsd:int"/>
      </xsd:sequence>
      </xsd:complexType>

      <xsd:complexType name="movieDetails">
      <xsd:sequence>
      <xsd:element name="Actor" type="xsd:string"/>
      <xsd:element name="numberOfCast" type="xsd:int"></xsd:element>
      <xsd:element name="releaseDate" type="xsd:date"/>
      </xsd:sequence>
      </xsd:complexType>

      <xsd:element name="OnDisplay">
      <xsd:complexType>
      <xsd:sequence >
      <xsd:element name="collectionOfMovies" type="tns:movies" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
      </xsd:complexType>
      </xsd:element>

      </xsd:schema>


      Extra information




      OnDisplay element would add all elements of movies into a list in order to use them when unMarshalling. However, I want to also add movieDetails onto OnDisplay, therefore, it would be convenient to have them included in movies as a ref, sub-element or another form.




      Tried the following methods but failed XML validation




      Method 1




      <xsd:element name="MoviesAndDetails">
      <xsd:complexType name="movies">
      <xsd:sequence>
      <xsd:element name="Title" type="xsd:string"/>
      <xsd:element name="Director" type="xsd:string"></xsd:element>
      <xsd:element name="Year" type="xsd:int"/>
      </xsd:sequence>
      </xsd:complexType>

      <xsd:complexType name="movieDetails">
      <xsd:sequence>
      <xsd:element name="Actor" type="xsd:string"/>
      <xsd:element name="numberOfCast" type="xsd:int"> </xsd:element>
      <xsd:element name="releaseDate" type="xsd:date"/>
      </xsd:sequence>
      </xsd:complexType>
      </xsd:element>



      Method 2




      <xsd:complexType name="MoviesAndDetails">
      <xsd:complexType name="movies">
      <xsd:sequence>
      <xsd:element name="Title" type="xsd:string"/>
      <xsd:element name="Director" type="xsd:string"></xsd:element>
      <xsd:element name="Year" type="xsd:int"/>
      <xsd:element ref="Actor"/>
      <xsd:element ref="numberOfCast"/>
      <xsd:element ref="releaseDate"/>
      </xsd:sequence>
      </xsd:complexType>

      <xsd:complexType name="movieDetails">
      <xsd:sequence>
      <xsd:element name="Actor" type="xsd:string"/>
      <xsd:element name="numberOfCast" type="xsd:int"> </xsd:element>
      <xsd:element name="releaseDate" type="xsd:date"/>
      </xsd:sequence>
      </xsd:complexType>
      </xsd:element>






      xml xsd xml-schema-collection






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 29 '18 at 1:22









      JCassioJCassio

      416




      416
























          1 Answer
          1






          active

          oldest

          votes


















          0














          If you want to have a movieDetails element as a child of collectionOfMovies, then you could add a movieDetails element of type tns:movieDetails to the sequence of movies elements.



          <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
          targetNamespace="http://xml.netbeans.org/schema/AmazingMovies"
          xmlns:tns="http://xml.netbeans.org/schema/AmazingMovies"
          elementFormDefault="qualified">

          <xsd:complexType name="movies">
          <xsd:sequence>
          <xsd:element name="Title" type="xsd:string"/>
          <xsd:element name="Director" type="xsd:string"></xsd:element>
          <xsd:element name="Year" type="xsd:int"/>
          <xsd:element name="movieDetails" type="tns:movieDetails"/>
          </xsd:sequence>
          </xsd:complexType>

          <xsd:complexType name="movieDetails">
          <xsd:sequence>
          <xsd:element name="Actor" type="xsd:string"/>
          <xsd:element name="numberOfCast" type="xsd:int"></xsd:element>
          <xsd:element name="releaseDate" type="xsd:date"/>
          </xsd:sequence>
          </xsd:complexType>

          <xsd:element name="OnDisplay">
          <xsd:complexType>
          <xsd:sequence >
          <xsd:element name="collectionOfMovies" type="tns:movies" minOccurs="0" maxOccurs="unbounded"/>
          </xsd:sequence>
          </xsd:complexType>
          </xsd:element>

          </xsd:schema>





          share|improve this answer
























          • Thank you... That's exactly what I needed. Just didn't know how to add another element as a child element.

            – JCassio
            Nov 29 '18 at 13:33













          • I would like to receive one more input from you if possible... I was able to create a JAXB Binding in order to unMarshall the XML. I have created the object as follows OnDisplays todaysShow = new Ondisplays(); List<movies> movies_today = todaysShow.getMovieCollection(); Nonetheless, I am able to set elements such as Title, Director and Year, however, I thought that I would be able to also set elements of movieDetails this way but it only presents setmovieDetails and not the elements contained in it. How can I achieve this?

            – JCassio
            Nov 29 '18 at 23:57












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53530524%2fhow-to-improve-xml-schema-with-sub-elements-or-references%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          If you want to have a movieDetails element as a child of collectionOfMovies, then you could add a movieDetails element of type tns:movieDetails to the sequence of movies elements.



          <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
          targetNamespace="http://xml.netbeans.org/schema/AmazingMovies"
          xmlns:tns="http://xml.netbeans.org/schema/AmazingMovies"
          elementFormDefault="qualified">

          <xsd:complexType name="movies">
          <xsd:sequence>
          <xsd:element name="Title" type="xsd:string"/>
          <xsd:element name="Director" type="xsd:string"></xsd:element>
          <xsd:element name="Year" type="xsd:int"/>
          <xsd:element name="movieDetails" type="tns:movieDetails"/>
          </xsd:sequence>
          </xsd:complexType>

          <xsd:complexType name="movieDetails">
          <xsd:sequence>
          <xsd:element name="Actor" type="xsd:string"/>
          <xsd:element name="numberOfCast" type="xsd:int"></xsd:element>
          <xsd:element name="releaseDate" type="xsd:date"/>
          </xsd:sequence>
          </xsd:complexType>

          <xsd:element name="OnDisplay">
          <xsd:complexType>
          <xsd:sequence >
          <xsd:element name="collectionOfMovies" type="tns:movies" minOccurs="0" maxOccurs="unbounded"/>
          </xsd:sequence>
          </xsd:complexType>
          </xsd:element>

          </xsd:schema>





          share|improve this answer
























          • Thank you... That's exactly what I needed. Just didn't know how to add another element as a child element.

            – JCassio
            Nov 29 '18 at 13:33













          • I would like to receive one more input from you if possible... I was able to create a JAXB Binding in order to unMarshall the XML. I have created the object as follows OnDisplays todaysShow = new Ondisplays(); List<movies> movies_today = todaysShow.getMovieCollection(); Nonetheless, I am able to set elements such as Title, Director and Year, however, I thought that I would be able to also set elements of movieDetails this way but it only presents setmovieDetails and not the elements contained in it. How can I achieve this?

            – JCassio
            Nov 29 '18 at 23:57
















          0














          If you want to have a movieDetails element as a child of collectionOfMovies, then you could add a movieDetails element of type tns:movieDetails to the sequence of movies elements.



          <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
          targetNamespace="http://xml.netbeans.org/schema/AmazingMovies"
          xmlns:tns="http://xml.netbeans.org/schema/AmazingMovies"
          elementFormDefault="qualified">

          <xsd:complexType name="movies">
          <xsd:sequence>
          <xsd:element name="Title" type="xsd:string"/>
          <xsd:element name="Director" type="xsd:string"></xsd:element>
          <xsd:element name="Year" type="xsd:int"/>
          <xsd:element name="movieDetails" type="tns:movieDetails"/>
          </xsd:sequence>
          </xsd:complexType>

          <xsd:complexType name="movieDetails">
          <xsd:sequence>
          <xsd:element name="Actor" type="xsd:string"/>
          <xsd:element name="numberOfCast" type="xsd:int"></xsd:element>
          <xsd:element name="releaseDate" type="xsd:date"/>
          </xsd:sequence>
          </xsd:complexType>

          <xsd:element name="OnDisplay">
          <xsd:complexType>
          <xsd:sequence >
          <xsd:element name="collectionOfMovies" type="tns:movies" minOccurs="0" maxOccurs="unbounded"/>
          </xsd:sequence>
          </xsd:complexType>
          </xsd:element>

          </xsd:schema>





          share|improve this answer
























          • Thank you... That's exactly what I needed. Just didn't know how to add another element as a child element.

            – JCassio
            Nov 29 '18 at 13:33













          • I would like to receive one more input from you if possible... I was able to create a JAXB Binding in order to unMarshall the XML. I have created the object as follows OnDisplays todaysShow = new Ondisplays(); List<movies> movies_today = todaysShow.getMovieCollection(); Nonetheless, I am able to set elements such as Title, Director and Year, however, I thought that I would be able to also set elements of movieDetails this way but it only presents setmovieDetails and not the elements contained in it. How can I achieve this?

            – JCassio
            Nov 29 '18 at 23:57














          0












          0








          0







          If you want to have a movieDetails element as a child of collectionOfMovies, then you could add a movieDetails element of type tns:movieDetails to the sequence of movies elements.



          <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
          targetNamespace="http://xml.netbeans.org/schema/AmazingMovies"
          xmlns:tns="http://xml.netbeans.org/schema/AmazingMovies"
          elementFormDefault="qualified">

          <xsd:complexType name="movies">
          <xsd:sequence>
          <xsd:element name="Title" type="xsd:string"/>
          <xsd:element name="Director" type="xsd:string"></xsd:element>
          <xsd:element name="Year" type="xsd:int"/>
          <xsd:element name="movieDetails" type="tns:movieDetails"/>
          </xsd:sequence>
          </xsd:complexType>

          <xsd:complexType name="movieDetails">
          <xsd:sequence>
          <xsd:element name="Actor" type="xsd:string"/>
          <xsd:element name="numberOfCast" type="xsd:int"></xsd:element>
          <xsd:element name="releaseDate" type="xsd:date"/>
          </xsd:sequence>
          </xsd:complexType>

          <xsd:element name="OnDisplay">
          <xsd:complexType>
          <xsd:sequence >
          <xsd:element name="collectionOfMovies" type="tns:movies" minOccurs="0" maxOccurs="unbounded"/>
          </xsd:sequence>
          </xsd:complexType>
          </xsd:element>

          </xsd:schema>





          share|improve this answer













          If you want to have a movieDetails element as a child of collectionOfMovies, then you could add a movieDetails element of type tns:movieDetails to the sequence of movies elements.



          <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
          targetNamespace="http://xml.netbeans.org/schema/AmazingMovies"
          xmlns:tns="http://xml.netbeans.org/schema/AmazingMovies"
          elementFormDefault="qualified">

          <xsd:complexType name="movies">
          <xsd:sequence>
          <xsd:element name="Title" type="xsd:string"/>
          <xsd:element name="Director" type="xsd:string"></xsd:element>
          <xsd:element name="Year" type="xsd:int"/>
          <xsd:element name="movieDetails" type="tns:movieDetails"/>
          </xsd:sequence>
          </xsd:complexType>

          <xsd:complexType name="movieDetails">
          <xsd:sequence>
          <xsd:element name="Actor" type="xsd:string"/>
          <xsd:element name="numberOfCast" type="xsd:int"></xsd:element>
          <xsd:element name="releaseDate" type="xsd:date"/>
          </xsd:sequence>
          </xsd:complexType>

          <xsd:element name="OnDisplay">
          <xsd:complexType>
          <xsd:sequence >
          <xsd:element name="collectionOfMovies" type="tns:movies" minOccurs="0" maxOccurs="unbounded"/>
          </xsd:sequence>
          </xsd:complexType>
          </xsd:element>

          </xsd:schema>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 29 '18 at 1:32









          Mads HansenMads Hansen

          45k1195122




          45k1195122













          • Thank you... That's exactly what I needed. Just didn't know how to add another element as a child element.

            – JCassio
            Nov 29 '18 at 13:33













          • I would like to receive one more input from you if possible... I was able to create a JAXB Binding in order to unMarshall the XML. I have created the object as follows OnDisplays todaysShow = new Ondisplays(); List<movies> movies_today = todaysShow.getMovieCollection(); Nonetheless, I am able to set elements such as Title, Director and Year, however, I thought that I would be able to also set elements of movieDetails this way but it only presents setmovieDetails and not the elements contained in it. How can I achieve this?

            – JCassio
            Nov 29 '18 at 23:57



















          • Thank you... That's exactly what I needed. Just didn't know how to add another element as a child element.

            – JCassio
            Nov 29 '18 at 13:33













          • I would like to receive one more input from you if possible... I was able to create a JAXB Binding in order to unMarshall the XML. I have created the object as follows OnDisplays todaysShow = new Ondisplays(); List<movies> movies_today = todaysShow.getMovieCollection(); Nonetheless, I am able to set elements such as Title, Director and Year, however, I thought that I would be able to also set elements of movieDetails this way but it only presents setmovieDetails and not the elements contained in it. How can I achieve this?

            – JCassio
            Nov 29 '18 at 23:57

















          Thank you... That's exactly what I needed. Just didn't know how to add another element as a child element.

          – JCassio
          Nov 29 '18 at 13:33







          Thank you... That's exactly what I needed. Just didn't know how to add another element as a child element.

          – JCassio
          Nov 29 '18 at 13:33















          I would like to receive one more input from you if possible... I was able to create a JAXB Binding in order to unMarshall the XML. I have created the object as follows OnDisplays todaysShow = new Ondisplays(); List<movies> movies_today = todaysShow.getMovieCollection(); Nonetheless, I am able to set elements such as Title, Director and Year, however, I thought that I would be able to also set elements of movieDetails this way but it only presents setmovieDetails and not the elements contained in it. How can I achieve this?

          – JCassio
          Nov 29 '18 at 23:57





          I would like to receive one more input from you if possible... I was able to create a JAXB Binding in order to unMarshall the XML. I have created the object as follows OnDisplays todaysShow = new Ondisplays(); List<movies> movies_today = todaysShow.getMovieCollection(); Nonetheless, I am able to set elements such as Title, Director and Year, however, I thought that I would be able to also set elements of movieDetails this way but it only presents setmovieDetails and not the elements contained in it. How can I achieve this?

          – JCassio
          Nov 29 '18 at 23:57




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53530524%2fhow-to-improve-xml-schema-with-sub-elements-or-references%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Contact image not getting when fetch all contact list from iPhone by CNContact

          count number of partitions of a set with n elements into k subsets

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks