Xml 复合型模型
我对XML模式完全陌生,正在尝试了解基本知识。 这是ComplexType的模型。我不明白,我怎么能读内容部分。问题是ComplexType可以包含的元素) 我尝试了以下组合, 有可能:Xml 复合型模型,xml,model,xsd,complextype,Xml,Model,Xsd,Complextype,我对XML模式完全陌生,正在尝试了解基本知识。 这是ComplexType的模型。我不明白,我怎么能读内容部分。问题是ComplexType可以包含的元素) 我尝试了以下组合, 有可能: annotation, simpleContent simpleContent annotation, complexContent complexContent 在下面的组合中,我们是否也可以用位置代替顺序 这个元素,groupe,all,choice(我忽略了anyAttribute元素) 正如我们所看到
annotation, simpleContent
simpleContent
annotation, complexContent
complexContent
在下面的组合中,我们是否也可以用位置代替顺序
这个元素,groupe,all,choice(我忽略了anyAttribute元素)
正如我们所看到的,有可能有这样的组合,attributeA,attributeB,attributeGroup,这就是我概念中的要点,我不知道
理解模型中的语法
((attribute | attributeGroup)*, anyAttribute?))
由于|符号,不可能有以下组合
attributeA,attributeB,attributeGroupeA
attributeA,attributeB
attribute
attributeGroupeA,attriubteGroupeB
attributeGroupeA
我读错了什么
(attribute | attributeGroup)*
这个语法对我来说确实有意义。我有以下几种可能的组合
attributeA,attributeB,attributeGroupeA
attributeA,attributeB
attribute
attributeGroupeA,attriubteGroupeB
attributeGroupeA
将(attribute | attributeGroup)
读为允许属性
或属性组
将(attribute | attributeGroup)*
读为允许零个或多个属性
或属性组
。每次返回到另一个可能出现的属性
或属性组
,您都可以再次选择其中一个。因此,此构造允许以任何顺序的零或多个属性
或属性组
的任意序列。
因此,例如,在完整的XML模式术语中,complexType
的BNF支持以下Type
定义:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.0">
<xs:attributeGroup name="AttributeGroupXY1">
<xs:attribute name="attributeX1"/>
<xs:attribute name="attributeY1"/>
</xs:attributeGroup>
<xs:attributeGroup name="AttributeGroupXY2">
<xs:attribute name="attributeX2"/>
<xs:attribute name="attributeY2"/>
</xs:attributeGroup>
<xs:complexType name="Type">
<xs:attribute name="attributeA"/>
<xs:attribute name="attributeB"/>
<xs:attributeGroup ref="AttributeGroupXY1"/>
<xs:attribute name="attributeC"/>
<xs:attributeGroup ref="AttributeGroupXY2"/>
</xs:complexType>
</xs:schema>
Hi tanks,我将再次开始提问,因为我的问题更多的是如何阅读语法,这是我的第一个问题,谢谢,我是新来的
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.0">
<xs:attributeGroup name="AttributeGroupXY1">
<xs:attribute name="attributeX1"/>
<xs:attribute name="attributeY1"/>
</xs:attributeGroup>
<xs:attributeGroup name="AttributeGroupXY2">
<xs:attribute name="attributeX2"/>
<xs:attribute name="attributeY2"/>
</xs:attributeGroup>
<xs:complexType name="Type">
<xs:attribute name="attributeA"/>
<xs:attribute name="attributeB"/>
<xs:attributeGroup ref="AttributeGroupXY1"/>
<xs:attribute name="attributeC"/>
<xs:attributeGroup ref="AttributeGroupXY2"/>
</xs:complexType>
</xs:schema>