xml - 复杂扩展 xs :anyType allow textual content?

标签 xml xsd jaxb xjc

我有以下复杂类型:

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

相关文章:

java - XML 错误 "document is invalid.no grammar found"

c# - excel xml窗口宽度属性

wpf - 如何在 WPF 中进行 128 位 XML 加密

java - android 无法设置按钮的宽度?

xml-parsing - 发现以元素 'country' 开头的无效内容。 '{country}' 之一是预期的.. 行 '10' ,列 '14'

java - JAXB : how to read the xsi:type value when unmarshalling

java - 如何使用 JAX-B 将两个 XML 合并为一个?

java - JAXB 内部实现接口(interface) com.sun.xml.bind.namespacePrefixMapper 的类加载器问题

c++ - 从 *.xsd 模式文件自动生成 objective-c 类

java - JaxB 和 Enum 绑定(bind)