This is Interesting: Free Magazines for Graphics designers and webmasters
Home > Archive > Microsoft XML > April 2007 > xsd.exe fails to generate 'fixed' attribute
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
xsd.exe fails to generate 'fixed' attribute
|
|
| Doug V 2007-04-23, 6:16 pm |
| When I use xsd.exe to generate a schema from a class, it does not generate
'fixed' attributes for initialized fields. For example, see
http://msdn2.microsoft.com/en-us/library/ehbh3cs2(vs.80).aspx. When I
generate a schema from the FamilyDogType class, the 'name' element does not
have the [fixed="Spot"] attribute shown in the example. I'm using .NET 2.0,
XSD.EXE Version 2.0.50727.42.
Is this a bug in xsd.exe or am I doing something wrong?
| |
| WenYuan Wang [MSFT] 2007-04-24, 6:18 pm |
| Hi Doug V,
Thanks for your posting.
I have reproduced this issue on my side.
I will contact development team on this issue and will reply here as soon
as possible.
If you have any more concerns on it, please feel free to post here.
Have a great day,
Best regards,
Wen Yuan
Microsoft Online Community Support
| |
| WenYuan Wang [MSFT] 2007-04-25, 3:16 am |
| Hi Doug V
Thanks for your waiting. I got some response from development team.
xsd.exe supports the fixed construct and imports it into the generated code
as the value that the member gets initialized to. However, xsd.exe does not
make the guarantee that all XSD constructs are round-tripped
(schema->class->schema). Fixed is a construct that is supported when a user
generates schema and serializes/deserializes, but it is lost if the class
is used to then generate schema.
Hope this helps. If you still have anything unclear, please feel free to
let me know.
Have a great day,
Sincerely,
Wen Yuan
Microsoft Online Community Support
| |
| Doug V 2007-04-25, 6:17 pm |
| The documentation cited in my initial post clearly disagrees with your
statement. It shows an "...XML Schema document generated from an assembly
compiled from the preceding C# source". The 'name' field is initialized in
the C# source and the 'fixed' attribute is generated in the schema. This is
not a round-trip example, although the entire page implies that the 'fixed'
attribute will round-trip successfully. In fact, I thought that was the
intent of this page.
Either the documentation or your development team is wrong. I suspect the
team is trying to cover up a defect in xsd.exe. I would prefer a fix to the
application rather than a documentation change. Should I open a support
incident to resolve this?
| |
| John Saunders [MVP] 2007-04-25, 6:17 pm |
| "Doug V" <Doug V@community.nospam> wrote in message
news:uKw5$TzhHHA.4064@TK2MSFTNGP02.phx.gbl...
> The documentation cited in my initial post clearly disagrees with your
> statement. It shows an "...XML Schema document generated from an assembly
> compiled from the preceding C# source". The 'name' field is initialized
> in the C# source and the 'fixed' attribute is generated in the schema.
> This is not a round-trip example, although the entire page implies that
> the 'fixed' attribute will round-trip successfully. In fact, I thought
> that was the intent of this page.
>
> Either the documentation or your development team is wrong. I suspect the
> team is trying to cover up a defect in xsd.exe. I would prefer a fix to
> the application rather than a documentation change. Should I open a
> support incident to resolve this?
Why should "fixed" be generated just because a field has an initial value?
Doesn't "fixed" mean that the value cannot change?
--
John Saunders [MVP]
| |
| WenYuan Wang [MSFT] 2007-04-26, 6:18 pm |
| Hi Doug V,
Thanks for your reply.
According to the product team's reply, "fixed" attribute will lost when the
class is used to generate schema. However, as you said, it is different
from the document mentioned. I'll continue to contact product team on it
and clarify it for me. If you have any more concerns on it, please feel
free to post here.
Have a great day,
Sincerely,
Wen Yuan
Microsoft Online Community Support
| |
| Doug V 2007-04-26, 6:18 pm |
| Actually, as John pointed out, it does seem odd that the documentation
claims an initial value should generate a 'fixed' attribute. It seems more
logical to have a C# 'readonly' field generate a the 'fixed' attribute.
What I would like is to generate a 'fixed' attribute in the schema from a C#
class. Is there any other way to do this?
| |
| WenYuan Wang [MSFT] 2007-04-27, 3:19 am |
| Hi Doug V,
Actually, for "Default" Attribute, xsd.exe really achieved it in this way,
[System.ComponentModel.DefaultValueAttribute()] attribute generate a
"default" attribute.
[System.ComponentModel.DefaultValueAttribute(-1)]
Public int age = -1;
However, for "Fix" Attribute, xsd.exe seems like only support generate
class from schema, otherwise, the "Fix "attribute will be lost. Sorry, I'm
afraid the document is wrong.
http://msdn2.microsoft.com/en-us/library/ehbh3cs2(VS.80).aspx
I still haven't found a good way to generate 'fixed' attribute in the
schema from a
Class. No document mentioned this issue. If you really want to achieve
this, I would like to suggest you may contact CSS directly. I think they
should give you some workaround. I also appreciate if you can post back
some solution if CSS have resolved it for you. Many thanks.
Sincerely,
Wen Yuan
Microsoft Online Community Support
| |
| Doug V 2007-04-27, 6:17 pm |
| Hi Wen Yuan,
Unfortunately, DefaultValueAttribute does not work for me because
XmlSerializer does not include the node if the value is equal to the default
value. I need to always have the node included. I will write some custom
code to do what I need.
Please make sure the documentation is corrected.
Thanks for your help.
Doug
| |
| WenYuan Wang [MSFT] 2007-04-30, 6:15 am |
| Hi Doug V,
Thanks for your reply.
I have submitted a feedback to product feedback center
https://connect.microsoft.com/Visua...ack.aspx?Feedba
ckID=274773. You may rat or monitor on it. Anyway, if I can get any
information from there, I will also pass it for you.
Thanks again for your understanding,
Best regards,
Wen Yuan
Microsoft Online Community Support
| |
| WenYuan Wang [MSFT] 2007-04-30, 6:15 am |
| Hi Doug V,
Thanks for your reply.
I have submitted a feedback to product feedback center.
https://connect.microsoft.com/Visua...ack.aspx?Feedba
ckID=274773
You may rate or monitor on it. Anyway, if I can get any information from
there, I will also pass it for you.
Thanks again for your understanding,
Best regards,
Wen Yuan
Microsoft Online Community Support
|
|
|
| | Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |
|