Creating Data Type From XSD - does not work with Imported Schemas

May 2, 2007 at 1:24 PM
Hello all,

I am trying to create datatype from an XSD Schema. I was doing in incrementally and everything was working fine until I modified my Original XSD to import one more XSD. The second XSD has different namespace and I need to do it this way for maintenance reasons.

But I am getting an error:

Error: 0 : The 'http://RI.DataTypes/2007/05/ProdCat/Prod:Order' element is not declared.

Please help.

Also, I am creating one larger XSD which refers such many smaller XSDs with different namespaces.




May 3, 2007 at 10:58 AM
Hello all,

Can anyone please help me out on this? Any pointers for this topic would be helpful.
May 3, 2007 at 2:18 PM
It seems that you have an issue with your namespaces since the element Order is not being located. Just to discard any issue associated with the recipe, try running XSD.exe and verify that you can sucessfully import your schemas and generated the types.
If you did not get any error with that tool, then you can send me your xsd files and I will try to debug that recipe. If for whatever reason you can't send me the schemas, thent I will give you the steps to debug the recipe yourself.

Thanks,
Charly
May 4, 2007 at 2:10 PM
charly,

A friend in need is a friend indeed. Thanks for help.

I tried running XSD.exe and I could create datasets out of them; but not class. When I try to create a class it gives me the same error as above. My search took me to kb article: http://support.microsoft.com/kb/317611. I tried that too, but for no use.

I have posted you my schemas, please go through and let me know if I am doing anything wrong.
May 4, 2007 at 2:37 PM
Hi,

Let me know how can I send you files,

Thanks,
Sanket.
May 4, 2007 at 4:05 PM
Just send me an email and I'll replay back to your address so you can then send me the attached file. As a side not, consider that the recipe (and the XSD tool as well) will not import schemas that contain datasets, so perhaps that might be the root of this issue.

Thanks,
Charly
May 5, 2007 at 7:10 PM
Hi charly,

I suspect this could be a bug with recipe.

I could create classes as well as datatypes out of the schemas I built, as per an article on msdn (http://msdn2.microsoft.com/en-us/library/ms950721.aspx) which is as below:

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Q: Why doesn't XSD.exe support the schemaLocation attribute on imports and includes?

A: The W3C XML Schema recommendation describes this attribute as a hint, which can be ignored by processors that can use alternate means to locate schemas. XSD.exe only uses schemas that are specified through the command line to convert schema A.xsd, which imports schema B.xsd.

Copy Code
xsd.exe /c A.xsd B.xsd

Also, the wsdl.exe application, considered a sister application to xsd.exe, can be downloaded from the Web. If you do this and use the wsdl.exe, you would follow schemaLocation hints in imports and includes.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Now, how do I tell recipe to use the method above and not it's usual method?

Is there any way I can still use service factory without compromising on my initial decision of having each order in a separate XSD and namespace? I like all other stuff but not this one.

Going forward, even if I somehow resolve this error, I doubt if I can define Service Interfaces due to a bug as in the article below:

http://support.microsoft.com/default.aspx?scid=kb;en-us;317340 BUG: A Typed DataSet That Imports a Secondary Schema Cannot be Used As a Method Parameter or As a Return Type with ASP.NET Web Services

Regards,
Sanket.
May 8, 2007 at 7:57 AM
Hi charly,

Just to confirm, you got my schemas right?

If you can post steps to debug the recipe here, I'll also try at my end.
May 9, 2007 at 3:36 AM
I got your scehmas and I'm still investigating.
I'll post my findings here soon.

Thanks,
Charly
May 11, 2007 at 3:05 PM
Sanket,

The "schemaLocation" attribute value is case sensitive in WSSF v2 and therefore if the value differs from the file name, then it will not be inlucded and no code will be generated. In your case, there is a mismatch between the value of the attribute (lower case) and the file name (pascal case). Try change the values accordingly and you should be fine. Other than that, verify that the relative path is correct. If you put the include files at the same location of the main file, just add the name without and "\", like;
  <xs:import schemaLocation="Schema2.xsd" namespace="http://Schema.Schema2" />
  <xs:import schemaLocation="Schema3.xsd" namespace="http://Schema.Schema3" />

Charly