Page 1 of 1

Get all tokens from docx.

PostPosted: Wed Jun 06, 2012 2:55 am
by mfruizs2
Hi Jason,

one question:

I have made one method to extract the tokens ( "${token}" ) for remplacement, but watching the log console, I saw that the funcition to merge the fields/tokens on my *.docx write on it the tokens that never are used.

Exist any form to get this tokens on list/hashmap/etc structure ? or Exist any form to remplace it for "void" if it isn`t in the hashmap for remplace?


Thx a lot and sry 4 my english :)

Re: Get all tokens from docx.

PostPosted: Fri Jun 15, 2012 1:06 am
by mfruizs2
1UP!

nobody know how to get this values without use a external function with "indeoxof" to get the tokens "${token}" ?

Re: Get all tokens from docx.

PostPosted: Sun Jun 17, 2012 6:00 pm
by jason
You can easily create an enhanced method of your own to meet your additional requirements, working from the source code in XmlUtils.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
        public static Object unmarshallFromTemplate(String wmlTemplateString,
                        java.util.HashMap<String, String> mappings, JAXBContext jc) throws JAXBException {
            String wmlString = replace(wmlTemplateString, 0, new StringBuilder(), mappings).toString();
            log.debug("Results of substitution: " + wmlString);
            return unmarshalString(wmlString, jc);
         }

etc
 
Parsed in 0.015 seconds, using GeSHi 1.0.8.4


I'd be happy to consider your enhancements for inclusion in docx4j, but have no plans to extend the unmarshallFromTemplate concept myself at this stage.

Re: Get all tokens from docx.

PostPosted: Tue Jun 19, 2012 10:02 pm
by mfruizs2
Maybe, could I re-code the code with ur sourcecode?

regard!

Re: Get all tokens from docx.

PostPosted: Fri Jun 22, 2012 2:58 am
by mfruizs2
Hi Jason,

we are made one code refactor and we got the funcitonality that we need, that is: we exchange the NO "hashmapped" token on entry hashmap by "void value" or "key value", one boolean var control it.

it's a "proof of concept" --> docx4j: 2.7.1-poc-beta.

We used it on our app and no bug found ;)

Maybe u could make offical our implementation hehe but it's based on 2.7.1 :P

cya :)

Re: Get all tokens from docx.

PostPosted: Wed Sep 26, 2012 2:52 am
by mfruizs2
Hi,

We did one update:

- Now, uncut "${ }", the token could be get like: ${tokenName}, before: "tokenName".


Cya! ;)


pd: srry 4 my english :P