473,805 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

at runtime, get possible choices for xs:choice class

Hi,
I am using Reflection to build a GUI based on a class create with XSD, in VB
..NET 2.0. For most elements, I can easily determine the Type and then
provide the user some controls to select what data to use (they are creating
an XML document essentially on the fly). But the choice element has several
possible types and so it creates this itemField as object within the
xs:choice-generated class:

Private itemField As Object

'''<remarks/>
<System.Xml.Ser ialization.XmlE lementAttribute ("DetectionComm and",
GetType(Detecti onCommandType)) , _
System.Xml.Seri alization.XmlEl ementAttribute( "ExtendedComman d",
GetType(Extende dCommandType)), _
System.Xml.Seri alization.XmlEl ementAttribute( "LocationComman d",
GetType(Locatio nCommandType)), _
System.Xml.Seri alization.XmlEl ementAttribute( "SimpleCommand" ,
GetType(SimpleC ommandType)), _
System.Xml.Seri alization.XmlEl ementAttribute( "TimeComman d",
GetType(TimeCom mandType))_
Public Property Item() As Object
Get
Return Me.itemField
End Get
Set(ByVal value As Object)
Me.itemField = Value
End Set
End Property

Is there any way to get the information in the "remarks" section during
runtime, perhaps that auto-generated info is also hiding somewhere else?
Really, I just want be able to determine at runtime what possible Types could
this itemField object take on? I would just throw an enumerated list or some
other hack inside this class, but there are many classes like this and I've
gotten away with a very re-useable solution so far.
Apr 26 '07 #1
1 2938
GovernmentMan wrote:
Hi,
I am using Reflection to build a GUI based on a class create with XSD, in VB
.NET 2.0. For most elements, I can easily determine the Type and then
provide the user some controls to select what data to use (they are creating
an XML document essentially on the fly). But the choice element has several
possible types and so it creates this itemField as object within the
xs:choice-generated class:

Private itemField As Object

'''<remarks/>
<System.Xml.Ser ialization.XmlE lementAttribute ("DetectionComm and",
GetType(Detecti onCommandType)) , _
System.Xml.Seri alization.XmlEl ementAttribute( "ExtendedComman d",
GetType(Extende dCommandType)), _
System.Xml.Seri alization.XmlEl ementAttribute( "LocationComman d",
GetType(Locatio nCommandType)), _
System.Xml.Seri alization.XmlEl ementAttribute( "SimpleCommand" ,
GetType(SimpleC ommandType)), _
System.Xml.Seri alization.XmlEl ementAttribute( "TimeComman d",
GetType(TimeCom mandType))_
Public Property Item() As Object
Get
Return Me.itemField
End Get
Set(ByVal value As Object)
Me.itemField = Value
End Set
End Property

Is there any way to get the information in the "remarks" section during
runtime, perhaps that auto-generated info is also hiding somewhere else?
Really, I just want be able to determine at runtime what possible Types could
this itemField object take on? I would just throw an enumerated list or some
other hack inside this class, but there are many classes like this and I've
gotten away with a very re-useable solution so far.
Hi,
Unless with the explicit declaration of ItemChoiceType enum, I'm not
aware of another way to get it runtime.
You can see detailed sample at:
http://msdn.microsoft.com/msdnmag/is...3/06/XMLFiles/

HTH,
Petar Atanasov
http://a-wake.net
May 7 '07 #2

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

Similar topics

3
510
by: dgaucher | last post by:
Hi, I want to consume a Web Service that returns a choice, but my C++ client always receives the same returned type. On the other hand, when I am using a Java client, it is working fine (of course, the generated proxy is not the same). When I am looking at the C++ generated code, it seems fine, but when I am executing the code, I always get the first choice type.
1
2915
by: Oleg Ogurok | last post by:
Hi all, I have a complex type defined as follows: <xs:complexType name="SchedulingMethodType"> <xs:choice maxOccurs="1"> <xs:element name="Interval" type="xs:duration" /> <xs:element name="DailyAt" type="xs:duration" /> </xs:choice> </xs:complexType>
2
2375
by: Matthew | last post by:
I have implemented the xmlSchemaCollection object to cache commonly used schemas, as follows: =============================================================================== public void SchemaValidate(XmlDocument xmlDoc, string schemaURI, string urnNamespace) {
4
1732
by: Sergey Poberezovskiy | last post by:
Hi, As part of my schema I need to ensure that at least one of two fields have values. I defined my schema as follows: .... <xs:choice> <xs:element ref="el1"/> <xs:element ref="el2"/> <xs:sequence> <xs:element ref="el1"/>
2
4356
by: Sergey Poberezovskiy | last post by:
Hi, If I define my schema as <xs:choice> <xs:sequence> <xs:element ref="el_1" /> <xs:element ref="el_2" /> </xs:sequence> <xs:sequence>
2
5664
by: pawel.pabich | last post by:
Hajo, I know only one way of forcing element to have one or more childes: <xs:element name="saleOrSupplyMethod"> <BR/> <xs:complexType> <xs:choice> <xs:sequence> <xs:element name="generalSale" type="emptyTagType" /> <xs:element name="prescription" type="emptyTagType"/>
7
2459
by: rbarschaw | last post by:
I have the following schema designed: <xs:complexType name="AzzFeature-BoxType" mixed="true"> <xs:choice minOccurs="1" maxOccurs="unbounded"> <xs:element ref="Sub-Head" minOccurs="1" maxOccurs="unbounded"/> <xs:element ref="Title-Text" minOccurs="0" maxOccurs="unbounded"/> <xs:element ref="Text" minOccurs="0" maxOccurs="unbounded"/> <xs:element ref="Link-List" minOccurs="0" maxOccurs="unbounded"/> </xs:choice> <xs:attribute...
2
1674
by: hooomee | last post by:
Given: <xs:choice maxOccurs=5> <xs:element name="Foo" type="bar" /> <xs:element name="Foo1" type="bar" /> <xs:element name="Foo2" type="bar" /> </xs:choice> Is the choice made once and then the choosen element can occur 5 times, or is the choice made once for each occurance?
0
2842
by: Peter Larsen | last post by:
Is this really a valid schema design? <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="root"> <xs:complexType> <xs:sequence> <xs:choice> <xs:element name="e1" minOccurs="0" />
0
9596
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
10613
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10363
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...
1
10368
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 most users, this new feature is actually very convenient. If you want to control the update process,...
1
7649
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
6876
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
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4327
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
3846
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.