Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / April 2006

Tip: Looking for answers? Try searching our database.

xsd enumeration

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Davidoff - 27 Apr 2006 12:46 GMT
Hi,

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"/>
 <xs:enumeration value="Tue"/>
 <xs:enumeration value="Wed"/>
 <xs:enumeration value="Thur"/>
 <xs:enumeration value="Fri"/>
 <xs:enumeration value="Sat"/>
 <xs:enumeration value="Sun"/>
</xs:restriction>
</xs:simpleType>

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
and son on...

Thanks

David
Martin Honnen - 27 Apr 2006 13:43 GMT
> 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/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.