Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old March 9th, 2006, 07:35 AM
1-crm@freenet.de
Guest
 
Posts: n/a
Default XML Schema - limit occurrence

Hi,

i'd like to validate my XML file (see below) using XML Schema.

Now my question: is it possible to limit the occurrence of the element
b in the data element.
I mean: data can contain up to 6 b elements, but it doesn't matter how
the b elements are allocated in the elements a and c.

Any help would be appreciated -- thank you!

XML File (shall be valid)
<data>
<a>
<b>...</b>
<b>...</b>
<b>...</b>
<b>...</b>
</a>
<c>
<b>...</b>
<b>...</b>
</c>
</data>

XML File (shall be valid too)
<data>
<a>
<b>...</b>
<b>...</b>
<b>...</b>
</a>
<c>
<b>...</b>
<b>...</b>
<b>...</b>
<b>...</b>
</c>
</data>

  #2  
Old March 9th, 2006, 03:35 PM
Martin Honnen
Guest
 
Posts: n/a
Default Re: XML Schema - limit occurrence



1-crm@freenet.de wrote:
[color=blue]
> Now my question: is it possible to limit the occurrence of the element
> b in the data element.[/color]

I don't think so, you can describe the contents of the a element and
there you can constraint the number of b child elements. The same is
possible for the c element.
But with the W3C XSD schema language I don't think you can specify
constraints on the number of b descendants of the data element.
Schematron however allows you to model such constraints.


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
  #3  
Old March 9th, 2006, 04:55 PM
dickster
Guest
 
Posts: n/a
Default Re: XML Schema - limit occurrence

Hi Martin,

This thought of mine WOULD be way to convoluted and schematron as you
say would be better.

However as an academic argument could the <xsd:choice> option be used
with each permutation covered

minOccurs="0"
minOccurs="6"

minOccurs="1"
minOccurs="5"

minOccurs="2"
minOccurs="4"

minOccurs="3"
minOccurs="3"

& so on

Assuming XML Schema was the only show in town

Dickster

  #4  
Old March 9th, 2006, 05:15 PM
Martin Honnen
Guest
 
Posts: n/a
Default Re: XML Schema - limit occurrence



dickster wrote:
[color=blue]
> However as an academic argument could the <xsd:choice> option be used
> with each permutation covered
>
> minOccurs="0"
> minOccurs="6"
>
> minOccurs="1"
> minOccurs="5"
>
> minOccurs="2"
> minOccurs="4"
>
> minOccurs="3"
> minOccurs="3"
>
> & so on[/color]

In my understanding even if you try to enumerate all choices the schema
becomes non-deterministic and thus that approach does not work.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles