471,049 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,049 software developers and data experts.

Does XSD <Import> work?

Hi

Environment: Visual Studio .NET 2003 (vb)

I am developing an XSD Schema and want to include some building blocks from
another source, so they have a different namespace.
- If I use an <Include> the Schema doesn't show any of the Elements from the
include Schema. But that's to be expected because they are in a different
namespace.
- If I use <Import> the Schema doesn't show any of the Elements from the
import Schema
- If I use both <Include> and <Import> I get the same result as just using
<Import>
- If both Schemas are in the same namespace it works fine with <Include>.
But that's not what I want to do.

The documentation for Import documentation:
"....import element allows references to schema components from schema
documents with different target namespaces"

So, I conclude that <Import> doesn't work. Or is there another answer?

Without Import I can't generate Datasets.
An example below.

The same problem appears to occur when trying to add Web References (or use
the WSDL.EXE tool). It does not appear to accept <Import> directives.
Thanks
Steve

File: SCHEMA_A.XSD:
<?xml version="1.0" encoding="utf-8" ?>
<xsd:schema id="MainSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
xmlns="urn:schema-a"
xmlns:mstns="urn:schema-a"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:schema-a">
<xsd:import namespace="urn:schema-b" schemaLocation="schema_b.xsd" />
<xsd:element name="Element1">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="Element2" />
<xsd:element ref="Element3" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>

File: SCHEMA_B.XSD
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema
targetNamespace="urn:schema-b"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="urn:schema-b"
elementFormDefault="qualified"
attributeFormDefault="unqualified" >
<xsd:element name="Element2">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Element21" type="Timestamp">
</xsd:element>
<xsd:element name="Element22" type="xsd:string">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Element3">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Element31" type="xsd:string">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Nov 12 '05 #1
1 4096
WSDL.exe doesnt allow for using the "include", it would give you a binding error. One way to get over this is to, have the schema inside the same xsd document.

Hope that helps.

Ash
Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by John Tiger | last post: by
1 post views Thread by Paul Scotchford | last post: by
reply views Thread by Markus Seibold | last post: by
1 post views Thread by seeCoolGuy | last post: by

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.