我有和XSD在模式生成期间出现以下错误。
org.xml.sax.SAXParseException; systemId: file:/D:/Basil/Projects/myproducts.xsd; lineNumber: 577; columnNumber: 50; cos-all-limited.1.2: An 'all' model group must appear in a particle with '{'min occurs'}' = '{'max occurs'}' = 1, and that particle must be part of a pair which constitutes the '{'content type'}' of a complex type definition.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:437)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaErr(XSDHandler.java:4124)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaError(XSDHandler.java:4107)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:588)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:555)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:521)
at com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.newSchema(XMLSchemaFactory.java:240)
at com.sun.tools.xjc.reader.xmlschema.parser.SchemaConstraintChecker.check(SchemaConstraintChecker.java:101)
at com.sun.tools.xjc.ModelLoader.loadXMLSchema(ModelLoader.java:357)
at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:167)
at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:113)
at com.sun.tools.xjc.Driver.run(Driver.java:313)
at org.codehaus.mojo.jaxb2.AbstractXjcMojo.execute(AbstractXjcMojo.java:298)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
下面粘贴了相关的XSD。我无法理解实际的错误是什么。错误是在结束的第三行。请帮忙。
<xs:group name="prodVar">
<xs:all>
<xs:element name="prodVar" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="varName" type="xs:string" minOccurs="0" maxOccurs="unbounded" />
<xs:element ref="skuList" />
<xs:element name="vStory" type="xs:string" minOccurs="0" />
<xs:element ref="attList" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="colorSwatchList" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="unbounded">
<xs:element name="colorSwatch" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="swatchName" type="xs:string" minOccurs="0" />
<xs:element name="swatchHeight" type="xs:string" minOccurs="0" />
<xs:element name="swatchWidth" type="xs:string" minOccurs="0" />
<xs:element name="colorName" type="xs:string" minOccurs="0" />
<xs:element name="mainImageHeight" type="xs:string" minOccurs="0" />
<xs:element name="mainImageWidth" type="xs:string" minOccurs="0" />
<xs:element name="mainImageName" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
</xs:group>
<!--lot of other stuff -->
<xs:element name="prodVarList" minOccurs="0" maxOccurs="1">
<xs:complexType> <!-- ERROR HERE -->
<xs:group ref="prodVar" minOccurs="0" maxOccurs="unbounded" />
</xs:complexType>
</xs:element>
答案 0 :(得分:4)
在maxOccurs="unbounded"
<xs:group ref="prodVar" minOccurs="0" maxOccurs="unbounded" />
在XSD 1.0中,xs:all
不能重复(这里间接,有些人可能会说'很好试试!'),也不能重复xs:all
下的任何粒子,也不能嵌套在任何其他合成器下。< / p>