简体   繁体   中英

What is a meaningful format to save formatted text in the database?

I have an existing application that has some parts of formatted text-blocks (standard formats such as bold, italic, unordered list, …) saved in the database. Currently these text-blocks are saved in a custom xml format. The editor is created with a WPF-RichtTextBox.

Since I have to make the editor more user-friendly and extend the application, and I know that in the future also SQL-Server Reporting Services and probably Silverlight must use this markup, I'm thinking about to change the format of the saved text-blocks. In the future there will be the following application-types that must interpret the markup:

  • WPF-Applications (with an editor)
  • HTML-Web-Application (maybe with an editor)
  • SQL-Server Reporting-Services
  • Silverlight (maybe with an editor)

I tend to use a subset of HTML. What would you use or advise and why? Maybe you also have a link to existing resources dealing with this topic?

Update

Currently, it seems that I will take HTML:

I plan to use a RichTextBox in the WPF-app als MainEditor. To convert I will use the microsoft sample converter from here . Does someone know if there is a newer version or has some remarks about pitfalls?

For silverlight I have looked at the silverlight RichTextBox: For all who plan to make something similar as I, be warned: The silverlight 4 RichTextBox seems not to be very powerfull (as far as I have seen). The simplest things such list-items with bullets must be done with a workaround. And it can not export in RichTextFormat! Don't count on this control without testing it.

For the HTML-site I will probably use CKEditor or TinyMce .

I thought also about using RTF as format, but because the silverlight RichtTextBox is does not support it, i will not use. For those who are interested in, here is a very interesting project for converting.

I'm not qualified to answer with respect to WPF and Silverlight, but with respect to SSRS and web applications, a subset of HTML will treat you fine, though you'll want to use SSRS 2008 or later.

In SSRS 2008, displaying HTML requires a simple setting on a text box placeholder. You can see an example here: http://dinesql.blogspot.com/2010/05/reporting-services-2008-showing-html.html

In a web application, displaying HTML is super easy, though I recommend first sanitizing your output using the AntiXSS library (using the GetSafeHTMLFragment() method): http://wpl.codeplex.com/

I plan to use a RichTextBox in the WPF-app als MainEditor. To convert I will use the microsoft sample converter from here. Does someone know if there is a newer version or has some remarks about pitfalls?

I don't know about the RichTextBox.

I have written a managed, WYSIWYM HTML edit control for .NET . It's specifically for [X]HTML, and described in some detail on its web site.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM