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

  • Home
  • SEARCH
  • 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 183117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:03:33+00:00 2026-05-11T15:03:33+00:00

I have seen null elements represented in several ways: The element is present with

  • 0

I have seen null elements represented in several ways:

The element is present with xsi:nil='true':

 <book>      <title>Beowulf</title>      <author xsi:nil='true'/>  </book> 

The element is present, but represented as an empty element (which I believe is wrong since ’empty’ and null are semantically different):

 <book>      <title>Beowulf</title>      <author/>  </book>   <!-- or: -->  <book>      <title>Beowulf</title>      <author></author>  </book> 

The element is not present at all in the returned markup:

 <book>      <title>Beowulf</title>  </book> 

The element has a <null/> child element (from TStamper below):

 <book>      <title>Beowulf</title>      <author><null/></author>  </book> 

Is there a correct, or canonical way to represent such a null value? Are there additional ways than the above examples?

The XML for the examples above is contrived, so don’t read too far into it. 🙂

  • 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. 2026-05-11T15:03:34+00:00Added an answer on May 11, 2026 at 3:03 pm

    xsi:nil is the correct way to represent a value such that: When the DOM Level 2 call getElementValue() is issued, the NULL value is returned. xsi:nil is also used to indicate a valid element with no content even if that elements content type normally doesn’t allow empty elements.

    If an empty tag is used, getElementValue() returns the empty string (”) If the tag is omitted, then no author tag is even present. This may be semantically different than setting it to ‘nil’ (Ex. Setting ‘Series’ to nil may be that the book belongs to no series, while omitting series could mean that series is an inapplicable element to the current element.)

    From: The W3C

    XML Schema: Structures introduces a mechanism for signaling that an element should be accepted as ·valid· when it has no content despite a content type which does not require or even necessarily allow empty content. An element may be ·valid· without content if it has the attribute xsi:nil with the value true. An element so labeled must be empty, but can carry attributes if permitted by the corresponding complex type.

    A clarification:
    If you have a book xml element and one of the child elements is book:series you have several options when filling it out:

    1. Removing the element entirely – This can be done when you wish to indicate that series does not apply to this book or that book is not part of a series. In this case xsl transforms (or other event based processors) that have a template that matches book:series will never be called. For example, if your xsl turns the book element into table row (xhtml:tr) you may get the incorrect number of table cells (xhtml:td) using this method.
    2. Leaving the element empty – This could indicate that the series is ”, or is unknown, or that the book is not part of a series. Any xsl transform (or other evernt based parser) that matches book:series will be called. The value of current() will be ”. You will get the same number of xhtml:td tags using this method as with the next described one.
    3. Using xsi:nil=’true’ – This signifies that the book:series element is NULL, not just empty. Your xsl transform (or other event based parser) that have a template matching book:series will be called. The value of current() will be empty (not empty string). The main difference between this method and (2) is that the schema type of book:series does not need to allow the empty string (”) as a valid value. This makes no real sense for a series element, but for a language element that is defined as an enumerated type in the schema, xsi:nil=’true’ allows the element to have no data. Another example would be elements of type decimal. If you want them to be empty you can union an enumerated string that only allows ” and a decimal, or use a decimal that is nillable.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 163k
  • Answers 163k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Put the cell in it's own nib @interface IBOutlet UITableViewCell… May 12, 2026 at 12:08 pm
  • Editorial Team
    Editorial Team added an answer You must be using a template engine called Smarty. templates_c… May 12, 2026 at 12:08 pm
  • Editorial Team
    Editorial Team added an answer Somehow the relative path "../../fbconnect-iphone/src" is not working, but absolute… May 12, 2026 at 12:08 pm

Related Questions

Here's what I'm trying to do. I'm querying an XML file using LINQ to
I have a structure which I create a custom constructor to initialize the members
referring to this question , I've decided to duplicate the tables every year, creating
I have seen a few mentions of this idiom (including on SO ): //

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.