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

RE: Use-case for a complex type that has no valid content?

  • From: "Costello, Roger L." <costello@mitre.org>
  • To: "xml-dev@lists.xml.org" <xml-dev@lists.xml.org>
  • Date: Tue, 2 Jun 2015 19:00:41 +0000

RE: Use-case for a complex type that has no valid content?

Here's an idea: use the empty choice as a way to express "I'm terminating my connection with you".

 

For example, a sender creates XML documents containing data of either books, magazines, or Kindles. At some point the sender wants to signal that he will send no further XML documents. So the XML Schema is created in which one of the choices is a Halt element (of type ValidationKiller):

 

    <xs:element name="Document">

        <xs:complexType>

            <xs:choice>

                <xs:element name="Books" type="BooksType" />

                <xs:element name="Magazines" type="MagazinesType" />

                <xs:element name="Kindles" type="KindlesType" />

                <xs:element name="Halt" type="ValidationKiller" />

            </xs:choice>

        </xs:complexType>

    </xs:element>

 

where ValidationKiller is a complexType containing an empty choice:

 

<xs:complexType name="ValidationKiller">

         <xs:choice/>

</xs:complexType>

 

To halt the communication the sender sends this XML document:

 

<Document>

      <Halt/>

</Document>

 

That fails validation and thus terminates the connection.

 

Is that a reasonable use of ValidationKiller?

 

/Roger

 

 

From: Costello, Roger L.
Sent: Tuesday, June 02, 2015 1:45 PM
To: xml-dev@lists.xml.org
Subject: Use-case for a complex type that has no valid content?

 

Hi Folks,

 

Thanks for the outstanding responses.

 

I have learned that an empty choice:

 

    <xs:complexType name="ValidationKiller">
       
<xs:choice/>
   
</xs:complexType>

 

has no valid content, i.e., the set of valid content is the empty set, {}.

 

When would one use such a complex type? Can you think of a use-case for it?

 

/Roger



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


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.