[英]How to write an XML Schema for which this XML document is a valid instance?
<Unit Number="1">
<Identifier Type="ABC" Text="STO0001"/>
<Identifier Type="DEF" Text="Some Value"/>
<Identifier Type="GHI" Text="20070805"/>
<Disposition Unit="Accept"/>
</Unit>
我需要验证Type =“ DEF” Text =“ Some Value”是否为空
就像是:
<xs:complexType name="requiredValue" abstract="true"/>
<xs:complexType name="Identifier">
<xs:complexContent>
<xs:extension base="requiredValue">
<xs:attribute name="Type" use="required" fixed="DEF"/>
<xs:attribute name="Text" type="NonEmptyString"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
这并不完全是您想要的,但是它可能会帮助您完成大部分架构。
这允许您上载xml文件,它将创建xsd模式或DTD。
http://www.hitsw.com/xml_utilites/
这做同样的事情。
http://www.flame-ware.com/products/xml-2-xsd/Default.aspx
帕维尔提到Schematron。 为了帮助构造这些模式,您可能想使用pyang。
http://code.google.com/p/pyang/
使用xsd:minLength限制:
<xsd:attribute name="Type">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.