Project

General

Profile

Actions

Defect #7132

closed

do not include empty nodes to XML response when no value is set

Added by Alex Last over 13 years ago. Updated over 13 years ago.

Status:
Closed
Priority:
High
Category:
REST API
Target version:
-
Start date:
2010-12-18
Due date:
% Done:

0%

Estimated time:
Resolution:
Wont fix
Affected version:

Description

I'm trying to parse the "issues.xml" response from Redmine REST API using Java and Castor XML library.
this is the text I get from the server (I skipped some not related items):

<issue>
    <id>210</id>
    <project name="ace" id="9579" />
    <subject>testGetIssues: Sat Dec 18 11:47:13 PST 2010</subject>
    <description></description>
    <start_date>2010-12-18</start_date>
    <due_date></due_date>
    <done_ratio>0</done_ratio>
    <estimated_hours></estimated_hours> <---- can this be REMOVED from the response?
</issue>

as you can see, "estimated_hours" and some other xml nodes are included even though they don't have any values.
unfortunately, Castor XML parsing library believes that if the node is present, then its value must be initialized, which means the Java object will get

  Float estimatedHours = 0.0

value instead of NULL (as it should!).

so I'm wondering if it's possible to not add empty nodes in the xml response in REST API?
this seems like an easy and useful thing to do, so I'm setting the priority to High.

I believe it should be done in a generic way so that other empty nodes are omitted in the xml response as well (like "due_date" in my example above) - although my main concern at this moment is "estimated_hours".

Actions #1

Updated by Jean-Philippe Lang over 13 years ago

I think it's important to know from the response that this attribute is null.
What about having <estimated_hours /> rather than <estimated_hours></estimated_hours> in the response?

Actions #2

Updated by Alex Last over 13 years ago

unfortunately, <estimated_hours /> is treated by Castor XML the same. well, I think we can close this request as "wontfix". this is a problem with the Castor XML library itself (http://www.junlu.com/list/70/105232.html)

whether or not to include empty nodes - it's a matter of personal preference.
on one hand, including empty nodes shows to clients that the server didn't forget to provide some info,
but at at the same time the number of nodes can grow up in the future redmine versions and sending them all even when they are empty can look weird.

anyway, I applied a workaround in my program (skipping those empty xml nodes before parsing with Castor), so this issue does not bother me anymore. I think I should seriously consider ditching Castor XML library whatsoever - it gives more headache than helps.

anyway, this can be closed as "wontfix" - up to you.
Thanks, Jean-Philippe.

Actions #3

Updated by Alex Last over 13 years ago

  • Status changed from New to Resolved
Actions #4

Updated by Jean-Philippe Lang over 13 years ago

  • Status changed from Resolved to Closed
  • Resolution set to Wont fix

Thanks for the feedback.

Actions

Also available in: Atom PDF