Schema definition

View: New views
2 Messages — Rating Filter:   Alert me  

Schema definition

by vipin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
 
I have a generic question regarding writing xsd for XML.
 
Is it possible to write a schema(xsd) if children of an element depends on value of a particular attribute ?
 
for eg, if type="service" then children of  will be  (protocal,srcport,destport,icmpType,icmpCode)            AND
          if type="device" then children of  will be   (ip,hostname,domain)  
 
           <Service>
               
                   <protocol/>
                   <srcPort/>
                   <destPort/>
                   <icmpType/>
                   <icmpCode/>
               
            <Service>
 
            <ReportingDevices>
               
                    <ip/>
                    <hostName/>
                    <domain/>
               
            </ReportingDevices>
 
Thanks,
Vipin V S.

Re: Schema definition

by Michael Glavassevich-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Vipin,

The only attribute in XML Schema 1.0 that can be used to do what you want
is xsi:type.

FYI: The W3C mailing list [1] is a more appropriate list for generic
queries such as this.

Thanks.

[1] http://lists.w3.org/Archives/Public/xmlschema-dev/

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@...
E-mail: mrglavas@...

vipin <vipinvs@...> wrote on 06/07/2007 02:57:41 PM:

> Hi,
>
> I have a generic question regarding writing xsd for XML.
>
> Is it possible to write a schema(xsd) if children of an element depends
on
> value of a particular attribute ?
>
> for eg, if type="service" then children of  will be
> (protocal,srcport,destport,icmpType,icmpCode)            AND
>           if type="device" then children of  will be
(ip,hostname,domain)

>
>            <Service>
>
>                    <protocol/>
>                    <srcPort/>
>                    <destPort/>
>                    <icmpType/>
>                    <icmpCode/>
>
>             <Service>
>
>             <ReportingDevices>
>
>                     <ip/>
>                     <hostName/>
>                     <domain/>
>
>             </ReportingDevices>
>
> Thanks,
> Vipin V S.
> --
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: general-unsubscribe@...
> For additional commands, e-mail: general-help@...


---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@...
For additional commands, e-mail: general-help@...