Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6802505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:13:53+00:00 2026-05-26T19:13:53+00:00

Inside an xs:complexType, there are elements: Running .NET tools like SvcUtil.exe, you will get

  • 0

Inside an xs:complexType, there are elements:

Running .NET tools like SvcUtil.exe, you will get a class decorated with DataContractAttribute containing properties:
public string RegistrationNumber {get;set;}
public DateTime ExpiryDate {get;set;}
public DateTime? RegistrationEndDate {get;set;}

What puzzle me is:
if the XML instance received does not contact these 3 elements, apparently default values will be used though default values are not explicitly defined in XSD. What default values for string and Datetime?

To refresh my deem memory, I have a look at

http://www.w3.org/TR/xmlschema-0/

2.2.1

In summary, the differences between element and attribute defaults can be stated as: Default attribute values apply when attributes are missing, and default element values apply when elements are empty.

So what if the default value is no explicitly defined and an element is empty/absent?

The standard does not seem to define for such scenario, but apparently this will be at the mercy of the implementation of the receiver.

For data type like integer and boolean, the default values are obvious: 0 and false. Well defined since day 1 of electronic computing.

But for string and datetime, the situation is a bit tricky, largely because different languages have different structures and conventions for string and datetime.

Do you think my understanding is correct?

In MSDN about DataMemberAttribute.EmitDefaultValue, there is a statement:

“Setting the EmitDefaultValue property to false is not a recommended practice. It should only be done if there is a specific need to do so (such as for interoperability or to reduce data size). “

Can you tell me why this is not a recommended practice? say, sound like MS recommend emitting every elements regardless if minOccurs=0 in XML message?

Thanks

Andy

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:13:54+00:00Added an answer on May 26, 2026 at 7:13 pm

    if an element is absent from the XML document then there shouldn’t be any object representing it in memory. Think of any element where the schema has a minOccurs or a maxOccurs as by definition a list. If its minOccurs=0, maxOccurs=1 then we think of it as optional but actually its a list with at most one element. So the data structure representing it should be a list (or array with variable bounds or …). Then the question of its value makes no sense and there is no ambiguity in the spec.

    If SvcUtil.exe doesn’t do that, I don’t think its right.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Inside class, I would like to define some const strings.however the compiler reports error
Inside a repeater's ItemTemplate there is a: <tr class=class1> </tr> I want this class
Inside my function there is an if() statement like this: if(passedValue < staticValue) But
Inside a windows batch file I'd like to figure out what the fully qualified
Inside the titleView of a UINavigationBar, there is a button. Clicking it should slide
Is there any reason why <xs:group> cannot appear inside <xs:all> , but only inside
Inside a batch file on Windows I would like some variable to have the
I have problem with XML schema. I need inside one element elements of three
Inside a templated class, I found the expression, *this = NULL What does such
Learning XML Schema, I want to be able to have collections of elements inside

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.