Jazz Register Log in
Jazz Forum Welcome to the Jazz Community Forum

Welcome to the Jazz Community Forum

Connect and collaborate with IBM Engineering experts and users

Line breaks and leading spaces in programmatically created work items

Hi RTC developers,

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 &lt;br/&gt
  - We replaced each leading space with &amp;nbsp;

The resulting XML looks like:
<dc:description>
Items:&lt;br/&gt;
&amp;nbsp;&amp;nbsp;-&amp;nbsp;line&amp;nbsp;1&lt;br/&gt;
...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?



0 votes


Accepted answer

Permanent link
That is correct, in both Eclipse and the Web in both Edit or Preview modes.

Attached are the results.

Web Edit Mode
Web Preview Mode Eclipse

Frederic Mora selected this answer as the correct answer

0 votes

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

Permanent link
As Chris shows by example, if you have valid XHTML content, it should work. Here are some possibly useful references:

http://open-services.net/bin/view/Main/CmSpecificationV2
dcterms:description
Value-type: XMLLiteral
Descriptive text (reference: Dublin Core) about resource represented as rich text in XHTML content. SHOULD include only content that is valid and suitable inside an XHTML <div> element.

http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#section-XMLLiteral

http://open-services.net/pipermail/oslc-core_open-services.net/2011-November/001178.html
[this last item includes some discussion about formatted plain text in descriptions]

If there is some sort of defect related to 4.0.1, we should file that, but your fastest relief is likely to move up to 4.0.3 if that is the case.

1 vote


Permanent link
Hi Fred,

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:&lt;br/&gt;- line 1&lt;br/&gt;- line 2&lt;br/&gt;&amp;#160;&amp;#160;&amp;#160;- line 2.1&lt;br/&gt;&amp;#160;&amp;#160;&amp;#160;- line 2.2</dc:description>
</oslc_cm:ChangeRequest>


0 votes

Comments

By the way, I'm using 4.0.3, not sure if that matters.

Hi Chris,

When you say "that works", do you mean that you saw the description in the Eclipse client with the correct spacing and the <br/> interpreted correctly?


Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,985

Question asked: Jun 17 '13, 7:07 p.m.

Question was seen: 5,303 times

Last updated: Jun 18 '13, 6:53 p.m.

Confirmation Cancel Confirm