473,516 Members | 3,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

xsd enumeration

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
Apr 27 '06 #1
3 2529


Davidoff wrote:
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?
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Apr 27 '06 #2
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
"Martin Honnen" <ma*******@yahoo.de> a écrit dans le message de news:
e7**************@TK2MSFTNGP03.phx.gbl...


Davidoff wrote:
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?
--

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

Apr 27 '06 #3


Davidoff wrote:
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);


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/frlrfSystemXmlXmlValidatingReaderClassSchemaTypeTo pic.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.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Apr 27 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
12617
by: Justin Wright | last post by:
I know that I can set up an enumeration as follows ( just typed in quick so may have syntax errors ): <xsd:simpleType name="colors"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="red"/> <xsd:enumeration value="yellow"/> <xsd:enumeration value="blue"/> </xsd:simpleType>
8
6502
by: aevans1108 | last post by:
Greetings I can't seem to inherit enumerated values from a globally defined type in my XML schema. XmlSchema.Compile() doesn't like it. Here's the schema. <?xml version="1.0" encoding="UTF-8" ?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
2
1799
by: Mark | last post by:
Assume you have an enumeration like PhoneType { Home, Business, Cell }. This enumeration corresponds with a lookup/dictionary table in your database like: phone_cd | phone_descr 1 Home 2 Business 3 Cell Now, I could associated each enumeration value with the phone_cd used in the
4
5645
by: Marshal | last post by:
Sure... IEnumerable was inconvenient suggesting a separate class to service the enumeration, IEnumerator, and multiple operations: Current, MoveNext, Reset. (I'll warp the definition of "operation" for a second if you don't mind). However, it existed within intuitive language semantics, whereas the new "yield" keyword, while highly...
1
4972
by: Stefano G. | last post by:
I have a WSDL containing this enumeration type <xsd:simpleType name="item_type_enum"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="VCD"/> <xsd:enumeration value="SVCD"/> <xsd:enumeration value="CDAUDIO"/> <xsd:enumeration value="DVD"/> <xsd:enumeration value=""/><!-- can be an empty string --> </xsd:restriction>
27
2639
by: Ben Finney | last post by:
Antoon Pardon wrote: > I just downloaded your enum module for python > and played a bit with it. IMO some of the behaviour makes it less > usefull. Feedback is appreciated. I'm hoping to provide a "one obvious way" to do enumerations in Python. > >>> from enum import Enum > >>> day = Enum('mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun')
0
500
by: news.emn.fr | last post by:
Hello, i got this attribute <xs:attribute name="jour"> <xs:simpleType> <xs:restriction base="stypeJour"> </xs:restriction> </xs:simpleType> </xs:attribute>
3
2697
by: eXt | last post by:
For a realtime-application (half an application at least, kind of a framework) I am working with I need a event managing system and naturally it must be fast. I have defined a set of available event types in an enumeration like this: enum Events { EVENT_FOO, EVENT_BAR, EVENT_BAZ, EVENT_CUSTOM1,
3
4771
by: muler | last post by:
hi all, After reading this excerpt from "The C# Programming Language", (By Anders) I tried to check it out. Unfortunately, I'm getting compile errors. Can anyone illustrate this with an example: ---------------------------------------------------- Section 7.7.4 - enumeration addition
0
7273
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7182
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7136
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7547
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5106
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3252
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1620
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.