JAXB绑定错误,“内容必须匹配......?”

时间:2013-07-29 18:27:18

标签: java xml jaxb schema yql

我已经编写了一个.xsd架构(下面)用于Yahoo的YQL yahoo.finance.quote table 。但是当我使用xjc绑定模式时,我得到以下错误:

[ERROR] s4s-elt-must-match.1: The content of 'query' must match (annotation?, (simpleType | complexType)?, (unique | key | keyref)*)). A problem was found starting at: attribute.
  line 35 of file:

这是谢玛:

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

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:yahoo="http://www.yahooapis.com/v1/base.rng">
  <xsd:element name="query">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="results" minOccurs="0" maxOccurs="1">
          <xsd:complexType>
            <xsd:sequence>
              <xsd:element name="quote" minOccurs="0" maxOccurs="unbounded">
                <xsd:complexType>
                  <xsd:sequence>
                    <xsd:element name="AverageDailyVolume" minOccurs="0" maxOccurs="1" type="xsd:int"/>
                    <xsd:element name="Change" minOccurs="0" maxOccurs="1" type="xsd:decimal"/>
                    <xsd:element name="DaysLow" minOccurs="0" maxOccurs="1" type="xsd:decimal"/>
                    <xsd:element name="DaysHigh" minOccurs="0" maxOccurs="1" type="xsd:decimal"/>
                    <xsd:element name="YearLow" minOccurs="0" maxOccurs="1" type="xsd:decimal"/>
                    <xsd:element name="YearHigh" minOccurs="0" maxOccurs="1" type="xsd:decimal"/>
                    <xsd:element name="MarketCapitalization" minOccurs="0" maxOccurs="1" type="xsd:normalizedString"/>
                    <xsd:element name="LastTradePriceOnly" minOccurs="0" maxOccurs="1" type="xsd:decimal"/>
                    <xsd:element name="DaysRange" minOccurs="0" maxOccurs="1" type="xsd:string"/>
                    <xsd:element name="Name" minOccurs="0" maxOccurs="1" type="xsd:string"/>
                    <xsd:element name="Symbol" minOccurs="0" maxOccurs="1" type="xsd:normalizedString"/>
                    <xsd:element name="Volume" minOccurs="0" maxOccurs="1" type="xsd:int"/>
                    <xsd:element name="StockExchange" minOccurs="0" maxOccurs="1" type="xsd:normalizedString"/>
                  </xsd:sequence>
                  <xsd:attribute name="symbol" type="xsd:normalizedString" use="required"/>
                </xsd:complexType>
              </xsd:element>
            </xsd:sequence>
          </xsd:complexType>
        </xsd:element>
      </xsd:sequence>
      <xsd:attribute name="count" type="xsd:int" use="required"/>
      <xsd:attribute name="created" type="xsd:normalizedString" use="required"/>
      <xsd:attribute name="lang" type="xsd:normalizedString" use="required"/>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>

有人可以向我解释这个错误具体意味着什么和/或纠正它?谢谢。

1 个答案:

答案 0 :(得分:2)

我认为问题是你在“complexType”定义之外复制的3个属性(count,created,lang)(在文件的底部)。