Order of schema files may cause an exception

Jun 16, 2011 at 3:28 PM
Edited Jun 16, 2011 at 3:31 PM

Immo,

You've taken on a difficult problem and produced a very useful tool to address it.  Thanks!

I have encountered a bug that you may want to address.  The order of entries in the <schemaFiles> collection in .shfbproj may cause the tool to fail.

If the collection contains:

<schemaFiles>
  <schemaFile path="Schemas\*.xsd" />
</schemaFiles>

SHFB raises the error:

SHFB: Error BE0029: Unexpected error while executing plug-in 'XML Schema Documenter':
  XsdDocumentation.XsdDocumentationException: 
    There was an error constructing the schema set. ---> System.Xml.Schema.XmlSchemaException:
    The complexType '/CommonTypes:CompanyType' has already been declared.

But if the collection contains:

<schemaFiles>
    <schemaFile path="Schemas\Reference.xsd" />
    <schemaFile path="Schemas\Container.xsd" />
    <schemaFile path="Schemas\CommonTypes.xsd" />
    <schemaFile path="Schemas\Arrival_BL_Canonical_Xml.xsd" />
</schemaFiles> 

the process runs to completion.  The Arrival_BL_Canonical_Xml.xsd schema imports the other three schemas.  But it seems to me that the order of entry in the schemaFiles collection should not cause an exception.
Regards,
Dave
Coordinator
May 26, 2012 at 8:05 PM

Interesting. Funny enough, I don't do any magic constructing the XML schema set. I just relay on XmlSchemaSet to do the right thing. I tried to reproduce the issue locally but couldn't construct a schema set that has this issue.

Can you share the schema files?

May 29, 2012 at 4:36 PM

I avoided the problem by re-structuring the schemas to use “import” statements, rather than filename wildcards. Since this was a long time ago, I no longer have the original schemas without the “import” statements.

Dave

From: terrajobst [email removed]
Sent: Saturday, May 26, 2012 3:06 PM
To: David P. Romig, Sr.
Subject: Re: Order of schema files may cause an exception [xsddoc:261646]

From: terrajobst

Interesting. Funny enough, I don't do any magic constructing the XML schema set. I just relay on XmlSchemaSet to do the right thing. I tried to reproduce the issue locally but couldn't construct a schema set that has this issue.

Can you share the schema files?

Coordinator
Jun 1, 2012 at 3:11 AM

Ah, that makes sense. AFAIK the order of xs:import elements matters.

Marked as answer by terrajobst on 2/15/2014 at 6:12 PM