473,738 Members | 10,068 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:simpleTyp e name="stypeDay" >
<xs:restricti on base="xs:string ">
<xs:enumerati on value="Mon"/>
<xs:enumerati on value="Tue"/>
<xs:enumerati on value="Wed"/>
<xs:enumerati on value="Thur"/>
<xs:enumerati on value="Fri"/>
<xs:enumerati on value="Sat"/>
<xs:enumerati on 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 2545


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:simpleTyp e name="stypeDay" >
<xs:restricti on base="xs:string ">
<xs:enumerati on 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(s XMLFileName);
reader = new XmlValidatingRe ader(txtReader) ;
reader.Validati onType = ValidationType. Schema ;
XmlDocument doc = new XmlDocument();
doc.Load(reader );
return(doc.Docu mentElement);
Then I parse the XmlDocument under .NET1.0

David
"Martin Honnen" <ma*******@yaho o.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:simpleTyp e name="stypeDay" >
<xs:restricti on base="xs:string ">
<xs:enumerati on 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(s XMLFileName);
reader = new XmlValidatingRe ader(txtReader) ;
reader.Validati onType = ValidationType. Schema ;
XmlDocument doc = new XmlDocument();
doc.Load(reader );
return(doc.Docu mentElement);


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 XmlValidatingRe ader and access
the SchemaType property
<http://msdn.microsoft. com/library/default.asp?url =/library/en-us/cpref/html/frlrfSystemXmlX mlValidatingRea derClassSchemaT ypeTopic.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
12633
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
6512
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
1813
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
5659
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 convenient, is also one of the most gross warping of language concepts to date... public IEnumerator...
1
5029
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
2673
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
2711
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
4794
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
8788
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9335
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9208
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8210
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6751
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6053
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4825
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3279
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
2
2745
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.