471,594 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,594 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 1929
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by mre | last post: by
3 posts views Thread by man-in-nature | last post: by
8 posts views Thread by aevans1108 | last post: by
3 posts views Thread by Amol | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

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.