Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: XSD questions [Thread Next] Re: XSD questionsTo: NULL Date: 10/1/2004 9:38:00 AM Zafar,
Thanks for replying. I see the basic pattern now, but still have some
questions.
1) What is it in the schema definition that tells a user that they MUST
specify a data type in their xml, as opposed to them assuming that because
it's in the schema then they don't have to. For example
<MyParent>
<MyChild dt:dt="string">ABCDE</MyChild>
</MyParent>
as opposed to just
<MyParent>
<MyChild>ABCDE</MyChild>
</MyParent>
This is a requirement of mine because several of my xml tags are generic
entities that can be one of a number of types
2) Following on from 1), when you define the requirement for an attribute,
you specify something along the lines of
<xs:attribute name="name" type="xs:string" use="required"/>
in the schema. Are datatype attributes fundamentally different?
3) You mentioned that I don't have to use 'dt' when specifying datatypes,
but I think you may be confused. The datatypes I am using are from a
Microsoft schema which I am referencing at the top of my schema with
xmlns:dt="urn:schemas-microsoft-com:datatypes". I am not using the W3C
datatypes, so surely I have to use the 'dt' to namespace them correctly.
Where I had
<xs:simpleType name="stringOrInt">
<xs:union memberTypes="dt:string dt:int"/>
</xs:simpleType>
this is using datatypes defined by Microsoft ( string is defined in both,
but my example has int and not the W3C integer type). I could just as easily
be using dt:uuid or dt:ui4.
Thanks again for your help,
Chris
"Zafar Abbas [MSFT]" <zafara@m...> wrote in message
news:ef4U%23NxpEHA.800@T......
> You do not use references to 'dt' while specifying types in XSD Schemas.
>
> For MyChild to be string simply use:
> <xs:element name="MyChild" type="string"/>
>
> for int:
> <xs:element name="MyChild" type="int"/>
>
> for it to be int or string, defined a union type of these two and set its
> type to MyChild.
>
> <xs:simpleType name="StringOrInt">
> <xs:union memberTypes="xs:int xs:string"/>
> </xs:simpleType>
>
> <xs:element name="MyChild" type="StringOrInt"/>
>
> for it be be any datatype, either define a union of all excepted types OR
> define it as anySimpleType, and then at runtime, change the type for
> MyChild like:
>
> <xs:element name="MyChild" type="xs:anySimpleType"/> so in the XML if
you
> want MyChild to be int, you do:
>
> <MyChild xsi:type="xs:int">123</MyChild>
>
> NOTE: remember to define the prefixes for xsi namespace in your XML
document
> like:
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
>
>
>
> "Chris Puncher" <chris.puncher@d...> wrote in message
> news:OmYRLOwpEHA.2900@T......
> > I'm trying to write the schema for some xml that uses datatypes from the
> > xmlns:dt="urn:schemas-microsoft-com:datatypes" namespace. I've got three
> > questions (currently) and hope someone can answer them
> >
> > Q1. Given the xml
> > <MyParent>
> > <MyChild dt:dt="string">ABCDE</MyChild>
> > </MyParent>
> > where the datatype must be specified, am right in thinking that the
schema
> > should be
> > <xs:element name="MyParent">
> > <xs:complexType>
> > <xs:sequence>
> > <xs:element name="MyChild" dt:type="string"/>
> > </xs:sequence>
> > </xs:complexType>
> > </xs:element>
> >
> > Q2. If MyChild can be string or int, that is
> > <MyChild dt:dt="string">ABCDE</MyChild>
> > or
> > <MyChild dt:dt="int">ABCDE</MyChild>
> > is this right?
> > <xs:simpleType name="stringOrInt">
> > <xs:union memberTypes="dt:string dt:int"/>
> > </xs:simpleType>
> > <xs:element name="MyParent">
> > <xs:complexType>
> > <xs:sequence>
> > <xs:element name="MyChild" dt:type="stringOrInt"/>
> > </xs:sequence>
> > </xs:complexType>
> > </xs:element>
> >
> > Q3. What if MyChild can be any of the dt:dt datatypes? Do I have to
define
> a
> > union for all of them, or is there one already defined in the dt:
> namespace
> > (something like dt:all I guess)?
> >
> > Thanks for your help.
> >
> >
>
>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
