Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: XML schema problem for two definitions of the same element.

From: Hess Yvan <yvan.hess@----.-->
To: 'Michael Kay' <mhk@---.--.-->
Date: 6/21/2004 1:04:00 PM
Thanks Michael for your help. This solution solves my problem. I hope in
future, xml schema specifications will allow a kind of "context-sensitive"
to determine the type to be used for validation.

Regards. Yvan

-----Original Message-----
From: Michael Kay [mailto:mhk@m...]
Sent: vendredi, 18. juin 2004 19:12
To: 'Hess Yvan'
Cc: xmlschema-dev@w...
Subject: RE: XML schema problem for two definitions of the same element.



Sorry: to be more precise, you need

sequence
  document-type
  choice
    sequence
      from
      to
    /sequence
    sequence
      filename
      filesize
    /sequence
  /choice
/sequence

Michael Kay 

> -----Original Message-----
> From: Hess Yvan [mailto:yvan.hess@i...] 
> Sent: 18 June 2004 17:30
> To: 'Michael Kay'
> Cc: 'xmlschema-dev@w...'
> Subject: RE: XML schema problem for two definitions of the 
> same element.
> 
> Michael,
> 
> I did like as you recommended (choice with two sequence) but 
> XML validators
> return an error saying "ambiguity would be created for those 
> two particles
> xml schema". I also tried to have a fixed value for the <documenttype>
> element, but it's the same problem. Any idea?
> 
> Regards. Yvan
> 
> -----Original Message-----
> From: Michael Kay [mailto:mhk@m...]
> Sent: vendredi, 18. juin 2004 11:27
> To: 'Hess Yvan'; xmlschema-dev@w...
> Subject: RE: XML schema problem for two definitions of the 
> same element.
> 
> 
> XML Schema doesn't allow types to be context-sensitive in 
> this kind of way.
> The closest you can get is to define the type of "metadata" 
> as a choice
> giving the two possible structures.
> 
> Michael Kay  
> 
> > -----Original Message-----
> > From: xmlschema-dev-request@w... 
> > [mailto:xmlschema-dev-request@w...] On Behalf Of Hess Yvan
> > Sent: 18 June 2004 08:49
> > To: 'xmlschema-dev@w...'
> > Subject: XML schema problem for two definitions of the same element.
> > 
> > 
> > I have a XML situation that have many time the same element 
> but with a
> > different defininiton as illustrated bellow and I would like 
> > to create the
> > XML schema that can validate this document. As you can see only the
> > <metadata> element differs from the first and second 
> > <document> element. The
> > first <document> element must occur only once and the second 
> > <document>
> > element can appears 0..unbounded. How can solve my problem?
> > 
> > Thanks for your answer.
> > 
> > Regards. Yvan
> > 
> > -------------
> > XML document:
> > -------------
> > 
> > <edoc>
> >    <document>
> >       <metadata>
> >          <documenttype>BODY</documenttype>
> >          <from>yhe</from>
> >          <to>yvan</to>
> >       </metadata>
> >       <content>this is the content of the first document</content>
> >    </document>
> >    <document>
> >       <metadata>
> >          <documenttype>ATTACHMENT</documenttype>
> >          <filename>test.doc</filename>
> >          <filesize>100</filesize>
> >       </metadata>
> >       <content>this is the content of the second document</content>
> >    </document>
> > </edoc>
> > 
> > -------------
> > XML schema:
> > -------------
> > 
> > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > elementFormDefault="qualified">
> >    <xs:element name="edoc">
> >       <xs:complexType>
> >          <xs:sequence>
> >             <xs:element name="document">
> >                <xs:complexType>
> >                   <xs:sequence>
> >                      <xs:element name="metadata">
> >                         <xs:complexType>
> >                            <xs:sequence>
> >                               <xs:element name="documenttype"
> > type="xs:string"/>
> >                               <xs:element name="from" 
> > type="xs:string"/>
> >                               <xs:element name="to" 
> type="xs:string"/>
> >                            </xs:sequence>
> >                         </xs:complexType>
> >                      </xs:element>
> >                      <xs:element name="content" type="xs:string"/>
> >                   </xs:sequence>
> >                </xs:complexType>
> >             </xs:element>
> >             <xs:element name="document" minOccurs="0" 
> > maxOccurs="unbounded">
> >                <xs:complexType>
> >                   <xs:sequence>
> >                      <xs:element name="metadata">
> >                         <xs:complexType>
> >                            <xs:sequence>
> >                               <xs:element name="documenttype"
> > type="xs:string"/>
> >                               <xs:element name="filename" 
> > type="xs:string"/>
> >                               <xs:element name="filesize" 
> > type="xs:string"/>
> >                            </xs:sequence>
> >                         </xs:complexType>
> >                      </xs:element>
> >                      <xs:element name="content" type="xs:string"/>
> >                   </xs:sequence>
> >                </xs:complexType>
> >             </xs:element>
> >          </xs:sequence>
> >       </xs:complexType>
> >    </xs:element>
> > </xs:schema>
> > 
> > 
> > Yvan Hess
> > Chief Software Architect
> > 
> > e-mail: yvan.hess@i...
> > 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.
> > 
> > 
> > 
> > 
> 
> 

From iipc@t...  Mon Jun 21 10:56:05 2004
Return-Path: <iipc@t...>
X-Original-To: xmlschema-dev@l...
Delivered-To: xmlschema-dev@l...
Received: from dr-nick.w3.org (dr-nick.w3.org [18.29.1.73


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent