XSD XML 更正?
XSD correction on XML?
我的 xml
中的数据显示为:
<xs:element name="location">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="coords"/>
</xs:sequence>
</xs:complexType>
</xs:element>
我想要模式来修复高度的位置
<location>
<coords>
13.45,12.25,2.33
</coords>
</location>
简单为 13.45,12.25(省略身高)
这可以被 XSD 强制执行吗?
我认为最好的办法是使用正则表达式来强制执行检查。应该是以下几行:
<xs:element name="location">
<xs:complexType>
<xs:sequence>
<xs:element type="no-height-coords" name="coords"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="no-height-coords">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]+\.[0-9]+,[0-9]+\.[0-9]+"/>
</xs:restriction>
</xs:simpleType>
我的 xml
中的数据显示为:
<xs:element name="location">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="coords"/>
</xs:sequence>
</xs:complexType>
</xs:element>
我想要模式来修复高度的位置
<location>
<coords>
13.45,12.25,2.33
</coords>
</location>
简单为 13.45,12.25(省略身高)
这可以被 XSD 强制执行吗?
我认为最好的办法是使用正则表达式来强制执行检查。应该是以下几行:
<xs:element name="location">
<xs:complexType>
<xs:sequence>
<xs:element type="no-height-coords" name="coords"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="no-height-coords">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]+\.[0-9]+,[0-9]+\.[0-9]+"/>
</xs:restriction>
</xs:simpleType>