[xsd-users] Using --file-per-type and importing

LINHARDT DOUGLAS-VJKP74 douglinhardt at motorolasolutions.com
Fri Apr 13 10:45:45 EDT 2012


Hi,

I want to be able to use XML Schema to define a set of messages to be sent around my system.  I defined a base Message type (in the BaseMessageSchema namespace) in BaseMessage.xsd, and a set of derived messages (in the DerivedMessageSchema namespace) in DerivedMessages.xsd, importing BaseMessage.xsd.

When I compile DerivedMessages.xsd without --file-per-type, I generate only DerivedMessages.*.  If I compile DerivedMessages.xsd with the --file-per-type, I get the DerivedMessages* and files for all of the types defined within DerivedMessages.xsd.  This I expected.  However, I also got BaseMessage.* and Message.* files.  This I did not expect.  I also tried putting the derived messages in the same namespace as the base Message type and including BaseMessage.xsd, but I got the same result.

I prefer to have files for each of the types-I think it's easier for a developers looking for a method name for a specific class.  However, the derived message types will be spread out all over the file system, and I don't want to re-generate the BaseMessage.*and Message.* files in every directory where derived files are generated.

Why is the behavior of file-per-type and file-per-schema different here?  I get what I am looking for with file-per-schema, but not with file-per-type.

File-per-schema is not a deal-breaker, but it would be nice to generate file-per-type, excluding imported and included types.

Thanks.

Doug Linhardt


More information about the xsd-users mailing list