Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

include xsd not working

Status
Not open for further replies.

ccampbell

Programmer
Aug 16, 2001
201
US
I have an XSD file that includes another XSD file in a C# program. Here is the first XSD file

<?xml version=&quot;1.0&quot;?>
<schema xmlns=&quot;targetNamespace=&quot;xmlns:ts=&quot;elementFormDefault=&quot;qualified&quot;>

<!-- IRP Account Input Transaction, T0020, version 1 -->

<include schemaLocation=&quot;globalTypes.xsd&quot;/>
....

Here is the globalTypes.xsd file

<?xml version=&quot;1.0&quot;?>
<schema xmlns=&quot;version=&quot;1.0&quot; elementFormDefault=&quot;qualified&quot; xml:lang=&quot;EN&quot;>

<simpleType name=&quot;globalAddressTypeValues&quot;>
<restriction base=&quot;string&quot;>
<enumeration value=&quot;MA&quot;/>
<enumeration value=&quot;PH&quot;/>
</restriction>
</simpleType>

<simpleType name=&quot;globalNameTypeValues&quot;>
<restriction base=&quot;string&quot;>
<enumeration value=&quot;LG&quot;/>
<enumeration value=&quot;DB&quot;/>
</restriction>
</simpleType>
...(etc.)

Here is my error when I try to load the schema

Microsoft.Data.SqlXml.SqlXmlException: Schema: unable to load schema 'T0020V1.xsd'.

An error occurred (globaltypes.xsd#/schema[1]/simpleType[position() = 6 and @name = globalAddressTypeValues]/restriction[1]
Undeclared XSD type : '{ --->
System.Runtime.InteropServices.COMException (0x80004005):
Schema: unable to load schema 'T0020V1.xsd'.

An error occurred (globaltypes.xsd#/schema[1]/simpleType[position() = 6 and @name = globalAddressTypeValues]/restriction[1]
Undeclared XSD type : '{at Microsoft.Data.SqlXml.Common.ISQLXMLCommandManagedInterface.ExecuteToOutputStream()
at Microsoft.Data.SqlXml.SqlXmlCommand.innerExecute(Stream strm)
--- End of inner exception stack trace ---
at Microsoft.Data.SqlXml.SqlXmlCommand.ExecuteStream()

Any help on this would be greatly appreciated
 
This would probably be better answered in the XML forum, but here goes anyway.

When including an XSD inside another one, do something like this:

Code:
<xs:schema xmlns:xs=&quot;[URL unfurl="true"]http://www.w3.org/2001/XMLSchema&quot;[/URL] elementFormDefault=&quot;qualified&quot; attributeFormDefault=&quot;unqualified&quot;>
	<xs:include schemaLocation=&quot;.\OtherXSD.xsd&quot;/>
	<xs:element name=&quot;ThisRoot&quot;>
		<xs:complexType>
			<xs:sequence>
				<xs:element ref=&quot;OtherXSDRoot&quot;/>
				<xs:element name=&quot;Element1&quot;/>
				<xs:element name=&quot;Element2&quot;/>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
</xs:schema>
By including the root of the other XSD as a ref, you can control where it appears in your document. It also helps to have both documents using the same namespace, but I realize that doesn't always happen.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top