【发布时间】:2012-12-25 12:37:47
【问题描述】:
我想我已经对此进行了很多搜索,但仍然没有。
将不胜感激。
我正在尝试限制内容为空的元素的属性。 “颜色”应该有一个限制,只能容纳 3 位数字或 minLength=3 和 maxLength=3。它不应该有任何内容。
<?xml version="1.0" encoding="utf-8"?>
<items xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="">
<product id="" name="">
<article id="1001">
<umbrella color="100"/>
<umbrella color="101"/>
</article>
<article id="1002">
<umbrella color="110"/>
</article>
</product>
</items>
编辑:我知道如何对 simpleType 进行 XSD 限制。但我不知道如何将它与 ComplexType 组合成一个实体。
如果您能提供更详细(或完整)的解决方案,我会很高兴。
顺便说一句,“颜色”不限于 xs:integer。它实际上是一个 xs:string。
【问题讨论】:
标签: attributes xsd restriction