Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Converting to Docx using xtext/xtend and docx4j
Converting to Docx using xtext/xtend and docx4j [message #1233688] Mon, 20 January 2014 09:40 Go to next message
Davide G is currently offline Davide GFriend
Messages: 36
Registered: October 2013
Member
Hi, i'm developing a documentation generator plugin for eclipse and i'm using xtext/xtend and docx4j for generating docx documentation. The problem is: the doGenerate method from the xtend class for generating documentation, requires a string format documentation. So, i have to export the docx4j output to string to use it with xtext/xtend. I tried various methods from the docx4j packages, and tried to convert the docx package to byte array then to string. But it doesn't work. Any idea??? Confused Confused
Re: Converting to Docx using xtext/xtend and docx4j [message #1233698 is a reply to message #1233688] Mon, 20 January 2014 09:51 Go to previous messageGo to next message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 250
Registered: June 2013
Senior Member
Perhaps the following code snippet to read in external files in the Generator may help:


import static extension com.google.common.io.CharStreams.*
def addIncludeFile(String filename) '''
«val File incfile = new File("..\\!includefiles\\"+filename)»
«IF incfile.exists()»
«FOR String line : new FileReader(incfile).readLines»
«line»
«ENDFOR»
«ELSE»
«addErr("Error addIncludeFile: >" +filename+"< not in !includefiles directory")»
«ENDIF»
'''

Invoked by:
«addIncludeFile("a.sampletext")»

The relative path is in most cases the directory with the eclipse.exe file.


Re: Converting to Docx using xtext/xtend and docx4j [message #1233716 is a reply to message #1233698] Mon, 20 January 2014 10:24 Go to previous message
Davide G is currently offline Davide GFriend
Messages: 36
Registered: October 2013
Member
Uli Merkel wrote on Mon, 20 January 2014 04:51
Perhaps the following code snippet to read in external files in the Generator may help:


import static extension com.google.common.io.CharStreams.*
def addIncludeFile(String filename) '''
«val File incfile = new File("..\\!includefiles\\"+filename)»
«IF incfile.exists()»
«FOR String line : new FileReader(incfile).readLines»
«line»
«ENDFOR»
«ELSE»
«addErr("Error addIncludeFile: >" +filename+"< not in !includefiles directory")»
«ENDIF»
'''

Invoked by:
«addIncludeFile("a.sampletext")»

The relative path is in most cases the directory with the eclipse.exe file.




Just tried and doesn't worked. I saved the docx using the save() method from the docx4j package, and then called the previous method to copy all the content into a string, but it didn't work.

[Updated on: Mon, 20 January 2014 10:24]

Report message to a moderator

Previous Topic:[MWE] Dependency issues in 2.4.1 release
Next Topic:[Solved] Post processing in standalone maven project
Goto Forum:
  


Current Time: Fri Apr 19 03:43:00 GMT 2024

Powered by FUDForum. Page generated in 0.02246 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top