Paul Clapham wrote:When I did this several years ago, I saved it as XML. The model for a styled document does have a tree structure based on javax.swing.text.Element, so it isn't terribly hard to convert that tree structure into an equivalent XML tree structure. I start by getting the root of the model's tree:
and then I recursively convert that to an XML document. Elements in the tree become elements in the XML document, and attributes of the Elements become attributes of the XML elements, and likewise leaf nodes of the tree correspond to text nodes of the XML document. Of course there's a similar process to take the XML and rebuild the model of a styled document from it.
The process isn't very complicated but it does take some fiddling around with the details of javax.swing.text.Element, plus observing what you actually get out of a styled document.
Thanks for the quick reply. I really appreciate it. Anyway, I found a format called ".rtf". Seems like some has used it without any issue. What about it?