首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ComplexType模型

ComplexType模型
EN

Stack Overflow用户
提问于 2013-09-29 12:10:36
回答 1查看 77关注 0票数 1

我对XML完全陌生,我正试图把基本知识弄清楚。这是ComplexType的模型。我不明白,我怎么能读到内容部分。问题列表,wich元素可以包含ComplexType )。

代码语言:javascript
复制
<complexType
  abstract = Boolean : false 
  block = (#all | List of (extension | restriction))
  final = (#all | List of (extension | restriction))
  id = ID 
  mixed = Boolean : false
  name = NCName 
  {any attributes with non-schema Namespace...}>
Content: (annotation?, (simpleContent | complexContent | ((group | all | 
choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?))))
</complexType>

complexType中模型语法中的下列符号或运算符ar

代码语言:javascript
复制
?            = ( one or no of this element) 
*            = ( several or no of this element) 
no operator  = (  does mean one of this element) 
|            = ( is this e OR ? )

我尝试了以下组合,这是可能的:

代码语言:javascript
复制
annotation, simpleContent
simpleContent
annotation, complexContent
complexContent

在下面的组合中,我们是否可以放置代替序列,还有这个精灵,群,所有,选择(我忽略了anyAttribut元素)

代码语言:javascript
复制
annotation,sequence,attributeA,attributeB,attributeGroupeA
sequence,attributeA,attributeB,attributeGroupeA
attributeA,attributeB,attributeGroupeA
attributeA
attributeGroupeA

正如我们所看到的,有可能有这样的组合,attributeA,attributeB,attributeGroupeA,这就是我在wiche的概念中的要点--我在“模型语法”中不理解。

代码语言:javascript
复制
((attribute | attributeGroup)*, anyAttribute?))

由于使用了\x符号,因此不可能有以下组合

代码语言:javascript
复制
attributeA,attributeB,attributeGroupeA

我读错什么了?

代码语言:javascript
复制
(attribute | attributeGroup)*

这个语法对我来说意味着。我有以下可能的组合

代码语言:javascript
复制
attributeA,attributeB
attribute
attributeGroupeA,attriubteGroupeB
attributeGroupeA
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-29 14:35:42

(attribute | attributeGroup)理解为允许attributeattributeGroup

(attribute | attributeGroup)*理解为允许零或多个attributeattributeGroup。每次您返回到另一个可能出现的attributeattributeGroup时,您可以再次选择其中之一。因此,该构造允许在任何attribute中任意序列为零或多个或。

因此,以完整的XML术语来说,BNFforcomplexType支持以下Type定义

代码语言:javascript
复制
<?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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19077903

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档