On Mon, May 7, 2012 at 12:07 PM, Pavel Sanda <sa...@lyx.org> wrote: > Nico Williams wrote: >> How does LyX represent documents internally? If it does it in an >> objectified form then it should be fairly straightforward to walk the >> document tree and emit XML, no? Or, looking at .lyx files, maybe it >> should be possible to script a simple LyX->XML conversion.... has >> anyone tried this before? > > we miss someone who knows docbook/sgml/xml rather well and would like to help > to bring lyx output more up-to-date or at least clearly state what needs to > be done. > http://article.gmane.org/gmane.editors.lyx.devel/119220
Lookingat LyX's format, it seems like translating to XML using a LyX-specific schema should be utterly straightforward. For example, something like this: \lyxformat 413 \begin_document \begin_header \textclass article ... \end_header \begin_body \begin_layout Title Some Doc \end_layout \begin_layout Author Joe Sixpack \begin_inset VSpace defskip \end_inset Sixpack Corp. \end_layout \begin_layout Abstract Foo bar baz blah blah. \end_layout \begin_layout Abstract Two paragrap abstract, eh? \end_layout ... should translate into: <article> <title>Some Doc</title> <author>Joe Sixpack<vspace/>Sixpack Corp.</author> <abstract>Foo bar baz blah blah.</abstract> <abstract>Two paragrap abstract, eh?</abstract> ... </article> Translating insets and layouts into XML elements and attributes seems relatively straightforward. Translating directives seems straightforward also. Now, note that the two paragraph abstract would be translated into two <abstract> elements, but an XSLT stylesheet could easily translate that into: <abstract><p>...</p><p>...</p></abstract> A straightforward LyX->XML translation seems like the best approach to LyX->XML translation because translation to any other schemas can then be done via XSLT. Nico --