Welcome close

We've made some changes!

As you may have noticed, we've made some changes to the DevCenter to include the new Exchange site, a code community for Ektron developers. You may use the same username and password to login for both the Exchange and DevCenter. Your DevCenter profile has moved over to the Exchange site. You also may notice we have removed some profile functionality in favor of new functionality, including Activity Streams. We welcome your feedback about the site on the Exchange forum.

SEARCH : searchSite
This SectionSite Wide
SEO_version8 

RSS Feed Print Category View
AddContent is adding linebreaks and whitespace
mr.moses
Posted: Tuesday, February 2, 2010 4:11 PM
Joined: 9/15/2006
Posts: 17


AddContent seems to be adding line breaks and other whitespace to my XML.  I expect my XML to come out the same way it goes in, but it doesn't.  This only seems to be happening with the AddContent method, if the content is updated (in the Workarea or through the API), the whitespace is removed.

 

Dim ContentAPI As New Ektron.Cms.API.Content.Content
Dim ContentID As Long = ContentAPI.AddContent(Title, Comment, ContentHTML, SearchText, Summary, LanguageID, FolderID, GoLiveDate, Endate, Nothing)

ContentHTML looks like this (one line):

<event><title>aaTest linebreaks</title><date><startdate>2010-02-05</startdate><starttime /><enddate>2010-02-14</enddate><endtime /><location>Somewhere</location><label /></date><description>Placerat magna ultrices phasellus in massa, parturient? Turpis nisi ac risus, nascetur! Pellentesque tristique, elementum et, eu sagittis auctor a montes lorem placerat vut dis, tortor etiam quis.</description><cta><a href="http://www.guide2digitallearning.com/events/">Register now</a></cta><eventtype>inPerson</eventtype><legal /></event>

When I get the content

Dim ContentAPI As New Ektron.Cms.API.Content.Content
Dim ContentData As Ektron.Cms.ContentData = ContentAPI.GetContent(ContentID)

ContentData.Html looks like this

<event>
<title>aaTest linebreaks</title>

<date>
<startdate>2010-02-05</startdate>

<starttime />

<enddate>2010-02-14</enddate>

<endtime />

<location>Somewhere</location>

<label />
</date>

<description>Placerat magna ultrices phasellus in massa,
parturient? Turpis nisi ac risus, nascetur! Pellentesque
tristique, elementum et, eu sagittis auctor a montes lorem
placerat vut dis, tortor etiam quis.</description>

<cta>
<a href="http://www.guide2digitallearning.com/events/">Register
now</a>
</cta>

<eventtype>inPerson</eventtype>

<legal />
</event>

I've tried .Trim-ing and .Replace(vbCrLf, "") and that works, but it doesnt get rid of the
spaces. For example, "Register now" does not equal "Register\r\n now" or
"Register now"

In gathering samples for this post, The <cta> link text didn't always have a line break.
It varied depending on the length of the url. If the href value is longer, the output may
look like this

  <cta>
<a href="http://www.guide2digitallearning.com/events/longerUrlHere">
Register now</a>
</cta>

 If the <cta> link href is shorter, the output may look like this

  <cta>
<a href="http://test.com">Register now</a>
</cta>

Ektron Version:7.66 SP2 (Build7.6.6.47)




eGandalf
Posted: Tuesday, February 2, 2010 4:36 PM
Joined: 9/13/2006
Posts: 2367


Hey Mr. Moses,

 

It's odd to see that you're putting that XML into the system. XML in a Smart Form XML structure (<root>...</root>).

 

Do you have a Smart Form set up that follows this event structure?

 

Not that it should make a difference, but you never know what could.

 

When you edit the content in the workarea and the whitespace is removed, are you removing it or is it getting removed automatically when you checkin/publish?

 

There is more than one way to skin a cat, as they say, and I'm curious as to whether one of the "back end" APIs may perform better, even if it does require more code.


 


http://www.ektron.com/services/
mr.moses
Posted: Wednesday, February 3, 2010 10:06 AM
Joined: 9/15/2006
Posts: 17


 

Yes, the SmartForm is setup to use that structure (<event>...</event>).

 

I'm pretty sure the whitespace is removed automatically after a checkin/publish, both through the Workarea and through the API.  The content doesn't have to change, it just needs to be saved again.

 

Ektron Support said to remove the Plain Text Field for <description> and use a Rich Area Field instead (even though the <description> should be plain text).  They also said to wrap the value in <p></p> tags.  Which means I need to add it <p>..</p> when saving content with the API, and remove it when getting content because the <description> value should be plain text.

 

Also, the SmartForm elements are placed in a table to keep it organized and lined up nicely. Given the example of the <cta> link element breaking at a certain length, the width of that table may be part of the issue.  I'm going to do some more testing with that.

Sorry my reply took so long, I had trouble posting to the forums in IE and Chrome. Attached are screenshots of the problems I was having.  IE validation wasn't working, and in Chrome, I selected 1 for font size and it used 48.  I'm not trying raise more issues or anything, I just thought it was a great opportunity to show why I tend to not use these forums.


File Attachment(s):
ektron dev forum validation error.png (60898 bytes)
ektron dev forum chrome font size error.png (100382 bytes)

eGandalf
Posted: Wednesday, February 3, 2010 10:29 AM
Joined: 9/13/2006
Posts: 2367


I wonder if a regular expression replace on the returned string would eliminate those space characters.


Something like: 

html = Regex.Replace(html, ">[\\s]*<", "><"); 
// replaces all whitespace between xml tags with ""

As far as the forum editor issues go, I've been on this forum in Chrome, Firefox, and IE for the last three years and have never seen the like.

After testing, though, I can confirm the 48pt issue in Chrome and will report it.



http://www.ektron.com/services/


mr.moses
Posted: Wednesday, February 3, 2010 11:58 AM
Joined: 9/15/2006
Posts: 17


After more testing, I have confirmed that checkin/publish (in Workarea or API) does remove the added whitespace.

 

 

 

Also, the table in the SmartForm did not make a difference, neither did Plain Text Field or Rich Area Field.  I modified the SmartForm to have a Rich Area Field instead of Plain Text Field and wrapped the text in <p>..</p> tags, but got the same result.

 

 

 

Adjusting the width of the table in the SmartForm or removing the table completely did not make a difference either.

 

 

 

Ektron Support said to just build a new SmartForm, but I already have a lot of content using the existing SmartForm, so I don't think that would be a good solution.

 

 

 

The regular expression to replace all whitespace between xml tags would probably work, but might not be a good solution either. What if a user does want 2 or more spaces in between some text?

 

 

For a workaround right now, I am just using the API to update the content immediately after it is created (AddContent, GetContent, GetContentForEditing, SaveContent, PublishContent).

 

 



eGandalf
Posted: Wednesday, February 3, 2010 12:10 PM
Joined: 9/13/2006
Posts: 2367


That would be my recommended API workaround.

The Regex I included should only remove whitespace between XML tags and should not affect any text within...

However, if everything is plain text, then multiple spaces would be removed when output to HTML (which ignores more than one space, and treats it as a single). Another Regex replace could change those to xml character: &#160




http://www.ektron.com/services/


Jennifer Lee
Posted: Wednesday, February 3, 2010 3:13 PM
Joined: 11/14/2006
Posts: 138


 I have to agree with mr.moses on the forum issues... when I edit my forum post, it adds extra line breaks between my paragraphs. See screenshot. I'm using Firefox 3.5.7.

 


File Attachment(s):
weirdeditbug.JPG (32327 bytes)

mr.moses
Posted: Wednesday, February 3, 2010 3:43 PM
Joined: 9/15/2006
Posts: 17


I had that problem in Firefox 3.5.7 too, thats why my post had all that extra spacing.

Firefox was the only browser I could actually post in.


 

Jump to different Forum... 






Register for Synergy 2010

Articles
Design without Borders, yet with Structure
CMS400.NET and Adobe Flex
GeoMapping
EkML Ektron Markup Language
Taxonomy

[First] [Previous] [Next] [Last]


See All Articles