469,283 Members | 2,303 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,283 developers. It's quick & easy.

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 1843
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by mre | last post: by
8 posts views Thread by aevans1108 | last post: by
4 posts views Thread by Mike Jansen | last post: by
3 posts views Thread by Amol | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.