<p>I am writing a basic word processing application and am trying to settle on a native "internal" format, the one that my code parses in order to render to the screen. I'd like this to be XML so that I can, in the future, just write XSLT to convert it to ODF or XHTML or whatever.</p>

<p>When searching for existing standards to use, the only one that looks promising is ODF. But that looks like massive overkill for what I need. All I need is paragraph tags, font selection, font size &amp; decoration...that's pretty much it. It would take me a long time to implement even a minimal ODF renderer, and I'm not sure it's worth the trouble.</p>

<p>Right now I'm thinking of making my own XML format, but that's not really good practice. Better to use a standard, especially since then I can probably find the XSLTs I might need in the future already written.</p>

<p>Or should I just bite the bullet and implement ODF?</p>

<p><strong>EDIT: Regarding the Answer</strong></p>

<p>I knew about XSL-FO before, but due to the weight of the spec hadn't really consdiered it. But you're right, a subset would give me everything I need to work with and room to grow. Thanks so much the reminder.</p>

<p>Plus, by including a rendering library like FOP or RenderX, I get PDF generation for free. Not bad...</p>

[{'answer_id': 31234, 'author': 'Frank Krueger', 'author_id': 338, 'author_profile': 'https://Stackoverflow.com/users/338', 'pm_score': -1, 'selected': False, 'text': '<p>XML is an <em>external</em> format, not <em>internal</em>.</p>\n\n<p>What\'s wrong with <a href="http://www.w3.org/TR/xhtml1/" rel="nofollow noreferrer">XHTML</a>? It\'s simple and it\'s ubiquitous (at least HTML is). Your implementation would be easy to debug, and your users will be eternally greatful.</p>\n'}, {'answer_id': 31255, 'author': 'levand', 'author_id': 3044, 'author_profile': 'https://Stackoverflow.com/users/3044', 'pm_score': 0, 'selected': False, 'text': "<p>Well, right... But since I need to be able to convert to XML anyway, why hold both my document tree and the DOM tree in memory, when there's nothing preventing me from working right off the DOM tree?</p>\n\n<p>Particularly since one unique feature of my program is that everything is always saved as you type, and I don't want to run a whole conversion to XML every time I hit a key. Easier just to tie input and output directly to my in-memory DOM tree.</p>\n\n<p>Edit:\nOh, and the only problem with XHTML is that I do want to support basic pagination. Though I guess there's nothing stopping me with using some additional tags for that...</p>\n"}, {'answer_id': 31271, 'author': 'toolkit', 'author_id': 3295, 'author_profile': 'https://Stackoverflow.com/users/3295', 'pm_score': 1, 'selected': False, 'text': '<p>If its only for word processing, then perhaps <a href="http://en.wikipedia.org/wiki/DocBook" rel="nofollow noreferrer">DocBook</a> might be a little lighter than ODF?</p>\n\n<p>However, the wiki entry states:</p>\n\n<blockquote>\n  <p>DocBook is a semantic markup language for technical documentation. It was originally intended for writing technical documents related to computer hardware and software but it can be used for any other sort of documentation.</p>\n</blockquote>\n\n<p>So it might not be so suitable for a general-purpose word-processor?</p>\n\n<p>The advantage of using DocBook would be the fact that a number of DocBook -> other format converters should be available? Hope this helps.</p>\n'}, {'answer_id': 31278, 'author': 'levand', 'author_id': 3044, 'author_profile': 'https://Stackoverflow.com/users/3044', 'pm_score': 1, 'selected': False, 'text': '<p>I like DocBook, but it doesn\'t really fit. It strives to be presentation-independent, the intention being that you would use XSLT to render it to a presentation format.</p>\n\n<p>In a word processor, the user is editing presentation along with the content. For example, the user doesn\'t want to mark a "keyword", necessarily, they want to make some text bold.</p>\n\n<p>A DocBook editor would be a very nice thing (I\'m not sure a good one exists), but it\'s not really what I\'m doing.</p>\n'}, {'answer_id': 35517, 'author': 'gz.', 'author_id': 3665, 'author_profile': 'https://Stackoverflow.com/users/3665', 'pm_score': 4, 'selected': True, 'text': '<p>As you are sure about needing to represent the <em>presentational</em> side of things, it may be worth looking at the <a href="http://www.w3.org/TR/xsl/" rel="noreferrer">XSL-FO</a> W3C Recommendation. This is a full-blown page description language and the (deeply unfashionable) other half of the better-known XSLT.</p>\n\n<p>Clearly the whole thing is anything but "lightwight", but if you just incorporated a\nvery limited subset - which could even just be (to match your spec of "paragraph tags, font selection, font size &amp; decoration") <a href="http://www.w3.org/TR/xsl/#fo_block" rel="noreferrer">fo:block</a> and the <a href="http://www.w3.org/TR/xsl/#common-font-properties" rel="noreferrer">common font properties</a>, something like:</p>\n\n<pre><code>&lt;yourcontainer xmlns:fo="http://www.w3.org/1999/XSL/Format"&gt;\n    &lt;fo:block font-family="Arial, sans-serif" font-weight="bold"\n        font-size="16pt"&gt;Example Heading&lt;/fo:block&gt;\n    &lt;fo:block font-family="Times, serif"\n        font-size="12pt"&gt;Paragraph text here etc etc...&lt;/fo:block&gt;\n&lt;/yourcontainer&gt;\n</code></pre>\n\n<p>This would perhaps have a few advantages over just rolling your own. There\'s an open specification to work from, and all that implies. It reuses CSS properties as XML attributes (in a similar manner to SVG), so many of the formatting details will seem somewhat familiar. You\'d have an upgrade path if you later decided that, say, intelligent paging was a must-have feature - including more sections of the spec as they become relevant to your application.</p>\n\n<p>There\'s one other thing you might get from investigating XSL-FO - seeing how even just-doing-paragraphs-and-fonts can be horrendously complicated. Trying to do text layout and line breaking \'The Right Way\' for various different languages and use cases seems very daunting to me. </p>\n'}]
['https://Stackoverflow.com/questions/31226', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3044/']