代码之家  ›  专栏  ›  技术社区  ›  OC1092

s4s elt必须匹配。1 X的内容必须匹配(注释?,(simpleType | complexType)?,(唯一|键|键参考)*)

  •  1
  • OC1092  · 技术社区  · 8 年前

    我一直遇到这个错误:

    s4s elt必须匹配。1: (唯一|键|键参考)*)。

    这是我的XML:

        <televisionshows xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.tvshow.com/2016/XMLSchema catalan_tvshow.xsd"
        xmlns="http://www.tvshow.com/2016/XMLSchema">
    
        <tvshow>
          <productioninformation>
            <rate>TV-PG</rate>
            <title>Home Movies</title>
            <runtime>30 minutes</runtime>
            <production>Squigglevision</production>
            <genre>Animation</genre>
            <genre>Comedy</genre>
            <distributors>
                <distribution>UPN</distribution>
                <distribution>Cartoon Network</distribution>
            </distributors>
            <creator>Loren Bouchard</creator>
            <creator>Brendon Small</creator>
            <director> Loren Bouchard</director>
           </productioninformation>  
    
            <synopsis>
                TV series about an eight-year old who makes movies with his friends Jason and Melissa. 
                Recurring characters include Brendon's mother, Paula; soccer coach John McGuirk; 
                musician Dwayne; and teacher Mr. Lynch.
            </synopsis>
    
                <cast>
                    <star>Brendon Smalls as Brendon</star>
                    <star>H. Jon Benjamin as Jason</star>
                    <star>Melissa Bardin Galsky as Melissa</star>
                    <star>Ron Lynch as Mr. Lynch</star>
                    <star>Paula Poundstone as Paula</star>
                    <star>H. Jon Benjamin as Coach McGuirk</star>
                </cast>
    
    
            <gueststars>
                <actor>Louis C.K.</actor>
                <actor>Mitch Hedberg</actor>
                <actor>They Might Be Giants</actor>
            </gueststars>
    
            <season no="1">
                <year>1999</year>
                <episode no="1">
                    <release_date>April 26, 1999</release_date>
                    <title>Get Away From My Mom</title>
                    <plot>
                        Brendon's mother Paula announces her plans to go   
                        on a  date with Brendon'ssoccer coach, Mr. McGuirk.
                    </plot>
                </episode>
                <episode no="2">
                    <release_date>May 3, 1999</release_date>
                    <title>I Don't Do Well in Parent Teacher Conferences</title>
                    <plot>
                        Brendon fails to give an   oral report in   school, 
                        so his mother is asked to attend a parent-teacher conference. 
                        However, she can't keep her sanity in such a  situation.
                    </plot>
                </episode>
                <episode no="3">
                    <release_date>May 10, 1999</release_date>
                    <title>The Art of the Sucker Punch</title>
                    <plot>
                        After Jason is   dragged through the mud by the school bully, 
                        Shannon, Brendon plots a rather selfish revenge match.
                    </plot>
                </episode>
                <episode no="4">
                     <release_date>May 17, 1999</release_date>
                     <title>Brendon Gets Rabies</title>
                     <plot>
                         Brendon volunteers to   take care of a  vacationing couple's pet cat. 
                         However, it escapes its house and later turns up with rabies.
                     </plot>
                </episode>
                <episode no="5">
                      <release_date>May 24, 1999</release_date>
                      <title>Yoko</title>
                      <plot>
                          While on   a  camping trip, Brendon and a female classmate, Loni, 
                          startbecoming an item, but Melissa and Jason can't stand the newest member of their movie troupe. 
                          Meanwhile, a foreign student plays a nasty prank on McGuirk.
                      </plot>
                </episode>
            </season>
            <season no="2">
                <year>2001</year>
                <episode no="1">
                    <release_date>Sep. 2, 2001</release_date>
                    <title>Director's Cut</title>
                    <plot>
                        Duane wants to   produce a  rock opera based on Franz Kafka's "The Metamorphosis" 
                        but runs into some stiff opposition from Brendon and his own project, a fictional 
                        meeting between Louis Braille and Louis Pasteur.
                    </plot>
                </episode>
                <episode no="2">
                    <release_date>Sep. 9, 2001</release_date>
                    <title>It Was Supposed to be Funny</title>
                    <plot>
                        Brendon films a  documentary about Melissa's grandfather 
                        that was supposed to be funny.
                    </plot>
                </episode>
                <episode no="3">
                    <release_date>Sep. 16, 2001</release_date>
                    <title>Method of Acting</title>
                    <plot>
                        Brendon auditions for a play and Paula teaches a  creative writing class.
                    </plot>
                </episode>
                <episode no="4">
                    <release_date>Sep. 21, 2001</release_date>
                    <title>Life through the Fisheye Lens</title>
                    <plot>
                        Brendon tries to get a  fisheye lens for his camera.
                    </plot>
                </episode>
                <episode no="5">
                    <release_date>Sep. 30, 2001</release_date>
                    <title>School Nurse</title>
                    <plot>
                        Brendon fakes being sick so the school nurse will send him home.
                    </plot>
                </episode>
                <episode no="6">
                    <release_date>Sep. 30, 2001</release_date>
                    <title>Mortages &amp; Marbles</title>
                    <plot>
                        Brendon's baby sister Josie has a  habit of shoving marbles into her nostrils, 
                        so he produces an educational film about this for extra credit in class. 
                        Coach McGuirk also turns to Erik for advice about buying a new house.
                    </plot>
                </episode>
                <episode no="7">
                    <release_date>Oct. 7, 2001</release_date>
                    <title>Law and Boarder</title>
                    <plot>
                        Brendon gets hit by a car while riding his bike and has to go
                        to court because he broke the law.
                    </plot>
                </episode>
                <episode no="8">
                    <release_date>Oct. 7, 2001</release_date>
                    <title>Brendon's Choice</title>
                    <plot>
                        Brendon is curious about his father.
                    </plot>
                </episode>
            </season>
        </tvshow>
    </televisionshows>
    

    这是我的XSD:

        <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
        xmlns="http://www.tvshow.com/2016/XMLSchema"
        targetNamespace="http://www.tvshow.com/2016/XMLSchema"
        elementFormDefault="qualified">
    
        <xs:element name="televisionshows">
           <xs:complexType>
           <xs:sequence>
             <xs:element name="tvshow">
    
                 <xs:element name="productioninformation">
                   <xs:complexType>
                       <xs:sequence>
                           <xs:element name="rate" type="xs:string" maxOccurs="unbounded"/>
                           <xs:element name="title" type="xs:string" maxOccurs="unbounded"/>
                           <xs:element name="runtime" type="xs:string" maxOccurs="unbounded"/>
                           <xs:element name="production" type="xs:string" maxOccurs="unbounded"/>
                           <xs:element name="genre" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
                           <xs:element name="distributors" maxOccurs="unbounded">
                               <xs:complexType>
                                   <xs:sequence>
                                        <xs:element name="distribution" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
                                   </xs:sequence>
                               </xs:complexType>
                           </xs:element>
                           <xs:element name="creator" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
                           <xs:element name="director" type="xs:string" maxOccurs="unbounded"/>
                       </xs:sequence>
                </xs:complexType>
               </xs:element>
    
            <xs:element name="synopsis" type="xs:string"/>
    
             <xs:element name="cast">
                 <xs:complexType>
                     <xs:sequence>
                         <xs:element name="star" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
                     </xs:sequence>
                 </xs:complexType>
             </xs:element>
    
         <xs:element name="gueststars">
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="actor" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
                </xs:sequence>
            </xs:complexType>
         </xs:element>
    
          <xs:element name="season">
              <xs:complexType>
                  <xs:sequence>
                      <xs:attribute name="no" type="xs:string"/>
                      <xs:element name="year" type="xs:string"/>
                      <xs:element name="episode">
                          <xs:complexType>
                              <xs:sequence>
                                <xs:element name="release_date" type="xs:string"/>
                                <xs:element name="title" type="xs:string"/>
                                <xs:element name="plot" type="xs:string"/>
                              </xs:sequence>
                              <xs:attribute name="no" type="xs:string" />
                          </xs:complexType>
                          </xs:element>
                  </xs:sequence>
               </xs:complexType>
          </xs:element> 
        </xs:element>
      </xs:sequence>
    </xs:complexType>        
    </xs:element>
    </xs:schema>
    

    我已经看了一段时间了,现在我已经迷失了方向。我认为问题出在我的XSD中,但我不能完全确定。现在,氧气告诉我从 <xs:element name="productioninformation"> 就是我把事情搞砸了,但我找不到错误。任何帮助都将不胜感激。

    1 回复  |  直到 8 年前
        1
  •  1
  •   kjhughes    8 年前

    您的即时错误是由于

        <xs:element name="tvshow">
          <xs:element name="productioninformation">
    

    在您的XSD中

        <xs:element name="tvshow">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="productioninformation">
    

    (当然,在所有这些之后添加必要的结束标记。) tvshow 的兄弟声明。)