我正在编写一个xsd模式,它通过使用redefine元素来重新定义一个其他模式。
就像这样:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:redefine schemaLocation="some_schema.xsd">
.....
</xs:redefine>
</xs:schema>有人能告诉我如何在上下文中定义新类型吗?
<xs:simpleType name="restrictedString">
<!-- Make a new type to be a "descendant" of string-->
<xs:restriction base="xs:string">
<xs:maxLength value="36"/>
</xs:restriction>
</xs:simpleType>谢谢。
发布于 2014-06-16 15:48:06
好的,所以这个解决方案其实很简单。
必须在重新定义块之后指定自定义类型(restrictedString):
<xs:schema ....>
<xs:redefine ......>
.....
<use of type restrictedString>
</xs:redefine>
<xs:simpleType name="restrictedString">
.... type definition
</xs:simpleType>
</xs:schema>在重新定义块之前或在重定义块内执行此操作不起作用,但是在文档的末尾是可以的。
谢谢。
https://stackoverflow.com/questions/24245064
复制相似问题