Welcome to the Jazz Community Forum
Line breaks and leading spaces in programmatically created work items

We are programmatically creating work items using the Resource Oriented Work Item API. We set up the description using a source text that contains no enrichments, but does contain line breaks and leading blanks forming ASCII indented lists, e.g.:
Items: - line 1 - line 2 - line 2.1 - line 2.2
We found that if we PUT a <dc:description> block containing escaped HTML (with br tags and nbsp entities), we get the formatting we want... But only in the web UI.
What we do is this:
- We insert <BR/> tags for newlines, which, once escaped, give <br/>
- We replaced each leading space with &nbsp;
The resulting XML looks like:
<dc:description> Items:<br/> &nbsp;&nbsp;-&nbsp;line&nbsp;1<br/> ...etc... </dc:description>(Note: what we submit is actually escaped, so each ampersand within the block is actually replaced by & amp ;)
However, even so, we only see the desired result in the Web UI, and only in preview mode. If we click the Edit button on the description field, we see the unescaped HTML. The Eclipse UI always shows the unescaped HTML.
I understand the restrictions on HTML, but surely there is a way to create a description with blank lines and leading spaces, isn't it? How do you do that?
Accepted answer

Attached are the results.



Comments

Got it. There is a gotcha: the XML quoted by Chris has been unescaped by the forum software.
Summary of solution: We want to create a description with line breaks and leading blanks, e.g.,
Items:
- line 1
- line 2
- line 2.1
- line 2.2
Here is the algorithm to apply when you send a <dc:description> block:
each newline has to be replaced with the sequence & lt;br/& gt; (I am inserting blanks here to avoid the forum software interpreting it).
Each space has to be replaced with & #160; (again, mind the extra space), but only from the start of the line until the first non-blank character. Otherwise, you get lines as wide as a paragraph, and you have to scroll horizontally to read the text.

Here is the corresponding description block (warning: a space has been added after each ampersand to avoid interpretation):
<dc:description>Items:& lt;br/& gt;- line 1& lt;br/& gt;- line 2& lt;br/& gt;& #160;& #160;& #160;& #160;& #160;& #160;- line 2.1& lt;br/& gt;& #160;& #160;& #160;& #160;& #160;& #160;- line 2.2</dc:description>
2 other answers


This worked for me:
<?xml version="1.0" encoding="UTF-8"?><oslc_cm:ChangeRequest xmlns:oslc_cm="http://open-services.net/xmlns/cm/1.0/" rdf:about="https://jazz-server:9443/ccm/resource/itemName/com.ibm.team.workitem.WorkItem/60" xmlns:dc="http://purl.org/dc/terms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:calm="http://jazz.net/xmlns/prod/jazz/calm/1.0/" xmlns:rtc_cm="http://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/" xmlns:oslc_pl="http://open-services.net/ns/pl#"> <dc:description>Items:<br/>- line 1<br/>- line 2<br/>&#160;&#160;&#160;- line 2.1<br/>&#160;&#160;&#160;- line 2.2</dc:description>
</oslc_cm:ChangeRequest>