XML XSD xs:restriction 枚举不同问题

huangapple go评论55阅读模式
英文:

XML XSD problem with xs:restriction for different enumeration

问题

I generated XSD file from my xml.
我从我的xml生成了XSD文件。

xml...
xml...

<Edits> <Item id="AlignmentLargerThanSize">0.0</Item> <Item id="Machine">PI-8200</Item> <Item id="PackagePCBNames">Deepest level</Item> <Item id="ManualExactOutlineStroke">10.0</Item> <Item id="AlignmentPoint1Y">0.0</Item> <Item id="PolarityComboBox">Positive</Item> <Item id="AlignmentLessThanSize">10.0</Item>

generated xsd made...
生成的XSD文件如下...

<xs:element name="Item"> <xs:complexType> <xs:simpleContent> <xs:extension base="ST_Item"> <xs:attribute name="id" use="required"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="AlignmentLargerThanSize"/> <xs:enumeration value="Machine"/> <xs:enumeration value="PackagePCBNames"/> <xs:enumeration value="ManualExactOutlineStroke"/> <xs:enumeration value="AlignmentPoint1Y"/> <xs:enumeration value="PolarityComboBox"/> <xs:enumeration value="AlignmentLessThanSize"/>

then the restriction was made like...
然后进行了如下的限制...

<xs:simpleType name="ST_Item"> <xs:restriction base="xs:string"> <xs:enumeration value=""/> <xs:enumeration value="0"/>

!!!! But I need specific restiction for each enumeration!!!!
!!!! 但我需要为每个枚举值定义特定的限制!!!!

Something like..
类似于...

<xs:simpleType name="Item1" id="AlignmentLessThanSize"> <xs:restriction base="xs:decimal"> <xs:minInclusive value="0"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="Item2" id="AlignmentLargerThanSize"> <xs:restriction base="xs:decimal"> <xs:minExclusive value="0"/> </xs:restriction> </xs:simpleType>

英文:

I generated XSD file from my xml.
xml...

`				    <Edits>
					<Item id="AlignmentLargerThanSize">0.0</Item>
					<Item id="Machine">PI-8200</Item>
					<Item id="PackagePCBNames">Deepest level</Item>
					<Item id="ManualExactOutlineStroke">10.0</Item>
					<Item id="AlignmentPoint1Y">0.0</Item>
					<Item id="PolarityComboBox">Positive</Item>
					<Item id="AlignmentLessThanSize">10.0</Item>`

generated xsd made...

`	<xs:element name="Item">
		<xs:complexType>
			<xs:simpleContent>
				<xs:extension base="ST_Item">
					<xs:attribute name="id" use="required">
						<xs:simpleType>
<xs:restriction base="xs:string">								<xs:enumeration value="AlignmentLargerThanSize"/>
<xs:enumeration value="Machine"/>
<xs:enumeration value="PackagePCBNames"/>
<xs:enumeration value="ManualExactOutlineStroke"/>
<xs:enumeration value="AlignmentPoint1Y"/>
<xs:enumeration value="PolarityComboBox"/>
<xs:enumeration value="AlignmentLessThanSize"/>

`
then the restriction was made like...

`	<xs:simpleType name="ST_Item">
		<xs:restriction base="xs:string">
			<xs:enumeration value=""/>
			<xs:enumeration value="0"/>

`
!!!! But I need specific restiction for each enumeration!!!!

Something like..

	`<xs:simpleType name="Item1" id="AlignmentLessThanSize">
		<xs:restriction base="xs:decimal">
			<xs:minInclusive value="0"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="Item2" id="AlignmentLargerThanSize">
		<xs:restriction base="xs:decimal">
			   <xs:minExclusive value="0"/>
		</xs:restriction>
	</xs:simpleType>`

答案1

得分: 0

当一个XML文档包含多个具有相同名称的兄弟元素时,XSD规则要求这些元素必须具有相同的类型。不能为第一个元素声明一种类型,为第二个元素声明另一种类型,依此类推。该规则称为“元素声明一致性”,如果您想查找相关信息的话。

英文:

When an XML document contains several sibling elements with the same name, it's an XSD rule that those elements must all have the same type. You can't declare one type for the first element, another type for the second, and so on. The rule is called "Element Declarations Consistent", if you want to look it up.

huangapple
  • 本文由 发表于 2023年7月3日 19:32:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/76604328.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定