> I parse an XML file with a XSD schema.
> One XmlNode has an attribute whose type is a restriction of xs:string :
>
> <xs:simpleType name="stypeDay">
> <xs:restriction base="xs:string">
> <xs:enumeration value="Mon"/>
> Is it possible to read from such an its rank in the enumeration
> That is while reading
> <Poste Day="Mon">, get 0
> <poste Day="Tue">, get 1
What are you using to parse the XML, .NET 1.x or .NET 2.0? And what API,
for instance XmlDocument or XmlTextReader, do you use or do you want to use?

Signature
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Davidoff - 27 Apr 2006 14:41 GMT
Here is the code to load the document according to its schema
txtReader = new XmlTextReader(sXMLFileName);
reader = new XmlValidatingReader(txtReader);
reader.ValidationType = ValidationType.Schema ;
XmlDocument doc = new XmlDocument();
doc.Load(reader);
return(doc.DocumentElement);
Then I parse the XmlDocument under .NET1.0
David
>> I parse an XML file with a XSD schema.
>> One XmlNode has an attribute whose type is a restriction of xs:string :
[quoted text clipped - 11 lines]
> for instance XmlDocument or XmlTextReader, do you use or do you want to
> use?
Martin Honnen - 27 Apr 2006 17:59 GMT
> Here is the code to load the document according to its schema
> txtReader = new XmlTextReader(sXMLFileName);
[quoted text clipped - 3 lines]
> doc.Load(reader);
> return(doc.DocumentElement);
With .NET 1.x there is no connection between DOM (XmlDocument, XmlNode)
and schema types. .NET 2.0 changes that, there XmlNode has a property
SchemaInfo.
So with .NET 1.x all you can do is use XmlValidatingReader and access
the SchemaType property
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlr
fSystemXmlXmlValidatingReaderClassSchemaTypeTopic.asp>
to read out schema information while the document is being parsed. The
schema object model (SOM) allows you to read out schema information, for
instance the facets of a simple type restriction.

Signature
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/