473,399 Members | 4,254 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,399 software developers and data experts.

xsd:extension not inherit attributes?

Does anyone know why if I create a complexType based off another complexType
using xsd:extension the attributes don't seem to be inherited? Is this a
bug/non-implementation in the .NET Schema editor and the XML validator?

Thanks,
Mike Jansen
Nov 12 '05 #1
4 2007
Attributes are always inherited from the base type. Can you provide your
schema?

--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
"Mike Jansen" <mj**********@mail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Does anyone know why if I create a complexType based off another
complexType
using xsd:extension the attributes don't seem to be inherited? Is this a
bug/non-implementation in the .NET Schema editor and the XML validator?

Thanks,
Mike Jansen

Nov 12 '05 #2
Hi Stan,

Thanks for the quick response. My schema is below. I've got a complexType
(table-version-action-add-ct) deriving by extension from another complexType
(column-ct). Then I use table-version-action-add-ct as element
"action-add". In the XML editor, the Intellisense doesn't pickup the
attributes when I add an "action-add" element and if I put in the "name"
attribute, it marks it as invalid. See the XML sample that follows.

(Side note: I'm trying to come up with the best way to do inheritance in XML
using VS.NET. I seem to be running into walls. Could you point me to any
good resources on the best way to do this? I'd like to be able to have
abstract types and use polymorphism using xsi:type or some other method.
Substitution?)

Thanks,
Mike Jansen
Schema:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="DatabaseDefinition"
targetNamespace="urn:schemas-primepro-com:master-script:database-definition"
elementFormDefault="qualified"
xmlns="urn:schemas-primepro-com:master-script:database-definition"
xmlns:mstns="urn:schemas-primepro-com:master-script:database-definition"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.0">
<xs:element name="database-definition"
type="database-definition-ct"></xs:element>
<xs:simpleType name="column-type">
<xs:restriction base="xs:string">
<xs:enumeration value="tinyint" />
<xs:enumeration value="smallint" />
<xs:enumeration value="int" />
<xs:enumeration value="bigint" />
<xs:enumeration value="float" />
<xs:enumeration value="decimal" />
<xs:enumeration value="numeric" />
<xs:enumeration value="money" />
<xs:enumeration value="smalldatetime" />
<xs:enumeration value="datetime" />
<xs:enumeration value="char" />
<xs:enumeration value="varchar" />
<xs:enumeration value="nchar" />
<xs:enumeration value="nvarchar" />
<xs:enumeration value="text" />
<xs:enumeration value="ntext" />
<xs:enumeration value="binary" />
<xs:enumeration value="varbinary" />
<xs:enumeration value="image" />
<xs:enumeration value="uniqueidentifier" />
<xs:enumeration value="sysname" />
</xs:restriction>
</xs:simpleType>
<xs:complexType name="database-definition-ct">
<xs:sequence>
<xs:element name="table" type="table-ct" minOccurs="0"
maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="table-ct">
<xs:sequence>
<xs:element name="column" type="column-ct" maxOccurs="unbounded" />
<xs:element name="version" type="table-version-ct" minOccurs="0"
maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="name" type="xs:string" />
<xs:attribute name="version" type="xs:int" />
</xs:complexType>
<xs:complexType name="column-ct">
<xs:sequence></xs:sequence>
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="description" type="xs:string" use="required" />
<xs:attribute name="length" type="xs:int" use="optional" />
<xs:attribute name="type" type="column-type" use="required" />
<xs:attribute name="nullable" type="xs:boolean" default="false" />
</xs:complexType>
<xs:complexType name="table-version-ct" mixed="false">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="action-add" type="table-version-action-add-ct" />
<xs:element name="action-drop" type="table-version-action-drop-ct" />
</xs:choice>
<xs:attribute name="version" type="xs:int" />
</xs:complexType>
<xs:complexType name="table-version-action-add-ct">
<xs:complexContent>
<xs:extension base="column-ct">
<xs:sequence></xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="table-version-action-drop-ct">
<xs:sequence></xs:sequence>
<xs:attribute name="name" type="xs:string" />
</xs:complexType>
</xs:schema>
XML instance test:

<?xml version="1.0" encoding="utf-8" ?>
<database-definition
xmlns="urn:schemas-primepro-com:master-script:database-definition"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<table name="test" version="1">
<column name="test_pk" type="int" description="Primary key"
nullable="false"/>
<column name="descr" type="varchar" description="Description of record"
length="50" nullable="false"/>
<version version="1">
<action-add name="">
</version>
</table>
</database-definition>

Nov 12 '05 #3
Your xml is missing required attributes (type and description) for
action-add element. XML editor intellisense is working for me. The error
you get on action-add element is that it's missing required attributes.
Other than that both, your schema and your instance doc, are valid.

--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
"Mike Jansen" <mj**********@mail.com> wrote in message
news:e1****************@TK2MSFTNGP12.phx.gbl...
Hi Stan,

Thanks for the quick response. My schema is below. I've got a
complexType
(table-version-action-add-ct) deriving by extension from another
complexType
(column-ct). Then I use table-version-action-add-ct as element
"action-add". In the XML editor, the Intellisense doesn't pickup the
attributes when I add an "action-add" element and if I put in the "name"
attribute, it marks it as invalid. See the XML sample that follows.

(Side note: I'm trying to come up with the best way to do inheritance in
XML
using VS.NET. I seem to be running into walls. Could you point me to any
good resources on the best way to do this? I'd like to be able to have
abstract types and use polymorphism using xsi:type or some other method.
Substitution?)

Thanks,
Mike Jansen
Schema:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="DatabaseDefinition"
targetNamespace="urn:schemas-primepro-com:master-script:database-definition"
elementFormDefault="qualified"
xmlns="urn:schemas-primepro-com:master-script:database-definition"
xmlns:mstns="urn:schemas-primepro-com:master-script:database-definition"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.0">
<xs:element name="database-definition"
type="database-definition-ct"></xs:element>
<xs:simpleType name="column-type">
<xs:restriction base="xs:string">
<xs:enumeration value="tinyint" />
<xs:enumeration value="smallint" />
<xs:enumeration value="int" />
<xs:enumeration value="bigint" />
<xs:enumeration value="float" />
<xs:enumeration value="decimal" />
<xs:enumeration value="numeric" />
<xs:enumeration value="money" />
<xs:enumeration value="smalldatetime" />
<xs:enumeration value="datetime" />
<xs:enumeration value="char" />
<xs:enumeration value="varchar" />
<xs:enumeration value="nchar" />
<xs:enumeration value="nvarchar" />
<xs:enumeration value="text" />
<xs:enumeration value="ntext" />
<xs:enumeration value="binary" />
<xs:enumeration value="varbinary" />
<xs:enumeration value="image" />
<xs:enumeration value="uniqueidentifier" />
<xs:enumeration value="sysname" />
</xs:restriction>
</xs:simpleType>
<xs:complexType name="database-definition-ct">
<xs:sequence>
<xs:element name="table" type="table-ct" minOccurs="0"
maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="table-ct">
<xs:sequence>
<xs:element name="column" type="column-ct" maxOccurs="unbounded" />
<xs:element name="version" type="table-version-ct" minOccurs="0"
maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="name" type="xs:string" />
<xs:attribute name="version" type="xs:int" />
</xs:complexType>
<xs:complexType name="column-ct">
<xs:sequence></xs:sequence>
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="description" type="xs:string" use="required" />
<xs:attribute name="length" type="xs:int" use="optional" />
<xs:attribute name="type" type="column-type" use="required" />
<xs:attribute name="nullable" type="xs:boolean" default="false" />
</xs:complexType>
<xs:complexType name="table-version-ct" mixed="false">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="action-add" type="table-version-action-add-ct" />
<xs:element name="action-drop" type="table-version-action-drop-ct" />
</xs:choice>
<xs:attribute name="version" type="xs:int" />
</xs:complexType>
<xs:complexType name="table-version-action-add-ct">
<xs:complexContent>
<xs:extension base="column-ct">
<xs:sequence></xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="table-version-action-drop-ct">
<xs:sequence></xs:sequence>
<xs:attribute name="name" type="xs:string" />
</xs:complexType>
</xs:schema>
XML instance test:

<?xml version="1.0" encoding="utf-8" ?>
<database-definition
xmlns="urn:schemas-primepro-com:master-script:database-definition"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<table name="test" version="1">
<column name="test_pk" type="int" description="Primary key"
nullable="false"/>
<column name="descr" type="varchar" description="Description of record"
length="50" nullable="false"/>
<version version="1">
<action-add name="">
</version>
</table>
</database-definition>

Nov 12 '05 #4
Hi Mike,

I was using XML Editor in VS2005 beta. It is possible that VS2003 has a
problem with this.

--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
"Mike Jansen" <mj**********@mail.com> wrote in message
news:u4**************@TK2MSFTNGP09.phx.gbl...
I tried it again and I'm still getting the same problems. I realize I was
missing the required attributes in the XML file; I just put that together
more for you to easily work with and see. I'm still not getting
intellisense on the attributes for action-add. Is there is aVS.NET
service
pack I could be missing? My help/about says "Microsoft Development
Environment 2003 Version 7.1.3088". I've got MSXML 4.0 installed. (BTW,
I've also got BizTalk 2004 installed.)

I even tried this: took the schema and xml I posted to you (directly from
the newsgroup message), pasted into two brand new files in a brand new
.NET
C# project. I did the usual, close files, open files to get the
Intellisense to recognize the schema. I deleted the <action-add> element
and then using intellisense (just typing "<" from within the <version>
element), I added the <action-add> but when I type space after
"<action-add"
I don't get the attribute list. Furthermore, I'm still getting the
message
"Could not find any attribute 'name' of element 'action-add'." I've
attached a screen shot.

Thanks for your help,
Mike

"Stan Kitsis [MSFT]" <sk***@microsoft.com> wrote in message
news:42********@news.microsoft.com...
Your xml is missing required attributes (type and description) for
action-add element. XML editor intellisense is working for me. The
error
you get on action-add element is that it's missing required attributes.
Other than that both, your schema and your instance doc, are valid.

--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no

rights.


"Mike Jansen" <mj**********@mail.com> wrote in message
news:e1****************@TK2MSFTNGP12.phx.gbl...
> Hi Stan,
>
> Thanks for the quick response. My schema is below. I've got a
> complexType
> (table-version-action-add-ct) deriving by extension from another
> complexType
> (column-ct). Then I use table-version-action-add-ct as element
> "action-add". In the XML editor, the Intellisense doesn't pickup the
> attributes when I add an "action-add" element and if I put in the
> "name"
> attribute, it marks it as invalid. See the XML sample that follows.
>
> (Side note: I'm trying to come up with the best way to do inheritance
> in
> XML
> using VS.NET. I seem to be running into walls. Could you point me to any > good resources on the best way to do this? I'd like to be able to have
> abstract types and use polymorphism using xsi:type or some other
> method.
> Substitution?)
>
> Thanks,
> Mike Jansen
>
>
> Schema:
>
> <?xml version="1.0" encoding="utf-8" ?>
> <xs:schema id="DatabaseDefinition"
> targetNamespace="urn:schemas-primepro-com:master-script:database-definition" > elementFormDefault="qualified"
> xmlns="urn:schemas-primepro-com:master-script:database-definition"
> xmlns:mstns="urn:schemas-primepro-com:master-script:database-definition" > xmlns:xs="http://www.w3.org/2001/XMLSchema"
> version="1.0">
> <xs:element name="database-definition"
> type="database-definition-ct"></xs:element>
> <xs:simpleType name="column-type">
> <xs:restriction base="xs:string">
> <xs:enumeration value="tinyint" />
> <xs:enumeration value="smallint" />
> <xs:enumeration value="int" />
> <xs:enumeration value="bigint" />
> <xs:enumeration value="float" />
> <xs:enumeration value="decimal" />
> <xs:enumeration value="numeric" />
> <xs:enumeration value="money" />
> <xs:enumeration value="smalldatetime" />
> <xs:enumeration value="datetime" />
> <xs:enumeration value="char" />
> <xs:enumeration value="varchar" />
> <xs:enumeration value="nchar" />
> <xs:enumeration value="nvarchar" />
> <xs:enumeration value="text" />
> <xs:enumeration value="ntext" />
> <xs:enumeration value="binary" />
> <xs:enumeration value="varbinary" />
> <xs:enumeration value="image" />
> <xs:enumeration value="uniqueidentifier" />
> <xs:enumeration value="sysname" />
> </xs:restriction>
> </xs:simpleType>
> <xs:complexType name="database-definition-ct">
> <xs:sequence>
> <xs:element name="table" type="table-ct" minOccurs="0"
> maxOccurs="unbounded" />
> </xs:sequence>
> </xs:complexType>
> <xs:complexType name="table-ct">
> <xs:sequence>
> <xs:element name="column" type="column-ct" maxOccurs="unbounded"
> />
> <xs:element name="version" type="table-version-ct" minOccurs="0"
> maxOccurs="unbounded" />
> </xs:sequence>
> <xs:attribute name="name" type="xs:string" />
> <xs:attribute name="version" type="xs:int" />
> </xs:complexType>
> <xs:complexType name="column-ct">
> <xs:sequence></xs:sequence>
> <xs:attribute name="name" type="xs:string" use="required" />
> <xs:attribute name="description" type="xs:string" use="required" />
> <xs:attribute name="length" type="xs:int" use="optional" />
> <xs:attribute name="type" type="column-type" use="required" />
> <xs:attribute name="nullable" type="xs:boolean" default="false" />
> </xs:complexType>
> <xs:complexType name="table-version-ct" mixed="false">
> <xs:choice minOccurs="0" maxOccurs="unbounded">
> <xs:element name="action-add" type="table-version-action-add-ct"
> />
> <xs:element name="action-drop" type="table-version-action-drop-ct" /> > </xs:choice>
> <xs:attribute name="version" type="xs:int" />
> </xs:complexType>
> <xs:complexType name="table-version-action-add-ct">
> <xs:complexContent>
> <xs:extension base="column-ct">
> <xs:sequence></xs:sequence>
> </xs:extension>
> </xs:complexContent>
> </xs:complexType>
> <xs:complexType name="table-version-action-drop-ct">
> <xs:sequence></xs:sequence>
> <xs:attribute name="name" type="xs:string" />
> </xs:complexType>
> </xs:schema>
>
>
> XML instance test:
>
> <?xml version="1.0" encoding="utf-8" ?>
> <database-definition
> xmlns="urn:schemas-primepro-com:master-script:database-definition"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <table name="test" version="1">
> <column name="test_pk" type="int" description="Primary key"
> nullable="false"/>
> <column name="descr" type="varchar" description="Description of record" > length="50" nullable="false"/>
> <version version="1">
> <action-add name="">
> </version>
> </table>
> </database-definition>
>
>
>



Nov 12 '05 #5

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

Similar topics

2
by: Sean Bright | last post by:
Hi there. I'm having a problem which I hope is a simple one... Any help would be appreciated. I think it has something to do with the way attributes are (or are not) inherited in schemas... ...
1
by: mre | last post by:
Is there a program that will flatten an XSD, that is, will transform... <xsd:element name="name" type="nameType"/> <xsd:complexType name="nameType"> <xsd:sequence> <xsd:element...
4
by: trexim | last post by:
It seems that .NET does not support xsd:extension and xsd:attribute. What is the alternative? Thanks,
3
by: man-in-nature | last post by:
Hello, I have already read several existing posts about xsd:extension, but do not find something useful to my test case. I have one xml file and one xsd file. I can use a simple command line...
8
by: aevans1108 | last post by:
Greetings I can't seem to inherit enumerated values from a globally defined type in my XML schema. XmlSchema.Compile() doesn't like it. Here's the schema. <?xml version="1.0"...
3
by: comic_rage | last post by:
I am trying to get my schema to look like this <xsd:extension base="MyExtension"> <xsd:attributeGroup ref="DocumentAttributes"> <xsd:annotation> <xsd:documentation>Notes</xsd:documentation>...
3
by: Amol | last post by:
Hi all, I have a case where I have a element that can appear under multiple elements e.g. <AppFunctions> <UseTemplate name="1"/> <MethodSet name="2"> <UseTemplate name="3" /> <MethodCall...
5
by: Kunal | last post by:
I'm unable to use the "xsd:all" tag in derived objects, in a hierarchical schema setup. For example, I have the following schema (that doesn't validate with XMLSpy): (UserOfDerived extends...
4
by: Dmitry Kulinich | last post by:
Guys! Is there are any possibility to create nodes with duplicate names and different types in XSD? I've read the whole specification and tried in a many different ways, but not successfull. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
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
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...

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.