473,386 Members | 1,810 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,386 software developers and data experts.

vs2003 & xsd:extension

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 (C#) program to validate the xml file against
the xsd file without any error. The problem is that when I validate the same
xml file within VisualStudio 2003, I got five errors, which are all related
to xsd:extension. It seems that those "problem" attributes and elements are
not inherited in the derived type. Here is one of the famous error:

Could not find any attribute 'routingNum' of element 'hat'.

Any input is appreciated much. Thanks.

The following are the xml file and the xsd:

<!--Definitive XML Schema by Priscilla Walmsley (c) 2001 Prentice Hall PTR -->
<c:items xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://chapter14.xsd
http://localhost/xsd/chapter14.xsd"
xmlns:c="http://chapter14.xsd">
<hat routingNum="123456" effDate="2002-04-02" lang="en-US">
<number>557</number>
<name>Ten-Gallon Hat</name>
<description>This is a great hat!</description>
</hat>
<umbrella routingNum="123" effDate="2002-04-02">
<number>557</number>
<name>Ten-Gallon Hat</name>
</umbrella>
<shirt routingNum="124" effDate="2002-04-02" sleeve="17">
<number>557</number>
<name>Short-Sleeved Linen Blouse</name>
<color value="blue"/>
<size system="US-DRESS">6</size>
</shirt>
</c:items>

---------------------------------------------------
<!--Definitive XML Schema by Priscilla Walmsley (c) 2001 Prentice Hall PTR -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://chapter14.xsd"
xmlns="http://chapter14.xsd">

<xsd:annotation>
<xsd:documentation>
This example illustrates complex types that are derived from other
specified types.
</xsd:documentation>
</xsd:annotation>

<xsd:element name="items" type="ItemsType"/>

<xsd:complexType name="ItemsType">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="hat" type="ProductType"/>
<xsd:element name="umbrella" type="RestrictedProductType"/>
<xsd:element name="shirt" type="ShirtType"/>
</xsd:choice>
</xsd:complexType>

<!--Empty Content Type-->
<xsd:complexType name="ItemType" abstract="true">
<xsd:attribute name="routingNum" type="xsd:integer"/>
</xsd:complexType>

<!--Empty Content Extension (with Attribute Extension)-->
<xsd:complexType name="ProductType">
<xsd:complexContent>
<xsd:extension base="ItemType">
<xsd:sequence>
<xsd:element name="number" type="xsd:integer"/>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="description" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="effDate" type="xsd:date"/>
<xsd:attribute name="lang" type="xsd:language"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<!--Complex Content Restriction-->
<xsd:complexType name="RestrictedProductType">
<xsd:complexContent>
<xsd:restriction base="ProductType">
<xsd:sequence>
<xsd:element name="number" type="xsd:integer"/>
<xsd:element name="name" type="xsd:token"/>
</xsd:sequence>
<xsd:attribute name="routingNum" type="xsd:short" use="required"/>
<xsd:attribute name="effDate" type="xsd:date" default="1900-01-01"/>
<xsd:attribute name="lang" use="prohibited"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>

<!--Complex Content Extension-->
<xsd:complexType name="ShirtType">
<xsd:complexContent>
<xsd:extension base="RestrictedProductType">
<xsd:choice maxOccurs="unbounded">
<xsd:element name="size" type="SmallSizeType"/>
<xsd:element name="color" type="ColorType"/>
</xsd:choice>
<xsd:attribute name="sleeve" type="xsd:integer"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<!--Simple Content Extension-->
<xsd:complexType name="SizeType">
<xsd:simpleContent>
<xsd:extension base="xsd:integer">
<xsd:attribute name="system" type="xsd:token"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>

<!--Simple Content Restriction-->
<xsd:complexType name="SmallSizeType">
<xsd:simpleContent>
<xsd:restriction base="SizeType">
<xsd:minInclusive value="2"/>
<xsd:maxInclusive value="6"/>
<xsd:attribute name="system" type="xsd:token"
use="required"/>
</xsd:restriction>
</xsd:simpleContent>
</xsd:complexType>

<xsd:complexType name="ColorType">
<xsd:attribute name="value" type="xsd:string"/>
</xsd:complexType>

</xsd:schema>

Nov 12 '05 #1
3 2033
Your xml and xsd validate fine with the validation engine in VS 2003. Are
you putting your schema file in the right location?

"man-in-nature" <ma*********@discussions.microsoft.com> wrote in message
news:DA**********************************@microsof t.com...
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 (C#) program to validate the xml file against the xsd file without any error. The problem is that when I validate the same xml file within VisualStudio 2003, I got five errors, which are all related to xsd:extension. It seems that those "problem" attributes and elements are not inherited in the derived type. Here is one of the famous error:

Could not find any attribute 'routingNum' of element 'hat'.

Any input is appreciated much. Thanks.

The following are the xml file and the xsd:

<!--Definitive XML Schema by Priscilla Walmsley (c) 2001 Prentice Hall PTR --> <c:items xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://chapter14.xsd
http://localhost/xsd/chapter14.xsd"
xmlns:c="http://chapter14.xsd">
<hat routingNum="123456" effDate="2002-04-02" lang="en-US">
<number>557</number>
<name>Ten-Gallon Hat</name>
<description>This is a great hat!</description>
</hat>
<umbrella routingNum="123" effDate="2002-04-02">
<number>557</number>
<name>Ten-Gallon Hat</name>
</umbrella>
<shirt routingNum="124" effDate="2002-04-02" sleeve="17">
<number>557</number>
<name>Short-Sleeved Linen Blouse</name>
<color value="blue"/>
<size system="US-DRESS">6</size>
</shirt>
</c:items>

---------------------------------------------------
<!--Definitive XML Schema by Priscilla Walmsley (c) 2001 Prentice Hall PTR --> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://chapter14.xsd"
xmlns="http://chapter14.xsd">

<xsd:annotation>
<xsd:documentation>
This example illustrates complex types that are derived from other
specified types.
</xsd:documentation>
</xsd:annotation>

<xsd:element name="items" type="ItemsType"/>

<xsd:complexType name="ItemsType">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="hat" type="ProductType"/>
<xsd:element name="umbrella" type="RestrictedProductType"/>
<xsd:element name="shirt" type="ShirtType"/>
</xsd:choice>
</xsd:complexType>

<!--Empty Content Type-->
<xsd:complexType name="ItemType" abstract="true">
<xsd:attribute name="routingNum" type="xsd:integer"/>
</xsd:complexType>

<!--Empty Content Extension (with Attribute Extension)-->
<xsd:complexType name="ProductType">
<xsd:complexContent>
<xsd:extension base="ItemType">
<xsd:sequence>
<xsd:element name="number" type="xsd:integer"/>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="description" type="xsd:string" minOccurs="0"/> </xsd:sequence>
<xsd:attribute name="effDate" type="xsd:date"/>
<xsd:attribute name="lang" type="xsd:language"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<!--Complex Content Restriction-->
<xsd:complexType name="RestrictedProductType">
<xsd:complexContent>
<xsd:restriction base="ProductType">
<xsd:sequence>
<xsd:element name="number" type="xsd:integer"/>
<xsd:element name="name" type="xsd:token"/>
</xsd:sequence>
<xsd:attribute name="routingNum" type="xsd:short" use="required"/>
<xsd:attribute name="effDate" type="xsd:date" default="1900-01-01"/> <xsd:attribute name="lang" use="prohibited"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>

<!--Complex Content Extension-->
<xsd:complexType name="ShirtType">
<xsd:complexContent>
<xsd:extension base="RestrictedProductType">
<xsd:choice maxOccurs="unbounded">
<xsd:element name="size" type="SmallSizeType"/>
<xsd:element name="color" type="ColorType"/>
</xsd:choice>
<xsd:attribute name="sleeve" type="xsd:integer"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<!--Simple Content Extension-->
<xsd:complexType name="SizeType">
<xsd:simpleContent>
<xsd:extension base="xsd:integer">
<xsd:attribute name="system" type="xsd:token"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>

<!--Simple Content Restriction-->
<xsd:complexType name="SmallSizeType">
<xsd:simpleContent>
<xsd:restriction base="SizeType">
<xsd:minInclusive value="2"/>
<xsd:maxInclusive value="6"/>
<xsd:attribute name="system" type="xsd:token"
use="required"/>
</xsd:restriction>
</xsd:simpleContent>
</xsd:complexType>

<xsd:complexType name="ColorType">
<xsd:attribute name="value" type="xsd:string"/>
</xsd:complexType>

</xsd:schema>

Nov 12 '05 #2
I'm having the same problem with attributes from base types showing up
properly in the derived type in VS.NET 2003. VS understands the rest of the
schema, so it's finding the schema. It just doesn't seem to recognize
attributes from the base type of an xs:extension'ed type.
"man-in-nature" <ma*********@discussions.microsoft.com> wrote in message
news:DA**********************************@microsof t.com...
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 (C#) program to validate the xml file against the xsd file without any error. The problem is that when I validate the same xml file within VisualStudio 2003, I got five errors, which are all related to xsd:extension. It seems that those "problem" attributes and elements are not inherited in the derived type. Here is one of the famous error:

Could not find any attribute 'routingNum' of element 'hat'.

Any input is appreciated much. Thanks.

The following are the xml file and the xsd:

<!--Definitive XML Schema by Priscilla Walmsley (c) 2001 Prentice Hall PTR --> <c:items xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://chapter14.xsd
http://localhost/xsd/chapter14.xsd"
xmlns:c="http://chapter14.xsd">
<hat routingNum="123456" effDate="2002-04-02" lang="en-US">
<number>557</number>
<name>Ten-Gallon Hat</name>
<description>This is a great hat!</description>
</hat>
<umbrella routingNum="123" effDate="2002-04-02">
<number>557</number>
<name>Ten-Gallon Hat</name>
</umbrella>
<shirt routingNum="124" effDate="2002-04-02" sleeve="17">
<number>557</number>
<name>Short-Sleeved Linen Blouse</name>
<color value="blue"/>
<size system="US-DRESS">6</size>
</shirt>
</c:items>

---------------------------------------------------
<!--Definitive XML Schema by Priscilla Walmsley (c) 2001 Prentice Hall PTR --> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://chapter14.xsd"
xmlns="http://chapter14.xsd">

<xsd:annotation>
<xsd:documentation>
This example illustrates complex types that are derived from other
specified types.
</xsd:documentation>
</xsd:annotation>

<xsd:element name="items" type="ItemsType"/>

<xsd:complexType name="ItemsType">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="hat" type="ProductType"/>
<xsd:element name="umbrella" type="RestrictedProductType"/>
<xsd:element name="shirt" type="ShirtType"/>
</xsd:choice>
</xsd:complexType>

<!--Empty Content Type-->
<xsd:complexType name="ItemType" abstract="true">
<xsd:attribute name="routingNum" type="xsd:integer"/>
</xsd:complexType>

<!--Empty Content Extension (with Attribute Extension)-->
<xsd:complexType name="ProductType">
<xsd:complexContent>
<xsd:extension base="ItemType">
<xsd:sequence>
<xsd:element name="number" type="xsd:integer"/>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="description" type="xsd:string" minOccurs="0"/> </xsd:sequence>
<xsd:attribute name="effDate" type="xsd:date"/>
<xsd:attribute name="lang" type="xsd:language"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<!--Complex Content Restriction-->
<xsd:complexType name="RestrictedProductType">
<xsd:complexContent>
<xsd:restriction base="ProductType">
<xsd:sequence>
<xsd:element name="number" type="xsd:integer"/>
<xsd:element name="name" type="xsd:token"/>
</xsd:sequence>
<xsd:attribute name="routingNum" type="xsd:short" use="required"/>
<xsd:attribute name="effDate" type="xsd:date" default="1900-01-01"/> <xsd:attribute name="lang" use="prohibited"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>

<!--Complex Content Extension-->
<xsd:complexType name="ShirtType">
<xsd:complexContent>
<xsd:extension base="RestrictedProductType">
<xsd:choice maxOccurs="unbounded">
<xsd:element name="size" type="SmallSizeType"/>
<xsd:element name="color" type="ColorType"/>
</xsd:choice>
<xsd:attribute name="sleeve" type="xsd:integer"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<!--Simple Content Extension-->
<xsd:complexType name="SizeType">
<xsd:simpleContent>
<xsd:extension base="xsd:integer">
<xsd:attribute name="system" type="xsd:token"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>

<!--Simple Content Restriction-->
<xsd:complexType name="SmallSizeType">
<xsd:simpleContent>
<xsd:restriction base="SizeType">
<xsd:minInclusive value="2"/>
<xsd:maxInclusive value="6"/>
<xsd:attribute name="system" type="xsd:token"
use="required"/>
</xsd:restriction>
</xsd:simpleContent>
</xsd:complexType>

<xsd:complexType name="ColorType">
<xsd:attribute name="value" type="xsd:string"/>
</xsd:complexType>

</xsd:schema>

Nov 12 '05 #3
Yes, VS2003 can find the schema in question. It never complains that "Visual
Studio could not locate a schema for this document...". It is easy to verify
this by changing the target name space in the instance document
("xmlns:c="http://chanpter14.xsd") to something else.

Regards

"Zafar Abbas [MSFT]" wrote:
Your xml and xsd validate fine with the validation engine in VS 2003. Are
you putting your schema file in the right location?

"man-in-nature" <ma*********@discussions.microsoft.com> wrote in message
news:DA**********************************@microsof t.com...
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 (C#) program to validate the xml file

against
the xsd file without any error. The problem is that when I validate the

same
xml file within VisualStudio 2003, I got five errors, which are all

related
to xsd:extension. It seems that those "problem" attributes and elements

are
not inherited in the derived type. Here is one of the famous error:

Could not find any attribute 'routingNum' of element 'hat'.

Any input is appreciated much. Thanks.

The following are the xml file and the xsd:

<!--Definitive XML Schema by Priscilla Walmsley (c) 2001 Prentice Hall

PTR -->
<c:items xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://chapter14.xsd
http://localhost/xsd/chapter14.xsd"
xmlns:c="http://chapter14.xsd">
<hat routingNum="123456" effDate="2002-04-02" lang="en-US">
<number>557</number>
<name>Ten-Gallon Hat</name>
<description>This is a great hat!</description>
</hat>
<umbrella routingNum="123" effDate="2002-04-02">
<number>557</number>
<name>Ten-Gallon Hat</name>
</umbrella>
<shirt routingNum="124" effDate="2002-04-02" sleeve="17">
<number>557</number>
<name>Short-Sleeved Linen Blouse</name>
<color value="blue"/>
<size system="US-DRESS">6</size>
</shirt>
</c:items>

---------------------------------------------------
<!--Definitive XML Schema by Priscilla Walmsley (c) 2001 Prentice Hall

PTR -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://chapter14.xsd"
xmlns="http://chapter14.xsd">

<xsd:annotation>
<xsd:documentation>
This example illustrates complex types that are derived from other
specified types.
</xsd:documentation>
</xsd:annotation>

<xsd:element name="items" type="ItemsType"/>

<xsd:complexType name="ItemsType">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="hat" type="ProductType"/>
<xsd:element name="umbrella" type="RestrictedProductType"/>
<xsd:element name="shirt" type="ShirtType"/>
</xsd:choice>
</xsd:complexType>

<!--Empty Content Type-->
<xsd:complexType name="ItemType" abstract="true">
<xsd:attribute name="routingNum" type="xsd:integer"/>
</xsd:complexType>

<!--Empty Content Extension (with Attribute Extension)-->
<xsd:complexType name="ProductType">
<xsd:complexContent>
<xsd:extension base="ItemType">
<xsd:sequence>
<xsd:element name="number" type="xsd:integer"/>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="description" type="xsd:string"

minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="effDate" type="xsd:date"/>
<xsd:attribute name="lang" type="xsd:language"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<!--Complex Content Restriction-->
<xsd:complexType name="RestrictedProductType">
<xsd:complexContent>
<xsd:restriction base="ProductType">
<xsd:sequence>
<xsd:element name="number" type="xsd:integer"/>
<xsd:element name="name" type="xsd:token"/>
</xsd:sequence>
<xsd:attribute name="routingNum" type="xsd:short" use="required"/>
<xsd:attribute name="effDate" type="xsd:date"

default="1900-01-01"/>
<xsd:attribute name="lang" use="prohibited"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>

<!--Complex Content Extension-->
<xsd:complexType name="ShirtType">
<xsd:complexContent>
<xsd:extension base="RestrictedProductType">
<xsd:choice maxOccurs="unbounded">
<xsd:element name="size" type="SmallSizeType"/>
<xsd:element name="color" type="ColorType"/>
</xsd:choice>
<xsd:attribute name="sleeve" type="xsd:integer"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<!--Simple Content Extension-->
<xsd:complexType name="SizeType">
<xsd:simpleContent>
<xsd:extension base="xsd:integer">
<xsd:attribute name="system" type="xsd:token"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>

<!--Simple Content Restriction-->
<xsd:complexType name="SmallSizeType">
<xsd:simpleContent>
<xsd:restriction base="SizeType">
<xsd:minInclusive value="2"/>
<xsd:maxInclusive value="6"/>
<xsd:attribute name="system" type="xsd:token"
use="required"/>
</xsd:restriction>
</xsd:simpleContent>
</xsd:complexType>

<xsd:complexType name="ColorType">
<xsd:attribute name="value" type="xsd:string"/>
</xsd:complexType>

</xsd:schema>


Nov 12 '05 #4

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,
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"...
4
by: Mike Jansen | last post by:
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...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...

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.