473,729 Members | 2,177 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"Type Defintion Cannot be Abstract"

I am trying to implement variable content containers using an abstract
type and type substitution. My schema is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:this="thi s"
targetNamespace ="this" elementFormDefa ult="qualified" >

<complexType name="abstractA nswerType" abstract="true"/>

<complexType name="yesWithDe scType">
<complexContent >
<extension base="this:abst ractAnswerType" >
<sequence>
<element name="descripti on" type="string" />
</sequence>
<attribute name="answer" type="string" fixed="yes"
use="required"/>
</extension>
</complexContent>
</complexType>

<complexType name="noType">
<complexContent >
<extension base="this:abst ractAnswerType" >
<attribute name="answer" type="string" fixed="no"
use="required"/>
</extension>
</complexContent>
</complexType>

<element name="root">
<complexType>
<sequence>
<element name="question" type="this:abst ractAnswerType" />
</sequence>
</complexType>
</element>

</schema>

When I generate a document using my IDE (oXygen), the following
instance document is created:

<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="this"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="this file:/C:/variableContent .xsd">
<question/>
</root>

Which is not valid as "Type Defintion Cannot be Abstract for element
question". I thought my IDE had just failed to perform the type
substition but when I manually create the following instance document:

<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="this"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="this file:/C:/variableContent .xsd">
<question answer="yes">
<description>So me text</description>
</question>
</root>

This too is not valid because "Attribute 'answer' is not allowed to
appear in element 'question'." and "Element 'question' must have no
character or element information item [children], because the type's
content type is empty.". So again it appears as if the validator is
failing to realise that "yesWithDescTyp e" is a valid substitution for
"abstractAnswer Type".

I should mention that I can get this to work when I use element
substitution instead of type substitution.

Any thoughts? I feel I am missing something obvious.

Cheers

Lord0

Feb 26 '07 #1
3 3480
On Feb 26, 12:24 pm, "Lord0" <l...@hotmail.c o.ukwrote:
I am trying to implement variable content containers
using an abstract type and type substitution.
[...]
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="this"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="this file:/C:/variableContent .xsd">
<question answer="yes">
<description>So me text</description>
</question>
</root>

This too is not valid because "Attribute 'answer' is not
allowed to appear in element 'question'." and "Element
'question' must have no character or element information
item [children], because the type's content type is
empty.". So again it appears as if the validator is
failing to realise that "yesWithDescTyp e" is a valid
substitution for "abstractAnswer Type".
I believe XML Schema Part 0: Primer SE, 4.7 explains why
this doesn't work. There doesn't seem to be anything to
help you achieve what you want, though. (I doubt you would
want to use xsi:type, and there doesn't seem to be any
other way to make it work.)

--
Pavel Lepin

Feb 26 '07 #2
I believe XML Schema Part 0: Primer SE, 4.7 explains why this doesn't work

Thanks for the link - it was very useful.
. There doesn't seem to be anything to
help you achieve what you want, though. (I doubt you would
want to use xsi:type, and there doesn't seem to be any
other way to make it work.)

xsi:type does indeed allow it to work! But you're right - I wouldn't
want to use it.
Feb 26 '07 #3
Looking at the doc mentioned above there are examples such as

"<complexTy pe name="US-Address" base="ipo:Addre ss"
derivedBy="exte nsion">"

However according to my parser "base" and "derivedBy" are not valid
attributes for element complexType.

Thoughts?

Feb 26 '07 #4

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

Similar topics

19
15609
by: Roger | last post by:
How can I pass parameters to a style sheet? I have noticed a couple of sites are now passing variables to the style sheet, which appear to be substituted at run time. For example: <link rel="stylesheet" type="text/css" href="mystyle.css?color=ffffff"> I have seen references in my temp Internet file directory that indicates this is possible, but I can't find any documentation how to do it.
0
1862
by: Dave | last post by:
Hi everyone, (I already posted this to the VS.NET IDE news group without any responses, so I'm attempting one more time in this group) The issue I'm having is occuring in the IDE of VS.NET 2003, although I'm not sure what is actually causing the problem. I can't summarize the issue, so please read on to find out more. I've created a BaseDialogEditor class that allows a developer (namely me) to create Modal editors for controls at...
2
2490
by: Bill Zhao | last post by:
Dear all, Sorry for i did not paste original propreity codes See below the fake codes for what I cannot understand. =============================================== lass A { public: virtual int xfunc() = 0 ;
2
1387
by: Ben Fidge | last post by:
I've got a couple of UserControls that are derived from a common base-class. When I try to open them in the IDE, the following error is displayed in a dialog window: "The file failed to load in the Web Form designer. Please correct the following error, then load it again: Type Abstract" This has only just started happening, as I've had the inheritance working for a good week or so now. I've no
2
2974
by: PKuhne | last post by:
When pasting this code from the MS small Business Accounting Beta Concepts manual: DIM skdAssembly as = .LoadFrom(installpath.ToString()) the IDE shows : "Type 'Assembly' not defined" and underlines it in its normal error-indicating fashion. How can I overcome this problem? TIA
0
1253
by: Ken Varn | last post by:
I have the following code that I cannot get to compile. I get the error "A Sealed class cannot be abstract." public __value struct DVRAVIFileHeader : public ISerializable { double EventID; String *EventName; USHORT EventNum; String *EventType;
0
160
by: Jeff Louie | last post by:
Robert.. You can use interfaces or an abstract base class to abstract out the functionality of the plug ins. You then program to the abstraction. In the case of an interface, you program to the public view, the interface. The interface defines a contract between the user of your plug in class and any concrete implementation of the class. The caller programs to the type. The caller does
18
2454
by: Stephan Beal | last post by:
Hi, all! Before i ask my question, i want to clarify that my question is not about the code i will show, but about what the C Standard says should happen. A week or so ago it occurred to me that one can implement a very basic form of subclassing in C (the gurus certainly already know this, but it was news to me). What i've done (shown below) seems to work all fine and well, and does exactly what i'd expect, but i'm asking about
2
2555
by: JonathanSFL | last post by:
BEGIN; DROP TYPE structure.format_list2table_rs CASCADE; CREATE TYPE structure.format_list2table_rs AS ( "item" VARCHAR(4000) ); END;
0
8913
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8761
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
9426
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
9280
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
9142
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
6016
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
4525
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2677
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.