[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

XML schema problem for two definitions of the same element.

  • To: xml-dev@l...
  • Subject: XML schema problem for two definitions of the same element.
  • From: Hess Yvan <yvan.hess@i...>
  • Date: Fri, 18 Jun 2004 09:22:30 +0200

xml element name problem
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.


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.