【发布时间】:2016-01-25 09:41:26
【问题描述】:
我想允许一个元素是 xs:date 或空字符串。
这是我尝试过的 XML Schema:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:lp="urn:oio:ebst:diadem:lokalplan:1"
targetNamespace="urn:oio:ebst:diadem:lokalplan:1"
elementFormDefault="qualified" xml:lang="DA"
xmlns:m="urn:oio:ebst:diadem:metadata:1">
<xs:import schemaLocation="../key.xsd" namespace="urn:oio:ebst:diadem:metadata:1" />
<xs:element name="DatoVedtaget" type="lp:DatoVedtagetType" />
<xs:complexType name="DatoVedtagetType">
<xs:simpleContent>
<xs:extension base="xs:date">
<xs:attribute ref="m:key" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="DatoVedtagetTypeString">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute ref="m:key" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:schema>
如果元素包含一个值,我希望元素为DatoVedtagetType,如果它为空,我希望它为DatoVedtagetTypeString。我如何在这个架构中实现这样的条件功能?
【问题讨论】:
-
这不是说您希望
DatoVedtaget成为xs:date还是空的一种复杂的方式吗? -
如果可能的话是的