Thank you very much.
"Dino Chiesa [Microsoft]" <dinoch@online.microsoft.com> wrote in message
news:OIJIroItDHA.2248@TK2MSFTNGP09.phx.gbl...
> xsd makes an array when you have maxOccurs="unbounded", eg passing the
> following xsd into xsd.exe gives me an array:
>
> <?xml version="1.0" encoding="utf-8"?>
> <xs:schema xmlns:xs="
http://www.w3.org/2001/XMLSchema" xmlns=""
id="Ionic">
> <xs:complexType name="Root">
> <xs:sequence>
> <xs:element name="Stamp" maxOccurs="unbounded" type="xs:date"/>
> </xs:sequence>
> </xs:complexType>
> <xs:element name="Something" type="Root"/>
> </xs:schema>
>
>
> For Q2, when deserializing, pass the Deserialize() method an instance of
> XmlValidatingReader.
>
> Here is an example:
>
> XmlReader xr = new XmlTextReader(fileName);
> XmlValidatingReader vr = new XmlValidatingReader(xr);
> vr.Schemas.Add("urn:example-org:person", "person.xsd");
> Person p = (Person)ser.Deserialize(vr);
>
> ref:
>
http://msdn.microsoft.com/msdnmag/issues/02/11/XMLFiles/default.aspx >
> -Dino
>
> --
> Dino Chiesa
> Microsoft Developer Division
> d i n o c h @ o n l i n e . m i c r o s o f t . c o m
>
>
> "Iain" <idownsXXXX@dircon.co.uk> wrote in message
> news:ugnxvXFtDHA.2932@TK2MSFTNGP11.phx.gbl...
> > I'm embarking on a c# based project in which I would like to make use of
a
> > lot of XML including database access and using hte xml and .net tools as
> a
> > coding shortcut.
> >
> > What I'm trying to understand at the moment is how to use xsd.exe and
> result
> > .cs files to mange the xml.
> >
> > First question.
> >
> > My XSD includes <sequence>s which have > 1 value. the cs produced
renders
> > this as a single instance, though if I change this to an array
(manually)
> > the deserialization works as expected (nice!). How can I tell xsd it
> SHOULD
> > be an array (I've tried setting maxOccurs, but this seems to make no
> > difference).
> >
> > Second question.
> >
> > I want some of the attributes (and elements for that matter) to be
> > mandatory. Specifically, I would like an exception to be throw during
> > deserialisation (oops sorry about the 's' chaps - I speak British
English
> as
> > a first tongue - the 'z' thing takes some getting used to!) if an
> attribute
> > is not present. How do I do this?
> >
> > Equally, I would like an exception thrown if an attribute or element NOT
> > specified in the XSD occurs.
> >
> > In both cases, I'm kind of hoping I can do it without having to make
> > post-xsd.exe changes to the source.
> >
> > Look forward to feedback!
> >
> > iain
> >
> >
>
>