Re: key and keyref to express dependency

Othman Haddad asks:

>> can we express in the W3C Schema that the presence of an 
>> element A depends en the presence of an element B?


Sure, although it depends on exactly what dependency you want.  As a 
simple example, 

        <xsd:sequence>
                <xsd:element ref="A"/>
                <xsd:element ref="B"/>
        </xsd:sequence>

indicates that element B can occur only if preceded by an A (and indeed, 
the A can occur only if followed by a B!)

If you're new to Schemas, you should know that the recommendation 
documents are aimed primarily at those implementing processors, and others 
needing a legalisticly correct presentation.   If you're just learning 
schema, I highly recommend the primer, which is at [1].  I think you'll 
find it helpful.  There are also a number of books available, as well as 
some tutorial sites on the web I believe.

[1] http://www.w3.org/TR/xmlschema-0/

------------------------------------------------------------------
Noah Mendelsohn                              Voice: 1-617-693-4036
IBM Corporation                                Fax: 1-617-693-8676
One Rogers Street
Cambridge, MA 02142
------------------------------------------------------------------







"Othman Haddad" <ohaddad@neomalogic.com>
Sent by: www-xml-schema-comments-request@w3.org
05/30/2002 05:38 AM
Please respond to "Othman Haddad"

 
        To:     <xmlschema-dev@w3.org>
        cc:     <www-xml-schema-comments@w3.org>, (bcc: Noah Mendelsohn/Cambridge/IBM)
        Subject:        key and keyref to express dependency


hi everybody,
  i really don't find the W3C SChema specification clear, and have a 
question:
can we express in the W3C Schema that the presence of an element A depends
en the presence of an element B?
i thought about key and keyref elements,but i doubt they just impose
equality!
thank you 

Received on Wednesday, 5 June 2002 17:25:18 UTC