DTD属性分隔符

时间:2015-01-14 14:55:16

标签: xml dtd

如何在DTD中设置属性值将被分割为分隔符?



<element
  attr="value_1|value_2|value_3|..."
/>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

使用DTD,您无法验证元素/属性文本值。你只能定义一个元素是否应该计算更多的元素(哪些元素和哪个元素),如果属性是否需要,它的值......

如果需要检查属性的文本值,则应使用XML Schema而不是DTD。 您需要使用正则表达式模式对属性值进行限制以检查文本值。这样的事情对你有用:

<xs:attribute name="attribute">
    <xs:simpleType>
        <xs:restriction base="xs:integer">
            <xs:pattern value="patern here"/>
        </xs:restriction>
    </xs:simpleType>
</xs:attribute>
相关问题