Jump to content
Sign in to follow this  
Guest Davidb

Help with repeating tag substitution groups

Recommended Posts

Guest Davidb

Hi,I'm currently having an issue with defining a schema.My XML structure looks like this:

<document>   <letter>	<header>...</header>	<data1>...</data1>	<data2>...</data2>   </letter>   <letter>	<header>...</header>	<data2>...</data2>	<data4>...</data4>	<data1>...</data1>   </letter></document>

Each letter is repeated, with a header first, then a mixture of "data" tag which can be in any order,but can only occur once. The "data" tags are defined by substitution groups and are complex types.Here is my schema:

<xs:element name="document"> <xs:complexType>  <xs:sequence>   <xs:element name="letter" type="letter" minOccurs="1" maxOccurs="unbounded" />  </xs:sequence> </xs:complexType></xs:element><xs:complexType name="letter"> <xs:sequence>  <xs:element ref="header" />  <xs:element ref="DataBlock" minOccurs="1" maxOccurs="unbounded" /> </xs:sequence></xs:complexType><xs:element name="header">...</xs:element><xs:element name="DataBlock" type="DataBlockType" abstract="true" /><xs:complexType name="DataBlockType" abstract="true" /><xs:element name="data1" substitutionGroup="DataBlock"> <xs:complexType>  <xs:complexContent>   <xs:extension base="DataBlockType">	<xs:sequence>	 <xs:element name="id" type="xs:integer" />	</xs:sequence>   </xs:extension>  </xs:complexContent> </xs:complexType></xs:element>... etc ...

My problem is how to get the "DataBlock" tags to only repeat once. The above workds fine execpt that the tags can be repeated. I have tried combinationsof xs:choice, xs:all, but I cannot get it to work.For example: this is valid, but shouldn't be:

<letter> <header>...</header> <data1>...</data1> <data2>...</data2> <data1>...</data1> <data1>...</data2></letter>

Any ideas?Thanks!David

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...