【问题标题】:s4s-elt-must-match.1 The content of X must match (annotation?, (simpleType | complexType)?, (unique | key | keyref)*))s4s-elt-must-match.1 X的内容必须匹配(annotation?, (simpleType | complexType)?, (unique | key | keyref)*))
【发布时间】:2017-10-03 20:27:34
【问题描述】:

我不断收到此错误:

s4s-elt-must-match.1: 'tvshow' 的内容必须匹配 (annotation?, (simpleType | complexType)?, (唯一 | key | keyref)*))。 发现问题始于:元素。

这是我的 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 中,但我并不完全确定。现在,Oxygen 告诉我从&lt;xs:element name="productioninformation"&gt; 开始是我搞砸的地方,但我找不到错误。任何帮助将不胜感激。

【问题讨论】:

    标签: xml xsd xsd-validation xml-validation


    【解决方案1】:

    您的直接错误是由于

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

    在你的 XSD 中应该是

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

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

    然后您会发现您的 XSD 至少有一个额外的、不相关的错误。希望你能自己解决。如果没有,请发布一个关于它的新问题。

    【讨论】:

    • 谢谢!我现在看到了错误!有时,当您长时间盯着代码时,很难区分小错误。我目前仍在修复所有问题,但从现在开始还不错。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-20
    • 2015-09-10
    • 1970-01-01
    • 1970-01-01
    • 2019-08-10
    相关资源
    最近更新 更多