Question

I am entirely new to XML Schema and am trying to get the basics down. Here is the Model of ComplexType. I do not understand, how i can read the Content Part. The Questions ist, wich element can the ComplexType contain).

<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>

The following Symbols or Operators ar in the Model Syntax in the complexType

?            = ( one or no of this element) 
*            = ( several or no of this element) 
no operator  = (  does mean one of this element) 
|            = ( is this e OR ? )

i tried the following combination, it is possible:

annotation, simpleContent
simpleContent
annotation, complexContent
complexContent

In the following combinations, could we place instead of sequence, also this elemens, groupe, all, choice ( and i ignored the anyAttribut element)

annotation,sequence,attributeA,attributeB,attributeGroupeA
sequence,attributeA,attributeB,attributeGroupeA
attributeA,attributeB,attributeGroupeA
attributeA
attributeGroupeA

As we cann see it is possible to have this combination, attributeA,attributeB,attributeGroupeA and this is the point in my concept in wiche i dont understand in the Model the Syntax.

((attribute | attributeGroup)*, anyAttribute?))

Because of the | Symbol it should not be possible to have the following combinations

attributeA,attributeB,attributeGroupeA

What i do read wrong ?

(attribute | attributeGroup)*

This Syntax does mean for me. i have the following possibilites of combinations

attributeA,attributeB
attribute
attributeGroupeA,attriubteGroupeB
attributeGroupeA
Was it helpful?

Solution

Read (attribute | attributeGroup) as allowing either attribute or attributeGroup.

Read (attribute | attributeGroup)* as allowing zero or more of attribute or attributeGroup. Each time you go back for another possible occurrence of an attribute or attributeGroup, you may again choose either one. Therefore, this construct allows an arbitrary sequence of zero or more attribute or attributeGroup in any order.

So, in full XML Schema terms, for example, the following Type definition is supported by the BNF for complexType:

<?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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top