Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


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

From: Arshad Noor <arshad.noor@----------.--->
To: Koray SAKIROGLU <koray.sakiroglu@-----.--->
Date: 6/23/2008 9:16:00 AM
Its not quite what I wanted.  If I understand your construction,
you've essentially given elementB an attribute called "name" and
elementA may either use the locally-defined elementB (with two
sub-elements C & D) or the globally defined elementB with the
"name" attribute.

What I'm looking for is to have the elementB either contain the
sub-elements (C & D, as in your example), or fixed-text content
in the body of elementB rather than in an attribute.  Is that
possible?  Michael Kay from another posting has indicated that
it is not possible directly in XML Schema 1.0.

Thanks.

Arshad Noor
StrongAuth, Inc.

Koray SAKIROGLU wrote:
> 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@s...
>     <mailto:arshad.noor@s...>>:
> 
> 
>         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.
> 
> 
> 
> 

From mike@s... Mon Jun 23 23:47:40 2008
Received: from [128.30.52.63] (helo=bart.w3.org)
	by frink.w3.org with esmtp (Exim 4.63)
	(


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