PHP microservice using dita #HTML5


jack10086007@...
 

Hi,

I am currently working on a project, which is to use PHP to call a method which is to convert existing dita file to html5. May I get any suggestions? Thank you!

Cheers,
Jack


Don Day
 

I assume you are talking about rendering single topics on demand rather than initiating the usual map-driven build and thereafter serving HTML files statically out of a built folder. Converting single topics on demand using PHP is necessarily short of that full normal build view, but some degree of dynamically customized output is possible. What are the goals of your project, and how closely do you require a fully contemporary DITA output result?

--
Don Day

On 1/26/2021 2:40 AM, jack10086007@... wrote:
Hi,

I am currently working on a project, which is to use PHP to call a method which is to convert existing dita file to html5. May I get any suggestions? Thank you!

Cheers,
Jack



Avast logo

This email has been checked for viruses by Avast antivirus software.
www.avast.com



jack10086007@...
 

Hi Don,

Thank you so much for your reply!

Yes, it is currently just a single topic/concept, not even require formatting.

What I have tried so far:

1. Created a controller through the maven project, and inside PHP fetched that endpoint. However, I failed to use Java API as shown on the doc. Error message was 'Transtype xhtml not supported'.

2. Then, I was currently trying to wrap everything inside docker but was blocked by setting up JAVA HOME environment variable.

 

May I please ask if you have any better solutions? Thank you very much and wish you could have a lovely night!

Cheers,
Jack


Radu Coravu
 

Hi Jack,

I also replied to you on Slack, about using the Java API to start the DITA OT:

There is more information about making this work here:
https://github.com/dita-ot/dita-ot/issues/3647
The “dost.jar” is useful for compiling your Java code but for running you need an entire DITA OT distribution

If I were you I would maybe consider running the DITA OT command line directly as an external process from the PHP script. So you would need a DITA OT downloaded and available on the server side.

Or as another alternative you can create a Java wrapper which starts the DITA OT as a separate process and create a service wrapper around it.

Regards,

Radu

Radu Coravu
Oxygen XML Editor
On 1/27/21 09:41, jack10086007@... wrote:

Hi Don,

Thank you so much for your reply!

Yes, it is currently just a single topic/concept, not even require formatting.

What I have tried so far:

1. Created a controller through the maven project, and inside PHP fetched that endpoint. However, I failed to use Java API as shown on the doc. Error message was 'Transtype xhtml not supported'.

2. Then, I was currently trying to wrap everything inside docker but was blocked by setting up JAVA HOME environment variable.

 

May I please ask if you have any better solutions? Thank you very much and wish you could have a lovely night!

Cheers,
Jack


  


Jingjun Long
 

hi Jack,

I assume there will be multiple requests from Web browser to render XML to HTML output. I.e.: there will be multiple instances of converting XML to HTML running concurrently. I think your approach (Create a web service in Java to call Data-OT)  is a good approach.  

To call DITA-OT from Java program is documented here: https://www.dita-ot.org/dev/reference/java-api.html

Can you show the detail error message you got?

J.J. 


On Jan 27, 2021, at 3:41 PM, jack10086007@... wrote:

Hi Don,

Thank you so much for your reply!

Yes, it is currently just a single topic/concept, not even require formatting.

What I have tried so far:

1. Created a controller through the maven project, and inside PHP fetched that endpoint. However, I failed to use Java API as shown on the doc. Error message was 'Transtype xhtml not supported'.

2. Then, I was currently trying to wrap everything inside docker but was blocked by setting up JAVA HOME environment variable.

 

May I please ask if you have any better solutions? Thank you very much and wish you could have a lovely night!

Cheers,
Jack



despopoulos_chriss
 

As a different solution (not necessarily better), we do the DITA to HTML transform in the browser.  (This is also what Michael Kay does with DocBook, in his own way for his own docs.)  We support a subset of DITA that is roughly equivalent to LwDITA, but it's all a matter of what you support in the XSLT.  The one thorny issue is that we have to do a one-step transform...  No pre/post passes. This has proved to be a problem with conrefs to things like table rows. 

The good news is that it's very light-weight.  On the server side, it's essentially a static site.  It also seems to be quicker than calling the OT.  In my ignorant innocence, I tried transforming single topics via the OT before turning to client-side transforms.  Because of the multiple passes, the performance seemed sluggish.  It could just be that I don't know the optimal way to invoke the OT. 

Other good news is that we can integrate into our HTML GUI.  So we use the same code to present microcontent in the GUI. 

See it here:
https://docs.turbonomic.com/docApp/doc/index.html?config=8.0.json