英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论