all groups > dotnet xml > april 2005 >
You're in the

dotnet xml

group:

Can xsd.exe generate .cs files from schemas, if importing another schema with the same namespace is involved?


Can xsd.exe generate .cs files from schemas, if importing another schema with the same namespace is involved? rehveli
4/28/2005 12:00:00 AM
dotnet xml:
Isn't it possible to generate .cs files from schemas, where one
schema imports another, and both have the same namespace?

If a.xsd and b.xsd have namespace "MyNameSpace", and in b.xsd I
do <xsd:import namespace="MyNameSpace" schemaLocation="a.xsd"/>
and run "xsd.exe /c a.xsd b.xsd", xsd.exe errors out with

"Error: A schema with the namespace 'MyNameSpace' has already
been added."

If xsd.exe can't do this, is there a freeware alternative that
would actually work?

Re: Can xsd.exe generate .cs files from schemas, if importing another schema with the same namespace is involved? Chris Lovett
4/28/2005 9:29:06 PM
<xsd:imports> can only import schemas that have a different targetNamespace
from the parent schema. You may want to use <xsd:include> instead, which
can add stuff to the parent schema's namespace.

[quoted text, click to view]

Re: Can xsd.exe generate .cs files from schemas, if importing another schema with the same namespace is involved? rehveli
5/1/2005 12:00:00 AM
[quoted text, click to view]

Thanks, this clears things up a bit. Ok, next problem I run into:

a.xsd has namespace "A", and it imports schemas b1.xsd and b2.xsd.
Both b1 and b2 have namespace "B". Also, b2 includes b1. How should
this situation be handled?

Re: Can xsd.exe generate .cs files from schemas, if importing another schema with the same namespace is involved? Chris Lovett
5/2/2005 10:36:46 PM
Sounds like b1 is being both included (in b2) and imported (into a). This
will probably result in duplicate types and is not something that is
normally supported. A schema is usually either an import or an include, but
not both. You may have to factor B2 into two pieces, B2a and B2b (which is
the part that imports B1) then import only B2a into A.


[quoted text, click to view]

AddThis Social Bookmark Button