473,394 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

"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="this"
targetNamespace="this" elementFormDefault="qualified">

<complexType name="abstractAnswerType" abstract="true"/>

<complexType name="yesWithDescType">
<complexContent>
<extension base="this:abstractAnswerType">
<sequence>
<element name="description" type="string" />
</sequence>
<attribute name="answer" type="string" fixed="yes"
use="required"/>
</extension>
</complexContent>
</complexType>

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

<element name="root">
<complexType>
<sequence>
<element name="question" type="this:abstractAnswerType" />
</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:schemaLocation="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:schemaLocation="this file:/C:/variableContent.xsd">
<question answer="yes">
<description>Some 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 "yesWithDescType" is a valid substitution for
"abstractAnswerType".

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 3440
On Feb 26, 12:24 pm, "Lord0" <l...@hotmail.co.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:schemaLocation="this file:/C:/variableContent.xsd">
<question answer="yes">
<description>Some 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 "yesWithDescType" is a valid
substitution for "abstractAnswerType".
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

"<complexType name="US-Address" base="ipo:Address"
derivedBy="extension">"

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
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...
0
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...
2
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...
2
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...
2
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...
0
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;...
0
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...
18
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...
2
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
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.