Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Selective element based on attribute

From: "Pete Cordell" <petexmldev@--------------.--->
To: <xmlschema-dev@--.--->, <Muthuvelan.Swaminathan@---.--->
Date: 10/5/2007 12:41:00 PM
In addition to Michael Kay's reply, you might want to define your attr 
attribute to be an xs:list schema type, which causes the attribute value to 
be a space separated list (e.g. attr="add del chg").  Using a more 
conventional list definition may mean that the various tools can give you 
better service.

The schema segment for that would look something like:

    <xs:attribute name="attr">
        <xs:simpleType>
            <xs:list>
                <xs:simpleType>
                    <xs:restriction base="xs:token">
                        <xs:enumeration value="add"/>
                        <xs:enumeration value="del"/>
                        <xs:enumeration value="chg"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:list>
        </xs:simpleType>
    </xs:attribute>

This doesn't prevent you having an instance looking like attr="add add add". 
I'm not sure there is a convenient way to prevent that though and still be 
part of an xs:list.

HTH,

Pete.
=============================================
Pete Cordell
Codalogic
for XML Schema to C++ data binding visit
 http://www.codalogic.com/lmx/
=============================================

----- Original Message ----- 
From: <Muthuvelan.Swaminathan@d...>
To: <xmlschema-dev@w...>
Sent: Thursday, October 04, 2007 8:32 PM
Subject: Selective element based on attribute


> Hi  there,
>
> How can I define an xsd for the following scenario?
>
> <parenttag attr="add | del | chg">
>     <childtag1>chidvalue1</childtag1>
>     <childtag2>chidvalue2</childtag2>
>     <childtag3>chidvalue3</childtag3>
> </parenttag>
>
> Is it possible to create an xsd where childtag3 will have a value null if
> the parenttag  attr equals add else a nonnull-String when the parenttag
> attr is del/chg?
>
> Thanks
> Muthu 



From kstaniraji@y... Tue Oct 09 10:51:59 2007
Received: from wiggum.w3.org ([128.30.52.23])
	by f


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