W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2004

Implementing a kind of bag element with XML schema

From: Hess Yvan <yvan.hess@imtf.ch>
Date: Fri, 12 Mar 2004 11:06:36 +0100
Message-ID: <DF7EC83D7AFBD411965B0008C7596EC5E0D4A8@imtfexchange.imtf.ch>
To: xmlschema-dev@w3.org

I tried to implement with XML schema a kind of bag element with the
following requirements:

1. The order of the elements is not important.
2. It can contain predefined elements that must occurs with a given
occurrences (min and max). 
3. It can also accepts any kind of others elements (from the same namespace
or others namespaces) using for example <xs:any> element. 

Here are valid XML instance examples:

<metadata>
  <dc:identifier>urn:hsc:1234</dc:identifier>
  <dc:subject>this is the subject</dc:subject>
  <name>Hess Yvan</name>
  <anyOtherElement>blabla</anyOtherElement>
  <name>Hess Yvan</name>
  <dc:otherElement>blabla</otherElement>
</metadata>

<metadata>
  <dc:subject>this is the subject</dc:subject>
  <anyOtherElement>blabla</anyOtherElement>
  <dc:identifier>urn:hsc:1234</dc:identifier>
</metadata>

I would like to force that dc:identifier is always present in the metadata
element, but where this element appears is not important! This is the
requierement I have to implement.

For example, I tried somethink like that:

   <xs:element name="metadata">
      <xs:complexType>
         <xs:choice>
            <xs:element name="identifier" type="xs:string" minOccurs="1"
maxOccurs="1" />
            <xs:any processContents="lax" minOccurs="0"
maxOccurs="unbounded"/>
         </xs:choice>
      </xs:complexType>
   </xs:element>
   
But in this case it violates the "Unique Particle Attribution". Nobody can
help me to solve this problem (mailing-lists or others). I don't know if a
reach a limitation of the W3C recommendation, but from my point of view this
use case is a real concrete use case that should be supported by W3C XML
schema recommendation.

Does it exist a possibility to implement what I want to do or do I really
reach a limitation of the XML schema W3C recommendation 1.0?

Yvan Hess
Chief Software Architect

e-mail: yvan.hess@imtf.ch
phone : +41 (0)26 460 66 66 
fax   : +41 (0)26 460 66 60 

Informatique-MTF SA
Route du Bleuet 1 
CH-1762 Givisiez 
        
Systemintegrators for eDocuments 
http://www.imtf.com

DISCLAIMER 
This message is intended only for use by the person to whom it is addressed.
It may contain information that is privileged and confidential. Its content
does not constitute a formal commitment by IMTF. If you are not the intended
recipient of this message, kindly notify the sender immediately and destroy
this message. Thank You.
Received on Friday, 12 March 2004 05:12:43 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 5 February 2014 23:40:23 UTC