Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / July 2006

Tip: Looking for answers? Try searching our database.

XmlSchema Validation Error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Igor Koretsky - 13 Jul 2006 19:55 GMT
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.

Signature

Igor

Priya Lakshminarayanan - 14 Jul 2006 23:21 GMT
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

> Hi.
>
[quoted text clipped - 93 lines]
>
> Thank You.
Igor Koretsky - 17 Jul 2006 14:08 GMT
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.

Signature

Igor

> Schema B does not have a targetNamespace and including this in Schema A
> causes a chameleon include. (Include of a schema without a targetNamespace)
[quoted text clipped - 102 lines]
> >
> > Thank You.
Priya Lakshminarayanan - 18 Jul 2006 01:16 GMT
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

> Priya,
>
[quoted text clipped - 120 lines]
>> >
>> > Thank You.
Igor Koretsky - 18 Jul 2006 14:49 GMT
Thanks Priya,
You covered my question.
To bad they are not going to fix it for .NET 1.1
Signature

Igor

> This problem is fixed by the XmlSchemaSet class (Replacement for
> XmlSchemaCollection) in .Net 2.0. Can you move to .NET 2.0?
[quoted text clipped - 131 lines]
> >> >
> >> > Thank You.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.