472,959 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,959 software developers and data experts.

having difficulties with 'choice'


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>
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>
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>
  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>
  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>
  32. <xs:element name="configuration" type="Configuration"></xs:element>
  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>
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 1453
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>
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

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...
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...
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...
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; };...
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...
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...
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" ...
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...
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...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.