Re: Styles property for FO-DOCX converter

Hussein Shafie <[email protected]> Wed, 17 Jan 2024 17:05:40 +0100
Newsgroups gmane.text.xml.xfc.general
Message-ID <[email protected]>
Mridula P wrote:
> 
> I am trying to use the XMLMind java API to convert XSL-FO to DOCX.
> 
> We do have a styles file, which needs to be set to the Driver. We do 
> have a valid url which points to our file repository and we are trying 
> to pass it as an input to a micro service which does the conversion.
> 
> Passing the file repository URL as input has a security concern as it 
> contains security token and exposing those URL to the internet may cause 
> some potential issues.
> 
> Does XMLMind support OAUth authentication? Or is there anyway to pass a 
> URL without the token in the URL, instead we can pass the DB connection 
> and whether XML MInd can get the styles file?
> 

XMLmind XSL-FO Converter (XFC) does not support any kind of 
authentication because it does not need to.

It's up to you, the Java programmer embedding XFC in your program by the 
means of its API, to implement authentication if you need it.

To be more precise:



--> Do not embed XFC using com.xmlmind.fo.converter.Driver 
(http://www.xmlmind.com/foconverter/_distrib/doc/api/com/xmlmind/fo/converter/Driver.html). 


Instead use com.xmlmind.fo.converter.Converter 
(http://www.xmlmind.com/foconverter/_distrib/doc/api/com/xmlmind/fo/converter/Converter.html) 
which will give you more control over what you can do.

For example, Converter has setUserStyles method 
(http://www.xmlmind.com/foconverter/_distrib/doc/api/com/xmlmind/fo/converter/Converter.html#setUserStyles-com.xmlmind.fo.converter.UserStyles-) 
which must be passed a com.xmlmind.fo.converter.UserStyles 
(http://www.xmlmind.com/foconverter/_distrib/doc/api/com/xmlmind/fo/converter/UserStyles.html)

Download the styles file using any means you want (possibly involving 
authentication) and then parse downloaded data using UserStyles. 
loadFrom(InputStream in, String systemId) 
(http://www.xmlmind.com/foconverter/_distrib/doc/api/com/xmlmind/fo/converter/UserStyles.html#loadFrom-java.io.InputStream-java.lang.String-)



--> XFC always uses java.net.URL 
(https://docs.oracle.com/javase/8/docs/api/java/net/URL.html) to access 
files during a conversion.

java.net.URL supports authentication by the means of 
java.net.Authenticator 
(https://docs.oracle.com/javase/8/docs/api/java/net/Authenticator.html)

Therefore you may want to implement your own Authenticator and register 
it with the Java runtime using Authenticator.setDefault(Authenticator) 
(https://docs.oracle.com/javase/8/docs/api/java/net/Authenticator.html#setDefault-java.net.Authenticator-)


--
XMLmind FO Converter Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/xfc-support