【问题标题】:JAXB binding error, "Content must match...?"JAXB 绑定错误,“内容必须匹配...?”
【发布时间】:2013-07-30 02:57:37
【问题描述】:

我已经编写了一个 .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:

这里是shema:

<?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>

任何人都可以向我解释该错误的具体含义和/或纠正它吗?谢谢。

【问题讨论】:

    标签: java xml jaxb schema yql


    【解决方案1】:

    我想问题是您在“complexType”定义(位于文件底部)之外复制的 3 个属性(计数、创建、语言)。

    【讨论】:

    • 哎呀应该使用复制粘贴,抱歉实际文件只包含一次这些属性。我会在我的问题中解决这个问题。
    猜你喜欢
    • 2014-05-15
    • 1970-01-01
    • 2011-08-08
    • 2023-03-30
    • 1970-01-01
    • 2017-03-22
    • 1970-01-01
    • 1970-01-01
    • 2016-12-08
    相关资源
    最近更新 更多