473,466 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

circular references in schemas

I have created an xml format for describing a custom user interface. My
application successfully parses and displays the UI described in xml files
created in that format.

Before today we were using Visual Studio .net 2002. I created a schema file
to describe my xml so that I could use the fancy xml editing capabilities in
the Visual Studio enviroment. With this schema referenced, I could
auto-complete while scripting xml for my user interface while editing in
DevStudio. A pretty neat feature, even though it wasn't really necessary.

Today we upgraded to Visual Studio .net 2003. One of the changes seems to be
that schema files are compiled instead of interpreted directly. The compiler
gives the following error on compile: "DataSet doesn't allow the circular
reference in the ComplexType named 'Window'". So no more fancy editing. :(

This isn't a Microsoft-specific problem, I get a similar error if I try to
use an application I downloaded via w3.org to validate xml using my schema.

My script allows you to create windows with child windows, which can also
have children. A pretty standard windowing system, I think. But it doesn't
seem legal xml to make a window element a child of a window element. I'm not
really familiar with all the logic and theory behind xml, I just thought it
was a convenient way to script our UI. I would like to understand why these
"circular references" are not allowed in the schema, and what alternatives a
proper xml guru might suggest for my situation.

Below is a simple schema that has this problem

<schema targetNamespace="test.xsd" elementFormDefault="qualified"
xmlns=http://www.w3.org/2001/XMLSchema xmlns:ui="test.xsd">
<element name="test">
<complexType>
<sequence>
<element name="window" type="ui:Window" />
</sequence>
</complexType>
</element>
<complexType name="Window">
<sequence>
<element name="children">
<complexType>
<sequence>
<element name="childWindow"
type="ui:Window" />
</sequence>
</complexType>
</element>
<element name="testString" type="string" />
</sequence>
</complexType>
</schema>


Jul 20 '05 #1
3 5616
"Christine McGavran" <cm*******@perpetualent.com> writes:
Today we upgraded to Visual Studio .net 2003. One of the
changes seems to be that schema files are compiled instead
of interpreted directly. The compiler gives the following
error on compile: "DataSet doesn't allow the circular
reference in the ComplexType named 'Window'". So no more
fancy editing. :(
Is that the entirety of the error message?
This isn't a Microsoft-specific problem, I get a similar
error if I try to use an application I downloaded via w3.org
to validate xml using my schema.
More details, please? Do you mean XSV? If so, what exactly is the
error code XSV is giving you? I don't get any schema error from XSV
on the sample schema you provided (although I do get errors on any
document I provide, for reasons which will become clear below).
My script allows you to create windows with child windows,
which can also have children. A pretty standard windowing system,
I think. But it doesn't seem legal xml to make a window element a
child of a window element.
Ouch! No! Don't think that!

There is nothing in XML or in XML Schema that makes such
recursion illegal. (And to be fair, note that the error message
you quote from Visual Studio doesn't actually say it's illegal
XML, or a schema error. It says there is something there that
Visual Studio doesn't support.)
I'm not really familiar with all the logic and theory behind xml,
I just thought it was a convenient way to script our UI. I would
like to understand why these "circular references" are not allowed
in the schema, and what alternatives a proper xml guru might suggest
for my situation.

Below is a simple schema that has this problem
I'll take you at your word, though I suspect you did not
paste this in direct from a schema document that got the
same error message you give above. (I suspect it because
the xmlns attribute is missing its required quotation marks,
and you should have gotten a well-formedness error long
before anyone started worrying about circularity.)
<schema targetNamespace="test.xsd"
elementFormDefault="qualified"
xmlns=http://www.w3.org/2001/XMLSchema
er, "http://www.w3.org/2001/XMLSchema"
xmlns:ui="test.xsd">
<element name="test">
<complexType>
<sequence>
<element name="window" type="ui:Window" />
</sequence>
</complexType>
</element>
<complexType name="Window">
<sequence>
<element name="children">
<complexType>
<sequence>
<element name="childWindow"
type="ui:Window" />
</sequence>
</complexType>
</element>
<element name="testString" type="string" />
</sequence>
</complexType>
</schema>


If Visual Studio is complaining about the same problem
I see with this schema, I have to say I'm moderately
impressed with its acuity.

Both XSV and Xerces J believe, as I do, that the schema
document you give is valid, once the xmlns attribute gets
its quotation marks. The only problem with it is that
there are no finite documents which conform to it.
The problem is not the recursion per se, it's the fact
that there is no bottom to it, just as in the following
instructions there is no way to reach step 5.

0 Start. Go to step 1.

1 You have a top-level element named 'test', which has
a required child named 'window'. Go to step 2.

2 The 'window' element, being of type ui:Window, has
required children named 'children' and 'testString'.
Go to step 3.

3 The 'children' element has exactly one required child
named 'childWindow'. Go to step 4.

4 The 'childWindow' element, being of type ui:Window, has
required children named 'children' and 'testString'.
Go to step 3.

5 Done.

If I change the schema so that the childWindow element is
optional, then I can create a finite document which conforms
to the schema. In practice, I suspect you also want to
specify that a window can have more than one childWindow
among its children. One way to do this is to change the
declaration for 'childWindow' thus:

<element name="childWindow"
minOccurs="0"
maxOccurs="unbounded"
type="ui:Window" />

There are other ways, of course.

Is this the problem with your real schema, or is the
absence of the minOccurs and maxOccurs an artifact of
the way you cut down the problem for presentation in
your post?

You asked what alternatives others might suggest. My
first suggestion is to correct the occurrence information.
My second would be to change the name of the child
window to 'window', to make the recursion even more
obvious, unless there is a strong reason to distinguish
top-level windows from others (in which case, I'd
probably use the names 'topWindow' and 'window'
rather than 'window' and 'childWindow' -- but naming
is a matter of taste, and you should suit yourself and
your collaborators, not me).

I hope this helps,

-C. M. Sperberg-McQueen
World Wide Web Consortium
Jul 20 '05 #2
> Is that the entirety of the error message?

yes
Do you mean XSV?
I'm not really sure what Microsoft uses, but I don't think it's XSV. The
tool is called "XML Data Proxy Generator."
I don't get any schema error from XSV
on the sample schema you provided
There is nothing in XML or in XML Schema that makes such
recursion illegal. Then maybe it's a Microsoft issue after all.. I've also posted to the
Microsoft group.
I'll take you at your word, though I suspect you did not
paste this in direct from a schema document that got the
same error message you give above. (I suspect it because
the xmlns attribute is missing its required quotation marks,
You know I did paste it directly, but the document I pasted from has the
quotation marks. Beats me why they got left out... probably some Outlook
thing. :P
If I change the schema so that the childWindow element is
optional, then I can create a finite document which conforms
to the schema. In practice, I suspect you also want to
specify that a window can have more than one childWindow
among its children. One way to do this is to change the
declaration for 'childWindow' thus:

<element name="childWindow"
minOccurs="0"
maxOccurs="unbounded"
type="ui:Window" /> Doing this doesn't change my results at all.
Is this the problem with your real schema, or is the
absence of the minOccurs and maxOccurs an artifact of
the way you cut down the problem for presentation in
your post?
I knew about the minOccurs/maxOccurs thing, but Microsoft seemed to ignore
them, at least in the old version of DevStudio, so I had left them out of my
test.
My second would be to change the name of the child
window to 'window', to make the recursion even more
obvious
My actual schema (not the test) does this, actually. I was just trying to be
clear for the test.
I hope this helps,


Wish it did. I do thank you for letting me know I'm not trying to do
something entirely weird.
Jul 20 '05 #3
Just to follow-up, I got the response below from the Microsoft group.

I did finally manage to get the smart editor to work on my test schema
without the compile step, so I guess the compile step isn't needed after all
for the editing feature (which is all I really cared about). My real schema
doesn't work yet, so I guess I just rebuild it step-by-step until I figure
out what it doesn't like, when I get some time.

--

that is a drawback of the Data View in vs.net, it would never lend
itself well to this type of implementation.

"The Visual Studio .NET XML Designer applies the Microsoft ADO.NET
schema inference rules to determine the schema information for the
source XML when it tries to generate Data view. The ADO.NET schema
inference rules in the RTM release of the Microsoft .NET Framework do
not permit a single table to be a child table in more than one
DataRelation. "


Jul 20 '05 #4

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

Similar topics

16
by: Kiuhnm | last post by:
Is there an elegant way to deal with semi-circular definitions? Semi-circular definition: A { B }; B { *A }; Circular reference: A { *B }; B { *A }; The problems arise when there are more...
2
by: Earth Worm Jim | last post by:
I have been able to get simple circular references to be serialized in xml by using the ImportTypeMapping method on the SoapReflectionImporter class. But I am unable to serialise circular...
12
by: Frank Rizzo | last post by:
I have a circular reference between 2 classes in the same project (i.e. each class refers to the other). The app runs fine and I am seeing no issues, which kind of surprised me. Are there any...
5
by: Gos | last post by:
Hi, It is known that .NET does not allow us to add circular references. Is there a way to workaround this problem by late-binding the objects at run time? Will this create any other problems? ...
6
by: Stephen Robertson | last post by:
We are currently in a dead end with a circular reference issue using vb.net, and are hoping someone might help us resolve it. Idea... We have frmmain calling frmperson (dim f as new frmperson)...
2
by: Lapu-Lapu | last post by:
I have authored a web service using ASP 2.0. The web services return objects that use generics and that also contain circular references. Programmatically, everything works well, as long as you...
5
by: Madhur | last post by:
Hello If I define two classes in the same cs file. And in each class, I define the object of other class as a member. Can anyone explain me how .NET or its compiler will resolve this kind of...
3
by: =?Utf-8?B?UGF1bCBIYWxl?= | last post by:
Moving all User Controls to a single directory has solved my problem - Thanks Eliyahu. That said, I still got one Circular ref error yesterday, rebuilt again and the build was fine? Far far...
2
by: Dansk | last post by:
Hi all, I am currently writing some code that explores assemblies dependencies. I start loading the first assembly with Assmebly.LoadFrom which gives me an Assembly instance. Then, I...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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,...
0
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...
1
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...
0
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,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.