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

XmlSchema Validation Error

Hi.

Using VB.Net System.Xml 1.0
SchemaCollection Object

I am getting an error when trying to add
‘Schema A’ to the SchemaCollection.

Here are my schema files..

Schema A
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://www.twiststandards.org/3.0/ElectronicBilling"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.twiststandards.org/3.0/ElectronicBilling"
elementFormDefault="qualified"
attributeFormDefault="unqualified">

<xs:include schemaLocation="TestTwistMsg.xsd"/>

<xs:complexType name="ElectronicBillingMsg">
<xs:complexContent>
<xs:extension base="MessageHeader">
<xs:sequence>
<xs:element name="serviceAdjustment" type="ServiceAdjustment"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>

<xs:complexType name="ServiceAdjustment">
<xs:sequence>
<xs:element name="volumeChange" type="xs:decimal" minOccurs="0">
</xs:element>
<xs:element name="originalVolume" type="xs:decimal" minOccurs="0">
</xs:element>
<xs:element name="newVolume" type="xs:decimal" minOccurs="0">
</xs:element>
</xs:sequence>
</xs:complexType>

</xs:schema>

Schema B

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">

<xs:complexType name="MessageHeader">
<xs:annotation>
<xs:documentation xml:lang="en">A type defining the content model for a
generic message header that is refined by its derived
classes.</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="messageType" type="xs:string" minOccurs="0">
</xs:element>
<xs:element name="creationTimestamp" type="xs:dateTime">
</xs:element>
</xs:sequence>
</xs:complexType>

<xs:complexType name="NotificationMessageHeader">
<xs:annotation>
<xs:documentation xml:lang="en">A type that refines the generic message
header to match the requirements of a NotificationMessage.</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:restriction base="MessageHeader">
<xs:sequence>
<xs:element name="messageType" type="xs:string" minOccurs="0">
</xs:element>
<xs:element name="creationTimestamp" type="xs:dateTime">
</xs:element>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>

</xs:schema>
Schema A ‘Includes’ Schema B.

The error is..
Undefined complexType 'MessageHeader' is used as a base for complex type
restriction

I can validate this schema in Stylus that is using Xerces Validation Parcer.
What can I do to skip/fix this error?

Thank You.
--
Igor
Jul 13 '06 #1
4 1628
Schema B does not have a targetNamespace and including this in Schema A
causes a chameleon include. (Include of a schema without a targetNamespace)
XmlSchemaCollection does not support chameleon includes. If you provide a
targetNamespace for schema B and make it to be the default namespace in
schema B, it should fix the error.

Thanks,
Priya

"Igor Koretsky" <Ig**********@discussions.microsoft.comwrote in message
news:94**********************************@microsof t.com...
Hi.

Using VB.Net System.Xml 1.0
SchemaCollection Object

I am getting an error when trying to add
'Schema A' to the SchemaCollection.

Here are my schema files..

Schema A
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://www.twiststandards.org/3.0/ElectronicBilling"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.twiststandards.org/3.0/ElectronicBilling"
elementFormDefault="qualified"
attributeFormDefault="unqualified">

<xs:include schemaLocation="TestTwistMsg.xsd"/>

<xs:complexType name="ElectronicBillingMsg">
<xs:complexContent>
<xs:extension base="MessageHeader">
<xs:sequence>
<xs:element name="serviceAdjustment" type="ServiceAdjustment"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>

<xs:complexType name="ServiceAdjustment">
<xs:sequence>
<xs:element name="volumeChange" type="xs:decimal" minOccurs="0">
</xs:element>
<xs:element name="originalVolume" type="xs:decimal" minOccurs="0">
</xs:element>
<xs:element name="newVolume" type="xs:decimal" minOccurs="0">
</xs:element>
</xs:sequence>
</xs:complexType>

</xs:schema>

Schema B

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">

<xs:complexType name="MessageHeader">
<xs:annotation>
<xs:documentation xml:lang="en">A type defining the content model for a
generic message header that is refined by its derived
classes.</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="messageType" type="xs:string" minOccurs="0">
</xs:element>
<xs:element name="creationTimestamp" type="xs:dateTime">
</xs:element>
</xs:sequence>
</xs:complexType>

<xs:complexType name="NotificationMessageHeader">
<xs:annotation>
<xs:documentation xml:lang="en">A type that refines the generic message
header to match the requirements of a
NotificationMessage.</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:restriction base="MessageHeader">
<xs:sequence>
<xs:element name="messageType" type="xs:string" minOccurs="0">
</xs:element>
<xs:element name="creationTimestamp" type="xs:dateTime">
</xs:element>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>

</xs:schema>
Schema A 'Includes' Schema B.

The error is..
Undefined complexType 'MessageHeader' is used as a base for complex type
restriction

I can validate this schema in Stylus that is using Xerces Validation
Parcer.
What can I do to skip/fix this error?

Thank You.
--
Igor

Jul 14 '06 #2
Priya,

Thank you for your response.
Now I see where the problem is.

Unfortunately I can’t change the schema that supplied by another company.
I am developing software (Win Forms VB.NET) that receives and processes XML
documents.
The very first step I have to do is validate incoming files against schema
and show errors if XML file did not pass the validation.
Can you suggest what approach/tool I should be using to make it work?

Thank You.

--
Igor
"Priya Lakshminarayanan" wrote:
Schema B does not have a targetNamespace and including this in Schema A
causes a chameleon include. (Include of a schema without a targetNamespace)
XmlSchemaCollection does not support chameleon includes. If you provide a
targetNamespace for schema B and make it to be the default namespace in
schema B, it should fix the error.

Thanks,
Priya

"Igor Koretsky" <Ig**********@discussions.microsoft.comwrote in message
news:94**********************************@microsof t.com...
Hi.

Using VB.Net System.Xml 1.0
SchemaCollection Object

I am getting an error when trying to add
'Schema A' to the SchemaCollection.

Here are my schema files..

Schema A
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://www.twiststandards.org/3.0/ElectronicBilling"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.twiststandards.org/3.0/ElectronicBilling"
elementFormDefault="qualified"
attributeFormDefault="unqualified">

<xs:include schemaLocation="TestTwistMsg.xsd"/>

<xs:complexType name="ElectronicBillingMsg">
<xs:complexContent>
<xs:extension base="MessageHeader">
<xs:sequence>
<xs:element name="serviceAdjustment" type="ServiceAdjustment"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>

<xs:complexType name="ServiceAdjustment">
<xs:sequence>
<xs:element name="volumeChange" type="xs:decimal" minOccurs="0">
</xs:element>
<xs:element name="originalVolume" type="xs:decimal" minOccurs="0">
</xs:element>
<xs:element name="newVolume" type="xs:decimal" minOccurs="0">
</xs:element>
</xs:sequence>
</xs:complexType>

</xs:schema>

Schema B

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">

<xs:complexType name="MessageHeader">
<xs:annotation>
<xs:documentation xml:lang="en">A type defining the content model for a
generic message header that is refined by its derived
classes.</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="messageType" type="xs:string" minOccurs="0">
</xs:element>
<xs:element name="creationTimestamp" type="xs:dateTime">
</xs:element>
</xs:sequence>
</xs:complexType>

<xs:complexType name="NotificationMessageHeader">
<xs:annotation>
<xs:documentation xml:lang="en">A type that refines the generic message
header to match the requirements of a
NotificationMessage.</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:restriction base="MessageHeader">
<xs:sequence>
<xs:element name="messageType" type="xs:string" minOccurs="0">
</xs:element>
<xs:element name="creationTimestamp" type="xs:dateTime">
</xs:element>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>

</xs:schema>
Schema A 'Includes' Schema B.

The error is..
Undefined complexType 'MessageHeader' is used as a base for complex type
restriction

I can validate this schema in Stylus that is using Xerces Validation
Parcer.
What can I do to skip/fix this error?

Thank You.
--
Igor


Jul 17 '06 #3
This problem is fixed by the XmlSchemaSet class (Replacement for
XmlSchemaCollection) in .Net 2.0. Can you move to .NET 2.0?

Otherwise, the only workaround is for you to clone the included schema
yourself and set all qualified names to the right targetNamespace.
ie. all properties on the SOM of type XmlQualifiedName like BaseTypeName,
RefName, SchemaTypeName, ItemTypeName etc

Thanks,
Priya

"Igor Koretsky" <Ig**********@discussions.microsoft.comwrote in message
news:93**********************************@microsof t.com...
Priya,

Thank you for your response.
Now I see where the problem is.

Unfortunately I can't change the schema that supplied by another company.
I am developing software (Win Forms VB.NET) that receives and processes
XML
documents.
The very first step I have to do is validate incoming files against schema
and show errors if XML file did not pass the validation.
Can you suggest what approach/tool I should be using to make it work?

Thank You.

--
Igor
"Priya Lakshminarayanan" wrote:
>Schema B does not have a targetNamespace and including this in Schema A
causes a chameleon include. (Include of a schema without a
targetNamespace)
XmlSchemaCollection does not support chameleon includes. If you provide a
targetNamespace for schema B and make it to be the default namespace in
schema B, it should fix the error.

Thanks,
Priya

"Igor Koretsky" <Ig**********@discussions.microsoft.comwrote in message
news:94**********************************@microso ft.com...
Hi.

Using VB.Net System.Xml 1.0
SchemaCollection Object

I am getting an error when trying to add
'Schema A' to the SchemaCollection.

Here are my schema files..

Schema A
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://www.twiststandards.org/3.0/ElectronicBilling"
xmlns:xs="http://www.w3.org/2001/XMLSchema"

targetNamespace="http://www.twiststandards.org/3.0/ElectronicBilling"
elementFormDefault="qualified"
attributeFormDefault="unqualified">

<xs:include schemaLocation="TestTwistMsg.xsd"/>

<xs:complexType name="ElectronicBillingMsg">
<xs:complexContent>
<xs:extension base="MessageHeader">
<xs:sequence>
<xs:element name="serviceAdjustment" type="ServiceAdjustment"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>

<xs:complexType name="ServiceAdjustment">
<xs:sequence>
<xs:element name="volumeChange" type="xs:decimal" minOccurs="0">
</xs:element>
<xs:element name="originalVolume" type="xs:decimal" minOccurs="0">
</xs:element>
<xs:element name="newVolume" type="xs:decimal" minOccurs="0">
</xs:element>
</xs:sequence>
</xs:complexType>

</xs:schema>

Schema B

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">

<xs:complexType name="MessageHeader">
<xs:annotation>
<xs:documentation xml:lang="en">A type defining the content model for a
generic message header that is refined by its derived
classes.</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="messageType" type="xs:string" minOccurs="0">
</xs:element>
<xs:element name="creationTimestamp" type="xs:dateTime">
</xs:element>
</xs:sequence>
</xs:complexType>

<xs:complexType name="NotificationMessageHeader">
<xs:annotation>
<xs:documentation xml:lang="en">A type that refines the generic message
header to match the requirements of a
NotificationMessage.</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:restriction base="MessageHeader">
<xs:sequence>
<xs:element name="messageType" type="xs:string" minOccurs="0">
</xs:element>
<xs:element name="creationTimestamp" type="xs:dateTime">
</xs:element>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>

</xs:schema>
Schema A 'Includes' Schema B.

The error is..
Undefined complexType 'MessageHeader' is used as a base for complex
type
restriction

I can validate this schema in Stylus that is using Xerces Validation
Parcer.
What can I do to skip/fix this error?

Thank You.
--
Igor



Jul 18 '06 #4
Thanks Priya,
You covered my question.
To bad they are not going to fix it for .NET 1.1
--
Igor
"Priya Lakshminarayanan" wrote:
This problem is fixed by the XmlSchemaSet class (Replacement for
XmlSchemaCollection) in .Net 2.0. Can you move to .NET 2.0?

Otherwise, the only workaround is for you to clone the included schema
yourself and set all qualified names to the right targetNamespace.
ie. all properties on the SOM of type XmlQualifiedName like BaseTypeName,
RefName, SchemaTypeName, ItemTypeName etc

Thanks,
Priya

"Igor Koretsky" <Ig**********@discussions.microsoft.comwrote in message
news:93**********************************@microsof t.com...
Priya,

Thank you for your response.
Now I see where the problem is.

Unfortunately I can't change the schema that supplied by another company.
I am developing software (Win Forms VB.NET) that receives and processes
XML
documents.
The very first step I have to do is validate incoming files against schema
and show errors if XML file did not pass the validation.
Can you suggest what approach/tool I should be using to make it work?

Thank You.

--
Igor
"Priya Lakshminarayanan" wrote:
Schema B does not have a targetNamespace and including this in Schema A
causes a chameleon include. (Include of a schema without a
targetNamespace)
XmlSchemaCollection does not support chameleon includes. If you provide a
targetNamespace for schema B and make it to be the default namespace in
schema B, it should fix the error.

Thanks,
Priya

"Igor Koretsky" <Ig**********@discussions.microsoft.comwrote in message
news:94**********************************@microsof t.com...
Hi.

Using VB.Net System.Xml 1.0
SchemaCollection Object

I am getting an error when trying to add
'Schema A' to the SchemaCollection.

Here are my schema files..

Schema A
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://www.twiststandards.org/3.0/ElectronicBilling"
xmlns:xs="http://www.w3.org/2001/XMLSchema"

targetNamespace="http://www.twiststandards.org/3.0/ElectronicBilling"
elementFormDefault="qualified"
attributeFormDefault="unqualified">

<xs:include schemaLocation="TestTwistMsg.xsd"/>

<xs:complexType name="ElectronicBillingMsg">
<xs:complexContent>
<xs:extension base="MessageHeader">
<xs:sequence>
<xs:element name="serviceAdjustment" type="ServiceAdjustment"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>

<xs:complexType name="ServiceAdjustment">
<xs:sequence>
<xs:element name="volumeChange" type="xs:decimal" minOccurs="0">
</xs:element>
<xs:element name="originalVolume" type="xs:decimal" minOccurs="0">
</xs:element>
<xs:element name="newVolume" type="xs:decimal" minOccurs="0">
</xs:element>
</xs:sequence>
</xs:complexType>

</xs:schema>

Schema B

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">

<xs:complexType name="MessageHeader">
<xs:annotation>
<xs:documentation xml:lang="en">A type defining the content model for a
generic message header that is refined by its derived
classes.</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="messageType" type="xs:string" minOccurs="0">
</xs:element>
<xs:element name="creationTimestamp" type="xs:dateTime">
</xs:element>
</xs:sequence>
</xs:complexType>

<xs:complexType name="NotificationMessageHeader">
<xs:annotation>
<xs:documentation xml:lang="en">A type that refines the generic message
header to match the requirements of a
NotificationMessage.</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:restriction base="MessageHeader">
<xs:sequence>
<xs:element name="messageType" type="xs:string" minOccurs="0">
</xs:element>
<xs:element name="creationTimestamp" type="xs:dateTime">
</xs:element>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>

</xs:schema>
Schema A 'Includes' Schema B.

The error is..
Undefined complexType 'MessageHeader' is used as a base for complex
type
restriction

I can validate this schema in Stylus that is using Xerces Validation
Parcer.
What can I do to skip/fix this error?

Thank You.
--
Igor


Jul 18 '06 #5

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

Similar topics

0
by: BODIN | last post by:
I have an XML document, which is actually physically stored in 2 separated files. doc1.xml and doc2.xml I NEED a WAY FOR THIS SIMPLE NEED : XML file splitted into two physical files, and use...
4
by: Robert Ludewig | last post by:
This is my XML Schema (Sitemap.xsd) : <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.htw-dresden.de/SitemapNS">...
2
by: AlexS | last post by:
Hello, I have error when reading schema using XmlSchema. Read and then .Compile: System.Xml.Schema.XmlSchemaException: May not be nominated as the {substitution group affiliation} of any...
2
by: Chris | last post by:
I'd like to be able to access the elements in an XSD/XmlSchema object to determine things like the datatype. Can this be done without explicitly running validation on a document? Can I...
1
by: Rumen Traykov via .NET 247 | last post by:
Have somebody had already the problem of having to write more than one XmlSchema, where some of these schemas have imports to others and respectively derived types? The imports cannot be resolved...
1
by: Maansi Sanghi | last post by:
Hello, I am trying to write an xsd file using .NET System.Xml.Sxhema Class Library. (1) I get an error while writitng if the XSD has a taregetnamespace. (II) for any xsd with no...
3
by: JMD | last post by:
A set of xsd files has been working fine for us at this site, but now it gives *intermittent* errors for someone at a different cite (who is consuming the code we are producing). Most of the time...
1
by: madhuxml82 | last post by:
Dear Forum Members, I am Trying to Generate an XML File, Change the XML File, Validating the XML File with a DTD or XMLSCHEMA and Then Upload the XML File into Different set of Tables. I got...
1
by: Ryan | last post by:
Hello Xml Gurus, I'm trying to build an XML schema in memory using the System.Xml.XmlSchema namespace objects, validate it, and then write it to a file. The problem I'm facing is that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...

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.