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

Re: Choice of sub-element or character-data in an element

From: Koray SAKIROGLU <koray.sakiroglu@gmail.com>
Date: Mon, 23 Jun 2008 10:46:46 +0200
Message-ID: <23e987b00806230146l6d61a8c7m12461fd719026cca@mail.gmail.com>
To: "Arshad Noor" <arshad.noor@strongauth.com>
Cc: xmlschema-dev@w3.org
Re: Choice of sub-element or character-data in an element
Damned, sorry my previous message got sent before I completed it.

Hello :)

>From what I understood you want something like this :

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">

    <xsd:element name="elementB">
        <xsd:complexType>
            <xsd:simpleContent>
                <xsd:extension base="xsd:string">
                    <xsd:attribute name="name" type="xsd:string"
use="required" />
                </xsd:extension>
            </xsd:simpleContent>
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="elementA">
        <xsd:complexType>
            <xsd:choice>

                <xsd:element name="elementB">
                    <xsd:complexType>
                        <xsd:sequence>
                            <xsd:element name="elementC" type="xsd:string"/>
                            <xsd:element name="elementD" type="xsd:string"/>
                        </xsd:sequence>
                    </xsd:complexType>
                </xsd:element>

                <xsd:element ref="elementB" />

            </xsd:choice>
        </xsd:complexType>
    </xsd:element>
</xsd:schema>

does this help or you want something more specific ?

2008/6/22 Arshad Noor <arshad.noor@strongauth.com>:
>
>
>> How is it possible to define an XSD to allow an element to
>> either contain custom sub-elements, or a fixed string?
>>
>> For example, I would like to be able to do the following:
>>
>> <ElementA>
>>   <ElementB>
>>      <ElementC>Some value</ElementC>
>>      <ElementD>Another value</ElementD>
>>   </ElementB>
>> </ElementA>
>>
>> or
>>
>> <ElementA>
>>   <ElementB>Any</ElementB>
>> </ElementA>
>>
>> I'm not sure how to use <xsd:choice> to define this?  Thanks
>> for any suggestions.
>>
>> Arshad Noor
>> StrongAuth, Inc.
>>
>>
>>
>
Received on Monday, 23 June 2008 15:20:01 GMT

Subscribe to the Stylus Scoop newsletter for helpful XML tips and tutorials.
Email
First Name
Last Name
Company

Download Stylus Studio 6 XML Enterprise Edition

Subscribe in XML format
RSS 2.0
Atom 0.3
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-2007 All Rights Reserved.