473,503 Members | 11,968 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

having difficulties with 'choice'

3 New Member
Hi,

I'm currently busy writing an xsd at one point in time i whish that my xml must look like:
Expand|Select|Wrap|Line Numbers
  1. <object>
  2.     <loc>
  3.         <disk>
  4.             <drive>c</drive>
  5.             <path>temp\path</path>
  6.             <files>*.*</files>
  7.         </disk>
  8.     </loc>
  9.     <interval>
  10.         ...
  11.     </interval>
  12. </object>
or (choice)
Expand|Select|Wrap|Line Numbers
  1. <object>
  2.     <loc>
  3.         <network>
  4.             <server>localhost</server>
  5.             <path>temp\path</path>
  6.             <files>*.*</files>
  7.         </network>
  8.     </loc>
  9.     <interval>
  10.         ...
  11.     </interval>
  12. </object>
  13.  
or (another choice)
Expand|Select|Wrap|Line Numbers
  1. <object>
  2.     <loc>
  3.         <internet>
  4.             <uri>123.456.789.123</uri>
  5.             <path>temp\path</path>
  6.             <files>*.*</files>(optional (if webservice))
  7.             <port>8888</port>(optional)
  8.                 ....
  9.         </internet>
  10.     </loc>
  11.     <interval>
  12.         ...
  13.     </interval>
  14. </object>
  15.  
so the <loc> tag can contain (in my case) 5 different objects, which are all locations of some sorts. But the <loc> tag may only contain one (complex) child, which can be either an <internet>tag, a <network> tag or a <disk> tag.

How to get to my question: How do I pull this off in my XSD?

This is what I tried:
Expand|Select|Wrap|Line Numbers
  1. <xs:complexType name="Location">
  2.     <xs:sequence maxOccurs="1" minOccurs="1">
  3.         <xs:choice maxOccurs="1" minOccurs="1">
  4.             <xs:element name="localDisk" type="LocalDisk" maxOccurs="1" minOccurs="0" />
  5.             <xs:element name="networkLocation" type="NetworkLocation" maxOccurs="1" minOccurs="0" />
  6.             <xs:element name="internetSite" type="InternetSite" maxOccurs="1" minOccurs="0" />
  7.             <xs:element name="secureInternetSite" type="SecureInternetSite" maxOccurs="1" minOccurs="0" />
  8.             <xs:element name="ftpSite" type="FtpSite" maxOccurs="1" minOccurs="0" />
  9.         </xs:choice>
  10.     </xs:sequence>
  11. </xs:complexType>
  12.  
  13. <xs:complexType name="TextDataProvider">
  14.     <xs:sequence>
  15.         <xs:element name="location" type="Location" maxOccurs="1" minOccurs="1" />
  16.         <xs:element name="interval" type="Interval" maxOccurs="1" minOccurs="1" />
  17.         <xs:group ref="textSchema" maxOccurs="1" minOccurs="1" />
  18.     </xs:sequence>
  19.     <xs:attributeGroup ref="Identification" />
  20. </xs:complexType>
  21.  
  22. <xs:complexType name="Configuration">
  23.     <xs:sequence>
  24.         <xs:choice maxOccurs="3" minOccurs="1">
  25.             <xs:element name="textProviders" maxOccurs="unbounded" minOccurs="1" type="TextDataProviders" />
  26.             <xs:element name="csvProviders" maxOccurs="unbounded" minOccurs="0" type="CsvDataProviders" />
  27.             <xs:element name="xmlProviders" maxOccurs="unbounded" minOccurs="0" type="XmlDataProviders" />
  28.         </xs:choice>
  29.     </xs:sequence>
  30. </xs:complexType>
  31.  
  32. <xs:element name="configuration" type="Configuration"></xs:element>
  33.  
  34. <xs:complexType name="TextDataProviders">
  35.     <xs:sequence>
  36.         <xs:element name="dataprovider" type="TextDataProvider" minOccurs="0" maxOccurs="unbounded" />
  37.     </xs:sequence>
  38. </xs:complexType>
  39.  
But that doesn't do the trick, because when I'm forming an xml based on this xsd I can add as many locations of any kind within the location tag

I must be doing something wrong, I just can't see it at this time.

With kind regards,
- SL33PY
May 10 '06 #1
1 1483
SL33PY
3 New Member
I've been thinkering a bit, as well as reading some additional sources and I made a temp xsd and xml:

The temp xsd:
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <xs:schema targetNamespace="XMLSchema1.xsd" elementFormDefault="qualified" xmlns="XMLSchema1.xsd"
  3.     xmlns:mstns="XMLSchema1.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  4.     <xs:element name="Configuration">
  5.         <xs:annotation>
  6.             <xs:documentation>
  7.                 This tag describes the configuration of the system.
  8.                 It consists of maximum 3 childs representing the different kinds of
  9.                 providers that our application can process. Every child represents a group
  10.                 of data providers of a specific kind.
  11.             </xs:documentation>
  12.         </xs:annotation>
  13.         <xs:complexType>
  14.             <xs:choice minOccurs="1" maxOccurs="3">
  15.                 <xs:element name="TextProviders" maxOccurs="1" minOccurs="0" type="xs:string" /><!--type="TextProvidersType" />-->
  16.                 <xs:element name="CsvProviders" maxOccurs="1" minOccurs="0" type="xs:string" /><!--type="CsvProvidersType" />-->
  17.                 <xs:element name="XmlProviders" maxOccurs="1" minOccurs="0" type="xs:string" /><!--type="XmlProvidersType" />-->
  18.             </xs:choice>
  19.         </xs:complexType>
  20.     </xs:element>
  21. </xs:schema>
The temp xml:
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <Configuration xmlns="XMLSchema1.xsd">
  3.     <CsvProviders></CsvProviders>
  4.     <TextProviders></TextProviders>
  5.     <XmlProviders></XmlProviders>
  6. </Configuration>
  7.  
at this moment it works, but...

I adjusted my older xsd file and the xsd gets validated, still I cannot select it from the list (VS 2003) in the targetnamespace property field, I can select the xmlschema1.xsd but not my bigger one :confused:

I'll expand this test xsd and perhaps I can find out why the other doesn't work as intended. If anyone has hints/tips/more insight, please let me know asap

- SL33PY
May 10 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1479
by: James Bright | last post by:
I have set up custom Intellisense for our project. (In a nutshell, we will have ASP.NET controls based on many of the statndard WebControls, but with a few extensions that we will be adding). I've...
30
7380
by: aka | last post by:
Hi I have a DB2 v8.1 on AIX and DB2 Connect EE on Solaris wich is connected to OS/390 DB2 subsystems via APPC / SNA. I have cataloged the DB2 Connect instance as tcpip node and then the Host DB...
0
1198
by: Julia | last post by:
Hi, I am still having Charest conversion difficulties s when passing string from C# TO ASP and than to access using ADO I am using HttpWebRequest to POST some Multilanguage(Hebrew and...
15
1370
by: Edward Diener | last post by:
Why is it impossible to have a __value class instance variable in a __nogc class when it is possible to have a built-in type instance variable in a __nogc class ? __value class X { int a; };...
9
1741
by: Jordan Tiona | last post by:
I can't get this code to work right. It seems to be skipping some of the cin functions. Can someone help me with this? ClassTrack.cpp: #include <iostream> #include "ClassTrack.h" using...
3
9970
by: jg.campbell.ng | last post by:
I'm beginning learning Python and OpenGL in Python. Python fine. But difficulties with OpenGL; presumably with the installation of OpenGL. OS = Linux FC5. Python program gl_test.py: from...
1
1292
by: bau | last post by:
Hi everybody, I am using MS Access 2003 to prepare data for a scientific study. I have a table which look like that: "Customer" "Store" "Product" "Price" "week" "100" ...
0
1022
by: RazSam | last post by:
Hi I am developing in c# .net 2,0 web forms and having some problems. Code is attached below. I have written code to export the contents of a Grid View to Excel, this works. The problem occurs...
2
7581
by: cmb3587 | last post by:
I am having a problem with the validation of the account number and password. The beginning of the program asks for users account # then pwd. The program is then supposed to go to a checkID...
0
7212
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,...
0
7098
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...
0
7364
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...
0
7470
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...
0
5604
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,...
1
5026
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...
0
3186
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
405
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.