我有以下复杂类型:
<xs:complexType name="ValuePropertyType">
<xs:complexContent>
<xs:extension base="xs:anyType">
<xs:attribute name="recordCount" type="xs:positiveInteger"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
它是否允许简单的文本内容?喜欢:
<my:values>
2007-04-01T00:00:00.000-06:00,30.4,28.8,155.8,1055.32,55,haze
2007-04-01T00:00:10.000-06:00,30.4,28.8,155.8,1055.4,59,haze
</my:values>
我认为确实如此,但在 XML 模式规范中找到规范引用相当……困难。
我问也是因为 JAXB XJC 在这里生成以下属性:
@XmlAnyElement
protected List<Element> any;
只需要元素。我认为它也应该允许文本。
更新
Xerces、Eclipse(无论它在下面使用什么)、Stylus Studio 和 Oxygen 已验证 this example反对this schema .具体来说,这是 complex type有问题:
<xs:complexType name="DataValuePropertyType">
<xs:annotation>
<xs:documentation>Use to point or include data values inline</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="xs:anyType">
<xs:attribute name="recordCount" type="xs:positiveInteger"/>
<xs:attributeGroup ref="gml:AssociationAttributeGroup"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
最佳答案
具有 complexContent
的复杂类型不允许将文本内容作为子项,除非它被声明为 mixed="true"
。如果你将它混合,那么它允许任意文本节点混合在内容模型允许的任何元素中,你不能将文本限制为特定类型(除非你使用 simpleContent
,但那样的话根本不允许子元素)。
关于xml - 复杂扩展 xs :anyType allow textual content?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29455790/