-1

Can I use React, Vue, or Marko or similar libraries to accomplish XML output?

It appears that XML output is not a feature of any of these libraries (although it does seem to be possible to inject new (final,renderable) tags into Marko).

I need to render to various formats including HTML, ePub, iBooks, WordML and some other XML formats specific to educational settings. Ideally I would prefer to use the same tool to render to dynamic HTML, and static XML markup, rather than using React for dynamic HTML, and (eg) pug for static XML.

pwray
  • 1,075
  • 1
  • 10
  • 19

1 Answers1

0

XML output is simply a document type. You should be able to output XML in any of these libraries/frameworks, and you simply need the correct document headers for each document format.

The MDN has a great introduction to creating a well-formed XML document which will help you create the document headers and entities you need when building the page.

If you want to transform the documents into other document types you will likely have to build your own transformations within your app. Most libraries and frameworks assume you will do transforms yourself, or use transformer plugins to do so. There's really no way around doing this yourself in this day and age.

Then again, the libraries and frameworks you mentioned are built for HTML documents. That does not preclude you from creating well-formed XHTML/XML when using them. Tags are tags, strings are strings, markup is markup, and they should each handle those core scenarios.

As you stated, though, Marko is exceptionally qualified to build DOM trees, and well-formed XHTML/XML markup would be easy when using it.

seangates
  • 1,467
  • 11
  • 28
  • I'm familiar with XML, having used Saxon, Apache Cocoon, lxml, XSLT etc. My understanding is that (eg) React could not output XML without forking and supplementing react-dom, at a minimum. Can you be more specific about what you mean by 'transformation' in this context? – pwray Apr 25 '18 at 10:20
  • Transformation is basically all the different ways your data needs to be represented. For example, if it comes out of a database as JSON, you might want to transform it into HTML, XML, ePub, iBooks, etc. E.g. you have to transform it. – seangates Apr 26 '18 at 04:24